// Euclid's algorithm (simple recursive version)
// gets the greatest common divisor
const gcd = (a, b) => {
	if(b === 0) {
		return a;
	}

	return gcd(b, a % b);
};

export default {

	methods: {
		/**
		 * Age old way of turning bytes into a nicer, human readable format.
		 *
		 * @param      {<type>}  size       The size
		 * @param      {number}  precision  The precision
		 * @return     {<type>}  { description_of_the_return_value }
		 */
		formatBytes(size, precision = 2) {
			const
				base = Math.log(size) / Math.log(1024),
				floored = Math.floor(base),
				unit = ['bytes', 'KB', 'MB', 'GB', 'TB'][floored],
				formattedBytes = Math.pow(1024, base - floored).toFixed(precision);

			return `${formattedBytes} ${unit}`;
		},

		/**
		 * Turn a (decimal) aspect ratio into the form "x:y".
		 *
		 * @param      {number}  decimal     The decimal eg. 1.5
		 * @param      {number}  multiplier  Multiplier is used to remove the
		 * digits after our decimal point and simplify the calculation / avoid rounding issues.
		 * @return     {string}  { description_of_the_return_value }
		 */
		formatAspectRatioFromDecimal(decimal, multiplier = 1) {
			if(decimal === multiplier) {
				return '1:1';
			}

			const
				x = decimal * multiplier,
				y = multiplier,
				// make sure the first argument is the larger of the numbers
				divisor = gcd(
					y < x ? x : y,
					y < x ? y : x
				);

			return `${x / divisor}:${y / divisor}`;
		}
	}
};

@@ -290,22 +290,22 @@
 m      %7B
-%3Ctype%3E
+number
 %7D  size 
@@ -371,16 +371,21 @@
 ecision%0A
+%09%09 *%0A
 %09%09 * @re
@@ -398,52 +398,37 @@
    %7B
-%3Ctype%3E%7D  %7B description_of_the_return_value %7D
+string%7D  Formatted file size.
 %0A%09%09 
@@ -1013,16 +1013,21 @@
 issues.%0A
+%09%09 *%0A
 %09%09 * @re
@@ -1049,43 +1049,21 @@
 g%7D  
-%7B description_of_the_return_value %7D
+Aspect ratio.
 %0A%09%09 

Update unfinished comments in media formatters mixin.