const months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ];

module.exports = {
	flattenFiles: function flattenFiles (tree, path = '/', files = []) {
		tree.forEach((item) => {
			if (item.type === 'file') {
				files.push(path + item.name);
			} else {
				flattenFiles(item.files, path + item.name + '/', files);
			}
		});

		return files;
	},
	formatDate (date) {
		return `${months[date.getUTCMonth()]} ${date.getUTCDate()}`;
	},
	formatHits (hits) {
		if (hits < 1e9) {
			return 1;
		}

		return Math.round(hits / 1e9);
	},
	formatMiB2TiB (mb) {
		return Math.floor(mb / 1024 / 1024 / 10) * 10;
	},
	formatNumber (number) {
		return Math.floor(number).toString().replace(/\d(?=(?:\d{3})+$)/g, '$& ');
	},
	getMinifiedName (name) {
		return name.replace(/\.(js|css)$/i, '.min.$1');
	},
	getNonMinifiedName (name) {
		return name.replace(/\.min\.(js|css)$/i, '.$1');
	},
	listFiles: function listFiles (files = [], path) {
		if (!path.length) {
			return files;
		}

		let p = path.slice();
		let n = p.shift();
		let d = files.filter(f => f.name === n)[0];

		return d && d.files ? listFiles(d.files, p) : null;
	},
	linRange (max, number) {
		let array = [];

		for (let i = 1; i <= number; i++) {
			array.push(max * i / number);
		}

		return array;
	},
	logRange (min, max) {
		let array = [];

		for (let i = min; i <= max; i *= 10) {
			array.push(i);
		}

		return array;
	},
	multiplyDeep: function multiplyDeep (data, n) {
		if (typeof data !== 'object') {
			return data;
		}

		Object.keys(data).forEach((key) => {
			if (key !== 'rank' && typeof data[key] === 'number') {
				data[key] *= n;
			} else if (data[key] && typeof data[key] === 'object') {
				multiplyDeep(data[key], n);
			}
		});

		return data;
	},
	nth (n) {
		n = Math.floor(n);

		if (n === 1) {
			return '';
		} else if (n === 2) {
			return '2nd';
		} else if (n === 3) {
			return '3rd';
		}

		return `${n}th`;
	},
};

@@ -1800,16 +1800,34 @@
 loor(n);
+%0A%09%09let m = n %25 10;
 %0A%0A%09%09if (
@@ -1870,13 +1870,23 @@
  (n 
+%3E 20 && m 
 === 
-2
+1
 ) %7B%0A
@@ -1899,13 +1899,83 @@
 urn 
-'2nd'
+%60$%7Bn%7Dst%60;%0A%09%09%7D else if (n === 2 %7C%7C (n %3E 20 && m === 2)) %7B%0A%09%09%09return %60$%7Bn%7Dnd%60
 ;%0A%09%09
@@ -1992,16 +1992,39 @@
 (n === 3
+ %7C%7C (n %3E 20 && m === 3)
 ) %7B%0A%09%09%09r
@@ -2033,13 +2033,16 @@
 urn 
-'3rd'
+%60$%7Bn%7Drd%60
 ;%0A%09%09

Fix jsdelivr/jsdelivr#18088