diff --git a/dist/_30s.es5.js b/dist/_30s.es5.js index f4329bf8e4f..0dfce2ef23c 100644 --- a/dist/_30s.es5.js +++ b/dist/_30s.es5.js @@ -114,9 +114,65 @@ throw new TypeError("Invalid attempt to destructure non-iterable instance"); } + var fs = typeof require !== "undefined" && require('fs'); + var crypto = typeof require !== "undefined" && require('crypto'); - var fs = typeof require !== "undefined" && require('fs'); + var CSVToArray = function CSVToArray(data) { + var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ','; + var omitFirstRow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + return data.slice(omitFirstRow ? data.indexOf('\n') + 1 : 0).split('\n').map(function (v) { + return v.split(delimiter); + }); + }; + + var CSVToJSON = function CSVToJSON(data) { + var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ','; + var titles = data.slice(0, data.indexOf('\n')).split(delimiter); + return data.slice(data.indexOf('\n') + 1).split('\n').map(function (v) { + var values = v.split(delimiter); + return titles.reduce(function (obj, title, index) { + return obj[title] = values[index], obj; + }, {}); + }); + }; + + var JSONToFile = function JSONToFile(obj, filename) { + return fs.writeFile("".concat(filename, ".json"), JSON.stringify(obj, null, 2)); + }; + + var JSONtoCSV = function JSONtoCSV(arr, columns) { + var delimiter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ','; + return [columns.join(delimiter)].concat(_toConsumableArray(arr.map(function (obj) { + return columns.reduce(function (acc, key) { + return "".concat(acc).concat(!acc.length ? '' : delimiter, "\"").concat(!obj[key] ? '' : obj[key], "\""); + }, ''); + }))).join('\n'); + }; + + var RGBToHex = function RGBToHex(r, g, b) { + return ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); + }; + + var URLJoin = function URLJoin() { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return args.join('/').replace(/[\/]+/g, '/').replace(/^(.+):\//, '$1://').replace(/^file:/, 'file:/').replace(/\/(\?|&|#[^!])/g, '$1').replace(/\?/g, '&').replace('&', '?'); + }; + + var UUIDGeneratorBrowser = function UUIDGeneratorBrowser() { + return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) { + return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16); + }); + }; + + var UUIDGeneratorNode = function UUIDGeneratorNode() { + return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) { + return (c ^ crypto.randomBytes(1)[0] & 15 >> c / 4).toString(16); + }); + }; var all = function all(arr) { var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Boolean; @@ -158,8 +214,8 @@ var ary = function ary(fn, n) { return function () { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } return fn.apply(void 0, _toConsumableArray(args.slice(0, n))); @@ -172,8 +228,8 @@ var attempt = function attempt(fn) { try { - for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - args[_key2 - 1] = arguments[_key2]; + for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { + args[_key3 - 1] = arguments[_key3]; } return fn.apply(void 0, args); @@ -183,8 +239,8 @@ }; var average = function average() { - for (var _len3 = arguments.length, nums = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - nums[_key3] = arguments[_key3]; + for (var _len4 = arguments.length, nums = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + nums[_key4] = arguments[_key4]; } return nums.reduce(function (acc, val) { @@ -213,13 +269,13 @@ }; var bind = function bind(fn, context) { - for (var _len4 = arguments.length, boundArgs = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) { - boundArgs[_key4 - 2] = arguments[_key4]; + for (var _len5 = arguments.length, boundArgs = new Array(_len5 > 2 ? _len5 - 2 : 0), _key5 = 2; _key5 < _len5; _key5++) { + boundArgs[_key5 - 2] = arguments[_key5]; } return function () { - for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { - args[_key5] = arguments[_key5]; + for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { + args[_key6] = arguments[_key6]; } return fn.apply(context, boundArgs.concat(args)); @@ -227,8 +283,8 @@ }; var bindAll = function bindAll(obj) { - for (var _len6 = arguments.length, fns = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) { - fns[_key6 - 1] = arguments[_key6]; + for (var _len7 = arguments.length, fns = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) { + fns[_key7 - 1] = arguments[_key7]; } return fns.forEach(function (fn) { @@ -239,13 +295,13 @@ }; var bindKey = function bindKey(context, fn) { - for (var _len7 = arguments.length, boundArgs = new Array(_len7 > 2 ? _len7 - 2 : 0), _key7 = 2; _key7 < _len7; _key7++) { - boundArgs[_key7 - 2] = arguments[_key7]; + for (var _len8 = arguments.length, boundArgs = new Array(_len8 > 2 ? _len8 - 2 : 0), _key8 = 2; _key8 < _len8; _key8++) { + boundArgs[_key8 - 2] = arguments[_key8]; } return function () { - for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { - args[_key8] = arguments[_key8]; + for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { + args[_key9] = arguments[_key9]; } return context[fn].apply(context, boundArgs.concat(args)); @@ -280,8 +336,8 @@ }; var call = function call(key) { - for (var _len9 = arguments.length, args = new Array(_len9 > 1 ? _len9 - 1 : 0), _key9 = 1; _key9 < _len9; _key9++) { - args[_key9 - 1] = arguments[_key9]; + for (var _len10 = arguments.length, args = new Array(_len10 > 1 ? _len10 - 1 : 0), _key10 = 1; _key10 < _len10; _key10++) { + args[_key10 - 1] = arguments[_key10]; } return function (context) { @@ -335,8 +391,8 @@ }; var coalesce = function coalesce() { - for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) { - args[_key10] = arguments[_key10]; + for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) { + args[_key11] = arguments[_key11]; } return args.find(function (_) { @@ -346,8 +402,8 @@ var coalesceFactory = function coalesceFactory(valid) { return function () { - for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) { - args[_key11] = arguments[_key11]; + for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) { + args[_key12] = arguments[_key12]; } return args.find(valid); @@ -356,8 +412,8 @@ var collectInto = function collectInto(fn) { return function () { - for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) { - args[_key12] = arguments[_key12]; + for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) { + args[_key13] = arguments[_key13]; } return fn(args); @@ -365,8 +421,8 @@ }; var colorize = function colorize() { - for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) { - args[_key13] = arguments[_key13]; + for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) { + args[_key14] = arguments[_key14]; } return { @@ -394,8 +450,8 @@ }; var compose = function compose() { - for (var _len14 = arguments.length, fns = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) { - fns[_key14] = arguments[_key14]; + for (var _len15 = arguments.length, fns = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) { + fns[_key15] = arguments[_key15]; } return fns.reduce(function (f, g) { @@ -406,8 +462,8 @@ }; var composeRight = function composeRight() { - for (var _len15 = arguments.length, fns = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) { - fns[_key15] = arguments[_key15]; + for (var _len16 = arguments.length, fns = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) { + fns[_key16] = arguments[_key16]; } return fns.reduce(function (f, g) { @@ -419,8 +475,8 @@ var converge = function converge(converger, fns) { return function () { - for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) { - args[_key16] = arguments[_key16]; + for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) { + args[_key17] = arguments[_key17]; } return converger.apply(void 0, _toConsumableArray(fns.map(function (fn) { @@ -456,6 +512,12 @@ }, {}); }; + var countOccurrences = function countOccurrences(arr, val) { + return arr.reduce(function (a, v) { + return v === val ? a + 1 : a; + }, 0); + }; + var counter = function counter(selector, start, end) { var step = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; var duration = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 2000; @@ -472,12 +534,6 @@ return timer; }; - var countOccurrences = function countOccurrences(arr, val) { - return arr.reduce(function (a, v) { - return v === val ? a + 1 : a; - }, 0); - }; - var createElement = function createElement(str) { var el = document.createElement('div'); el.innerHTML = str; @@ -505,25 +561,6 @@ }; }; - var CSVToArray = function CSVToArray(data) { - var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ','; - var omitFirstRow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - return data.slice(omitFirstRow ? data.indexOf('\n') + 1 : 0).split('\n').map(function (v) { - return v.split(delimiter); - }); - }; - - var CSVToJSON = function CSVToJSON(data) { - var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ','; - var titles = data.slice(0, data.indexOf('\n')).split(delimiter); - return data.slice(data.indexOf('\n') + 1).split('\n').map(function (v) { - var values = v.split(delimiter); - return titles.reduce(function (obj, title, index) { - return obj[title] = values[index], obj; - }, {}); - }); - }; - var currentURL = function currentURL() { return window.location.href; }; @@ -531,8 +568,8 @@ var curry = function curry(fn) { var arity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : fn.length; - for (var _len17 = arguments.length, args = new Array(_len17 > 2 ? _len17 - 2 : 0), _key17 = 2; _key17 < _len17; _key17++) { - args[_key17 - 2] = arguments[_key17]; + for (var _len18 = arguments.length, args = new Array(_len18 > 2 ? _len18 - 2 : 0), _key18 = 2; _key18 < _len18; _key18++) { + args[_key18 - 2] = arguments[_key18]; } return arity <= args.length ? fn.apply(void 0, args) : curry.bind.apply(curry, [null, fn, arity].concat(args)); @@ -548,8 +585,8 @@ return function () { var _this = this; - for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) { - args[_key18] = arguments[_key18]; + for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) { + args[_key19] = arguments[_key19]; } clearTimeout(timeoutId); @@ -591,16 +628,16 @@ }; var defaults = function defaults(obj) { - for (var _len19 = arguments.length, defs = new Array(_len19 > 1 ? _len19 - 1 : 0), _key19 = 1; _key19 < _len19; _key19++) { - defs[_key19 - 1] = arguments[_key19]; + for (var _len20 = arguments.length, defs = new Array(_len20 > 1 ? _len20 - 1 : 0), _key20 = 1; _key20 < _len20; _key20++) { + defs[_key20 - 1] = arguments[_key20]; } return Object.assign.apply(Object, [{}, obj].concat(_toConsumableArray(defs.reverse()), [obj])); }; var defer = function defer(fn) { - for (var _len20 = arguments.length, args = new Array(_len20 > 1 ? _len20 - 1 : 0), _key20 = 1; _key20 < _len20; _key20++) { - args[_key20 - 1] = arguments[_key20]; + for (var _len21 = arguments.length, args = new Array(_len21 > 1 ? _len21 - 1 : 0), _key21 = 1; _key21 < _len21; _key21++) { + args[_key21 - 1] = arguments[_key21]; } return setTimeout.apply(void 0, [fn, 1].concat(args)); @@ -611,8 +648,8 @@ }; var delay = function delay(fn, wait) { - for (var _len21 = arguments.length, args = new Array(_len21 > 2 ? _len21 - 2 : 0), _key21 = 2; _key21 < _len21; _key21++) { - args[_key21 - 2] = arguments[_key21]; + for (var _len22 = arguments.length, args = new Array(_len22 > 2 ? _len22 - 2 : 0), _key22 = 2; _key22 < _len22; _key22++) { + args[_key22 - 2] = arguments[_key22]; } return setTimeout.apply(void 0, [fn, wait].concat(args)); @@ -860,8 +897,8 @@ var flip = function flip(fn) { return function (first) { - for (var _len22 = arguments.length, rest = new Array(_len22 > 1 ? _len22 - 1 : 0), _key22 = 1; _key22 < _len22; _key22++) { - rest[_key22 - 1] = arguments[_key22]; + for (var _len23 = arguments.length, rest = new Array(_len23 > 1 ? _len23 - 1 : 0), _key23 = 1; _key23 < _len23; _key23++) { + rest[_key23 - 1] = arguments[_key23]; } return fn.apply(void 0, rest.concat([first])); @@ -872,6 +909,18 @@ return arr.slice(0).reverse().forEach(callback); }; + var forOwn = function forOwn(obj, fn) { + return Object.keys(obj).forEach(function (key) { + return fn(obj[key], key, obj); + }); + }; + + var forOwnRight = function forOwnRight(obj, fn) { + return Object.keys(obj).reverse().forEach(function (key) { + return fn(obj[key], key, obj); + }); + }; + var formatDuration = function formatDuration(ms) { if (ms < 0) ms = -ms; var time = { @@ -892,18 +941,6 @@ }).join(', '); }; - var forOwn = function forOwn(obj, fn) { - return Object.keys(obj).forEach(function (key) { - return fn(obj[key], key, obj); - }); - }; - - var forOwnRight = function forOwnRight(obj, fn) { - return Object.keys(obj).reverse().forEach(function (key) { - return fn(obj[key], key, obj); - }); - }; - var fromCamelCase = function fromCamelCase(str) { var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '_'; return str.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2').replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2').toLowerCase(); @@ -925,8 +962,8 @@ return !y ? x : gcd(y, x % y); }; - for (var _len23 = arguments.length, arr = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) { - arr[_key23] = arguments[_key23]; + for (var _len24 = arguments.length, arr = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) { + arr[_key24] = arguments[_key24]; } return arr.concat().reduce(function (a, b) { @@ -945,8 +982,8 @@ }; var get = function get(from) { - for (var _len24 = arguments.length, selectors = new Array(_len24 > 1 ? _len24 - 1 : 0), _key24 = 1; _key24 < _len24; _key24++) { - selectors[_key24 - 1] = arguments[_key24]; + for (var _len25 = arguments.length, selectors = new Array(_len25 > 1 ? _len25 - 1 : 0), _key25 = 1; _key25 < _len25; _key25++) { + selectors[_key25 - 1] = arguments[_key25]; } return selectors.concat().map(function (s) { @@ -1020,8 +1057,8 @@ }; var hasFlags = function hasFlags() { - for (var _len25 = arguments.length, flags = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) { - flags[_key25] = arguments[_key25]; + for (var _len26 = arguments.length, flags = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) { + flags[_key26] = arguments[_key26]; } return flags.every(function (flag) { @@ -1065,8 +1102,8 @@ }; var hide = function hide() { - for (var _len26 = arguments.length, el = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) { - el[_key26] = arguments[_key26]; + for (var _len27 = arguments.length, el = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) { + el[_key27] = arguments[_key27]; } return el.concat().forEach(function (e) { @@ -1122,6 +1159,18 @@ return 1000 * iterations / (performance.now() - before); }; + var inRange = function inRange(n, start) { + var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + + if (end && start > end) { + var _ref12 = [start, end]; + end = _ref12[0]; + start = _ref12[1]; + } + + return end == null ? n >= 0 && n < start : n >= start && n < end; + }; + var indentString = function indentString(str, count) { var indent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ' '; return str.replace(/^/gm, indent.repeat(count)); @@ -1174,8 +1223,8 @@ }; var initializeNDArray = function initializeNDArray(val) { - for (var _len27 = arguments.length, args = new Array(_len27 > 1 ? _len27 - 1 : 0), _key27 = 1; _key27 < _len27; _key27++) { - args[_key27 - 1] = arguments[_key27]; + for (var _len28 = arguments.length, args = new Array(_len28 > 1 ? _len28 - 1 : 0), _key28 = 1; _key28 < _len28; _key28++) { + args[_key28 - 1] = arguments[_key28]; } return args.length === 0 ? val : Array.from({ @@ -1185,18 +1234,6 @@ }); }; - var inRange = function inRange(n, start) { - var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - - if (end && start > end) { - var _ref12 = [start, end]; - end = _ref12[0]; - start = _ref12[1]; - } - - return end == null ? n >= 0 && n < start : n >= start && n < end; - }; - var insertAfter = function insertAfter(el, htmlString) { return el.insertAdjacentHTML('afterend', htmlString); }; @@ -1426,19 +1463,6 @@ }, ''); }; - var JSONtoCSV = function JSONtoCSV(arr, columns) { - var delimiter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ','; - return [columns.join(delimiter)].concat(_toConsumableArray(arr.map(function (obj) { - return columns.reduce(function (acc, key) { - return "".concat(acc).concat(!acc.length ? '' : delimiter, "\"").concat(!obj[key] ? '' : obj[key], "\""); - }, ''); - }))).join('\n'); - }; - - var JSONToFile = function JSONToFile(obj, filename) { - return fs.writeFile("".concat(filename, ".json"), JSON.stringify(obj, null, 2)); - }; - var last = function last(arr) { return arr[arr.length - 1]; }; @@ -1452,8 +1476,8 @@ return x * y / gcd(x, y); }; - for (var _len28 = arguments.length, arr = new Array(_len28), _key28 = 0; _key28 < _len28; _key28++) { - arr[_key28] = arguments[_key28]; + for (var _len29 = arguments.length, arr = new Array(_len29), _key29 = 0; _key29 < _len29; _key29++) { + arr[_key29] = arguments[_key29]; } return arr.concat().reduce(function (a, b) { @@ -1462,8 +1486,8 @@ }; var longestItem = function longestItem() { - for (var _len29 = arguments.length, vals = new Array(_len29), _key29 = 0; _key29 < _len29; _key29++) { - vals[_key29] = arguments[_key29]; + for (var _len30 = arguments.length, vals = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) { + vals[_key30] = arguments[_key30]; } return vals.reduce(function (a, x) { @@ -1545,8 +1569,8 @@ var maxDate = function maxDate() { var _Math$max; - for (var _len30 = arguments.length, dates = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) { - dates[_key30] = arguments[_key30]; + for (var _len31 = arguments.length, dates = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) { + dates[_key31] = arguments[_key31]; } return new Date((_Math$max = Math.max).apply.apply(_Math$max, [null].concat(dates))); @@ -1580,8 +1604,8 @@ }; var merge = function merge() { - for (var _len31 = arguments.length, objs = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) { - objs[_key31] = arguments[_key31]; + for (var _len32 = arguments.length, objs = new Array(_len32), _key32 = 0; _key32 < _len32; _key32++) { + objs[_key32] = arguments[_key32]; } return objs.concat().reduce(function (acc, obj) { @@ -1601,8 +1625,8 @@ var minDate = function minDate() { var _Math$min; - for (var _len32 = arguments.length, dates = new Array(_len32), _key32 = 0; _key32 < _len32; _key32++) { - dates[_key32] = arguments[_key32]; + for (var _len33 = arguments.length, dates = new Array(_len33), _key33 = 0; _key33 < _len33; _key33++) { + dates[_key33] = arguments[_key33]; } return new Date((_Math$min = Math.min).apply.apply(_Math$min, [null].concat(dates))); @@ -1658,8 +1682,8 @@ var nthArg = function nthArg(n) { return function () { - for (var _len33 = arguments.length, args = new Array(_len33), _key33 = 0; _key33 < _len33; _key33++) { - args[_key33] = arguments[_key33]; + for (var _len34 = arguments.length, args = new Array(_len34), _key34 = 0; _key34 < _len34; _key34++) { + args[_key34] = arguments[_key34]; } return args.slice(n)[0]; @@ -1740,20 +1764,6 @@ if (opts.target) return delegatorFn; }; - var once = function once(fn) { - var called = false; - return function () { - if (called) return; - called = true; - - for (var _len34 = arguments.length, args = new Array(_len34), _key34 = 0; _key34 < _len34; _key34++) { - args[_key34] = arguments[_key34]; - } - - return fn.apply(this, args); - }; - }; - var onUserInputChange = function onUserInputChange(callback) { var type = 'mouse', lastTime = 0; @@ -1770,6 +1780,20 @@ }); }; + var once = function once(fn) { + var called = false; + return function () { + if (called) return; + called = true; + + for (var _len35 = arguments.length, args = new Array(_len35), _key35 = 0; _key35 < _len35; _key35++) { + args[_key35] = arguments[_key35]; + } + + return fn.apply(this, args); + }; + }; + var orderBy = function orderBy(arr, props, orders) { return _toConsumableArray(arr).sort(function (a, b) { return props.reduce(function (acc, prop, i) { @@ -1788,13 +1812,13 @@ }; var over = function over() { - for (var _len35 = arguments.length, fns = new Array(_len35), _key35 = 0; _key35 < _len35; _key35++) { - fns[_key35] = arguments[_key35]; + for (var _len36 = arguments.length, fns = new Array(_len36), _key36 = 0; _key36 < _len36; _key36++) { + fns[_key36] = arguments[_key36]; } return function () { - for (var _len36 = arguments.length, args = new Array(_len36), _key36 = 0; _key36 < _len36; _key36++) { - args[_key36] = arguments[_key36]; + for (var _len37 = arguments.length, args = new Array(_len37), _key37 = 0; _key37 < _len37; _key37++) { + args[_key37] = arguments[_key37]; } return fns.map(function (fn) { @@ -1805,8 +1829,8 @@ var overArgs = function overArgs(fn, transforms) { return function () { - for (var _len37 = arguments.length, args = new Array(_len37), _key37 = 0; _key37 < _len37; _key37++) { - args[_key37] = arguments[_key37]; + for (var _len38 = arguments.length, args = new Array(_len38), _key38 = 0; _key38 < _len38; _key38++) { + args[_key38] = arguments[_key38]; } return fn.apply(void 0, _toConsumableArray(args.map(function (val, i) { @@ -1835,13 +1859,13 @@ }; var partial = function partial(fn) { - for (var _len38 = arguments.length, partials = new Array(_len38 > 1 ? _len38 - 1 : 0), _key38 = 1; _key38 < _len38; _key38++) { - partials[_key38 - 1] = arguments[_key38]; + for (var _len39 = arguments.length, partials = new Array(_len39 > 1 ? _len39 - 1 : 0), _key39 = 1; _key39 < _len39; _key39++) { + partials[_key39 - 1] = arguments[_key39]; } return function () { - for (var _len39 = arguments.length, args = new Array(_len39), _key39 = 0; _key39 < _len39; _key39++) { - args[_key39] = arguments[_key39]; + for (var _len40 = arguments.length, args = new Array(_len40), _key40 = 0; _key40 < _len40; _key40++) { + args[_key40] = arguments[_key40]; } return fn.apply(void 0, partials.concat(args)); @@ -1849,13 +1873,13 @@ }; var partialRight = function partialRight(fn) { - for (var _len40 = arguments.length, partials = new Array(_len40 > 1 ? _len40 - 1 : 0), _key40 = 1; _key40 < _len40; _key40++) { - partials[_key40 - 1] = arguments[_key40]; + for (var _len41 = arguments.length, partials = new Array(_len41 > 1 ? _len41 - 1 : 0), _key41 = 1; _key41 < _len41; _key41++) { + partials[_key41 - 1] = arguments[_key41]; } return function () { - for (var _len41 = arguments.length, args = new Array(_len41), _key41 = 0; _key41 < _len41; _key41++) { - args[_key41] = arguments[_key41]; + for (var _len42 = arguments.length, args = new Array(_len42), _key42 = 0; _key42 < _len42; _key42++) { + args[_key42] = arguments[_key42]; } return fn.apply(void 0, args.concat(partials)); @@ -1899,8 +1923,8 @@ }; var pipeAsyncFunctions = function pipeAsyncFunctions() { - for (var _len42 = arguments.length, fns = new Array(_len42), _key42 = 0; _key42 < _len42; _key42++) { - fns[_key42] = arguments[_key42]; + for (var _len43 = arguments.length, fns = new Array(_len43), _key43 = 0; _key43 < _len43; _key43++) { + fns[_key43] = arguments[_key43]; } return function (arg) { @@ -1911,8 +1935,8 @@ }; var pipeFunctions = function pipeFunctions() { - for (var _len43 = arguments.length, fns = new Array(_len43), _key43 = 0; _key43 < _len43; _key43++) { - fns[_key43] = arguments[_key43]; + for (var _len44 = arguments.length, fns = new Array(_len44), _key44 = 0; _key44 < _len44; _key44++) { + fns[_key44] = arguments[_key44]; } return fns.reduce(function (f, g) { @@ -1985,8 +2009,8 @@ var promisify = function promisify(func) { return function () { - for (var _len44 = arguments.length, args = new Array(_len44), _key44 = 0; _key44 < _len44; _key44++) { - args[_key44] = arguments[_key44]; + for (var _len45 = arguments.length, args = new Array(_len45), _key45 = 0; _key45 < _len45; _key45++) { + args[_key45] = arguments[_key45]; } return new Promise(function (resolve, reject) { @@ -1998,8 +2022,8 @@ }; var pull = function pull(arr) { - for (var _len45 = arguments.length, args = new Array(_len45 > 1 ? _len45 - 1 : 0), _key45 = 1; _key45 < _len45; _key45++) { - args[_key45 - 1] = arguments[_key45]; + for (var _len46 = arguments.length, args = new Array(_len46 > 1 ? _len46 - 1 : 0), _key46 = 1; _key46 < _len46; _key46++) { + args[_key46 - 1] = arguments[_key46]; } var argState = Array.isArray(args[0]) ? args[0] : args; @@ -2042,8 +2066,8 @@ }; var pullBy = function pullBy(arr) { - for (var _len46 = arguments.length, args = new Array(_len46 > 1 ? _len46 - 1 : 0), _key46 = 1; _key46 < _len46; _key46++) { - args[_key46 - 1] = arguments[_key46]; + for (var _len47 = arguments.length, args = new Array(_len47 > 1 ? _len47 - 1 : 0), _key47 = 1; _key47 < _len47; _key47++) { + args[_key47 - 1] = arguments[_key47]; } var length = args.length; @@ -2093,8 +2117,8 @@ var rearg = function rearg(fn, indexes) { return function () { - for (var _len47 = arguments.length, args = new Array(_len47), _key47 = 0; _key47 < _len47; _key47++) { - args[_key47] = arguments[_key47]; + for (var _len48 = arguments.length, args = new Array(_len48), _key48 = 0; _key48 < _len48; _key48++) { + args[_key48] = arguments[_key48]; } return fn.apply(void 0, _toConsumableArray(indexes.map(function (i) { @@ -2137,15 +2161,6 @@ return asLink ? window.location.href = url : window.location.replace(url); }; - var reducedFilter = function reducedFilter(data, keys, fn) { - return data.filter(fn).map(function (el) { - return keys.reduce(function (acc, key) { - acc[key] = el[key]; - return acc; - }, {}); - }); - }; - var reduceSuccessive = function reduceSuccessive(arr, fn, acc) { return arr.reduce(function (res, val, i, arr) { return res.push(fn(res.slice(-1)[0], val, i, arr)), res; @@ -2161,6 +2176,15 @@ }); }; + var reducedFilter = function reducedFilter(data, keys, fn) { + return data.filter(fn).map(function (el) { + return keys.reduce(function (acc, key) { + acc[key] = el[key]; + return acc; + }, {}); + }); + }; + var reject = function reject(pred, array) { return array.filter(function () { return !pred.apply(void 0, arguments); @@ -2188,10 +2212,6 @@ return _toConsumableArray(str).reverse().join(''); }; - var RGBToHex = function RGBToHex(r, g, b) { - return ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); - }; - var round = function round(n) { var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; return Number("".concat(Math.round("".concat(n, "e").concat(decimals)), "e-").concat(decimals)); @@ -2272,16 +2292,16 @@ var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var delCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - for (var _len48 = arguments.length, elements = new Array(_len48 > 3 ? _len48 - 3 : 0), _key48 = 3; _key48 < _len48; _key48++) { - elements[_key48 - 3] = arguments[_key48]; + for (var _len49 = arguments.length, elements = new Array(_len49 > 3 ? _len49 - 3 : 0), _key49 = 3; _key49 < _len49; _key49++) { + elements[_key49 - 3] = arguments[_key49]; } return arr.slice(0, index).concat(elements).concat(arr.slice(index + delCount)); }; var show = function show() { - for (var _len49 = arguments.length, el = new Array(_len49), _key49 = 0; _key49 < _len49; _key49++) { - el[_key49] = arguments[_key49]; + for (var _len50 = arguments.length, el = new Array(_len50), _key50 = 0; _key50 < _len50; _key50++) { + el[_key50] = arguments[_key50]; } return el.concat().forEach(function (e) { @@ -2417,8 +2437,8 @@ }; var sum = function sum() { - for (var _len50 = arguments.length, arr = new Array(_len50), _key50 = 0; _key50 < _len50; _key50++) { - arr[_key50] = arguments[_key50]; + for (var _len51 = arguments.length, arr = new Array(_len51), _key51 = 0; _key51 < _len51; _key51++) { + arr[_key51] = arguments[_key51]; } return arr.concat().reduce(function (acc, val) { @@ -2553,13 +2573,6 @@ }; }; - var times = function times(n, fn) { - var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; - var i = 0; - - while (fn.call(context, i) !== false && ++i < n) {} - }; - var timeTaken = function timeTaken(callback) { console.time('timeTaken'); var r = callback(); @@ -2567,6 +2580,13 @@ return r; }; + var times = function times(n, fn) { + var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; + var i = 0; + + while (fn.call(context, i) !== false && ++i < n) {} + }; + var toCamelCase = function toCamelCase(str) { var s = str && str.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map(function (x) { return x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase(); @@ -2586,10 +2606,6 @@ return num.toLocaleString('en-US'); }; - var toggleClass = function toggleClass(el, className) { - return el.classList.toggle(className); - }; - var toHash = function toHash(object, key) { return Array.prototype.reduce.call(object, function (acc, data, index) { return acc[!key ? index : data[key]] = data, acc; @@ -2602,14 +2618,6 @@ }).join('-'); }; - var tomorrow = function tomorrow() { - var long = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - var t = new Date(); - t.setDate(t.getDate() + 1); - var ret = "".concat(t.getFullYear(), "-").concat(String(t.getMonth() + 1).padStart(2, '0'), "-").concat(String(t.getDate()).padStart(2, '0')); - return !long ? ret : "".concat(ret, "T00:00:00"); - }; - var toOrdinalSuffix = function toOrdinalSuffix(num) { var int = parseInt(num), digits = [int % 10, int % 100], @@ -2635,6 +2643,18 @@ }).join(' '); }; + var toggleClass = function toggleClass(el, className) { + return el.classList.toggle(className); + }; + + var tomorrow = function tomorrow() { + var long = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var t = new Date(); + t.setDate(t.getDate() + 1); + var ret = "".concat(t.getFullYear(), "-").concat(String(t.getMonth() + 1).padStart(2, '0'), "-").concat(String(t.getDate()).padStart(2, '0')); + return !long ? ret : "".concat(ret, "T00:00:00"); + }; + var transform = function transform(obj, fn, acc) { return Object.keys(obj).reduce(function (a, k) { return fn(a, obj[k], k, obj); @@ -2674,8 +2694,8 @@ }; }; - for (var _len51 = arguments.length, args = new Array(_len51), _key51 = 0; _key51 < _len51; _key51++) { - args[_key51] = arguments[_key51]; + for (var _len52 = arguments.length, args = new Array(_len52), _key52 = 0; _key52 < _len52; _key52++) { + args[_key52] = arguments[_key52]; } if (n > args.length) throw new RangeError('Arguments too few!'); @@ -2802,26 +2822,6 @@ }); }; - var URLJoin = function URLJoin() { - for (var _len52 = arguments.length, args = new Array(_len52), _key52 = 0; _key52 < _len52; _key52++) { - args[_key52] = arguments[_key52]; - } - - return args.join('/').replace(/[\/]+/g, '/').replace(/^(.+):\//, '$1://').replace(/^file:/, 'file:/').replace(/\/(\?|&|#[^!])/g, '$1').replace(/\?/g, '&').replace('&', '?'); - }; - - var UUIDGeneratorBrowser = function UUIDGeneratorBrowser() { - return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) { - return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16); - }); - }; - - var UUIDGeneratorNode = function UUIDGeneratorNode() { - return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) { - return (c ^ crypto.randomBytes(1)[0] & 15 >> c / 4).toString(16); - }); - }; - var validateNumber = function validateNumber(n) { return !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; }; @@ -2905,6 +2905,14 @@ }; module.exports = { + CSVToArray: CSVToArray, + CSVToJSON: CSVToJSON, + JSONToFile: JSONToFile, + JSONtoCSV: JSONtoCSV, + RGBToHex: RGBToHex, + URLJoin: URLJoin, + UUIDGeneratorBrowser: UUIDGeneratorBrowser, + UUIDGeneratorNode: UUIDGeneratorNode, all: all, allEqual: allEqual, any: any, @@ -2943,12 +2951,10 @@ converge: converge, copyToClipboard: copyToClipboard, countBy: countBy, - counter: counter, countOccurrences: countOccurrences, + counter: counter, createElement: createElement, createEventHub: createEventHub, - CSVToArray: CSVToArray, - CSVToJSON: CSVToJSON, currentURL: currentURL, curry: curry, dayOfYear: dayOfYear, @@ -2992,9 +2998,9 @@ flattenObject: flattenObject, flip: flip, forEachRight: forEachRight, - formatDuration: formatDuration, forOwn: forOwn, forOwnRight: forOwnRight, + formatDuration: formatDuration, fromCamelCase: fromCamelCase, functionName: functionName, functions: functions, @@ -3022,6 +3028,7 @@ httpPost: httpPost, httpsRedirect: httpsRedirect, hz: hz, + inRange: inRange, indentString: indentString, indexOfAll: indexOfAll, initial: initial, @@ -3030,7 +3037,6 @@ initializeArrayWithRangeRight: initializeArrayWithRangeRight, initializeArrayWithValues: initializeArrayWithValues, initializeNDArray: initializeNDArray, - inRange: inRange, insertAfter: insertAfter, insertBefore: insertBefore, intersection: intersection, @@ -3073,8 +3079,6 @@ isValidJSON: isValidJSON, isWritableStream: isWritableStream, join: join, - JSONtoCSV: JSONtoCSV, - JSONToFile: JSONToFile, last: last, lcm: lcm, longestItem: longestItem, @@ -3111,8 +3115,8 @@ omit: omit, omitBy: omitBy, on: on, - once: once, onUserInputChange: onUserInputChange, + once: once, orderBy: orderBy, over: over, overArgs: overArgs, @@ -3147,15 +3151,14 @@ rearg: rearg, recordAnimationFrames: recordAnimationFrames, redirect: redirect, - reducedFilter: reducedFilter, reduceSuccessive: reduceSuccessive, reduceWhich: reduceWhich, + reducedFilter: reducedFilter, reject: reject, remove: remove, removeNonASCII: removeNonASCII, renameKeys: renameKeys, reverseString: reverseString, - RGBToHex: RGBToHex, round: round, runAsync: runAsync, runPromisesInSeries: runPromisesInSeries, @@ -3196,19 +3199,19 @@ takeRightWhile: takeRightWhile, takeWhile: takeWhile, throttle: throttle, - times: times, timeTaken: timeTaken, + times: times, toCamelCase: toCamelCase, toCurrency: toCurrency, toDecimalMark: toDecimalMark, - toggleClass: toggleClass, toHash: toHash, toKebabCase: toKebabCase, - tomorrow: tomorrow, toOrdinalSuffix: toOrdinalSuffix, toSafeInteger: toSafeInteger, toSnakeCase: toSnakeCase, toTitleCase: toTitleCase, + toggleClass: toggleClass, + tomorrow: tomorrow, transform: transform, triggerEvent: triggerEvent, truncateString: truncateString, @@ -3228,9 +3231,6 @@ untildify: untildify, unzip: unzip, unzipWith: unzipWith, - URLJoin: URLJoin, - UUIDGeneratorBrowser: UUIDGeneratorBrowser, - UUIDGeneratorNode: UUIDGeneratorNode, validateNumber: validateNumber, when: when, without: without, diff --git a/dist/_30s.es5.min.js b/dist/_30s.es5.min.js index 03e8941de76..64777b3bdf5 100644 --- a/dist/_30s.es5.min.js +++ b/dist/_30s.es5.min.js @@ -1 +1 @@ -(function(e,t){'object'==typeof exports&&'undefined'!=typeof module?t():'function'==typeof define&&define.amd?define(t):t()})(this,function(){'use strict';function e(t){return e='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&'function'==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?'symbol':typeof e},e(t)}function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e){for(var n=1;n'.concat(e,'')}).join('')}()},ary:function(e,t){return function(){for(var n=arguments.length,i=Array(n),r=0;rt||t>e)return 0;if(0===t||t===e)return 1;if(1===t||t===e-1)return e;e-t=(document.documentElement.scrollHeight||document.documentElement.clientHeight)},btoa:function(e){return Buffer.from(e,'binary').toString('base64')},byteSize:function(e){return new Blob([e]).size},call:function(e){for(var t=arguments.length,n=Array(1(n-t)*i?-i:i,o=setInterval(function(){a+=l,document.querySelector(e).innerHTML=a,a>=n&&(document.querySelector(e).innerHTML=n),a>=n&&clearInterval(o)},v(y(r/(n-t))));return o},countOccurrences:function(e,t){return e.reduce(function(e,n){return n===t?e+1:e},0)},createElement:function(e){var t=document.createElement('div');return t.innerHTML=e,t.firstElementChild},createEventHub:function(){return{hub:Object.create(null),emit:function(e,t){(this.hub[e]||[]).forEach(function(e){return e(t)})},on:function(e,t){this.hub[e]||(this.hub[e]=[]),this.hub[e].push(t)},off:function(e,t){var n=(this.hub[e]||[]).findIndex(function(e){return e===t});-1'"]/g,function(e){return{"&":'&',"<":'<',">":'>',"'":''','"':'"'}[e]||e})},escapeRegExp:function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')},everyNth:function(e,t){return e.filter(function(n,e){return e%t==t-1})},extendHex:function(e){return'#'+e.slice(e.startsWith('#')?1:0).split('').map(function(e){return e+e}).join('')},factorial:function e(t){return 0>t?function(){throw new TypeError('Negative numbers are not allowed!')}():1>=t?1:t*e(t-1)},fibonacci:function(e){return Array.from({length:e}).reduce(function(e,t,n){return e.concat(1e&&(e=-e);var t={day:y(e/864e5),hour:y(e/36e5)%24,minute:y(e/6e4)%60,second:y(e/1e3)%60,millisecond:y(e)%1e3};return Object.entries(t).filter(function(e){return 0!==e[1]}).map(function(e){var t=r(e,2),n=t[0],i=t[1];return''.concat(i,' ').concat(n).concat(1===i?'':'s')}).join(', ')},forOwn:function(e,t){return Object.keys(e).forEach(function(n){return t(e[n],n,e)})},forOwnRight:function(e,t){return Object.keys(e).reverse().forEach(function(n){return t(e[n],n,e)})},fromCamelCase:function(e){var t=1e?e%12+'am':e%12+'pm'},getScrollPosition:function(){var e=0>>(t?24:16))+', '+((n&(t?16711680:65280))>>>(t?16:8))+', '+((n&(t?65280:255))>>>(t?8:0))+(t?', '.concat(255&n):'')+')'},hide:function(){for(var e=arguments.length,t=Array(e),n=0;nn){var i=[t,n];n=i[0],t=i[1]}return null==n?0<=e&&e=t&&et},isAnagram:function(e,t){var n=function(e){return e.toLowerCase().replace(/[^a-z0-9]/gi,'').split('').sort().join('')};return n(e)===n(t)},isArrayLike:function(e){return null!=e&&'function'==typeof e[Symbol.iterator]},isBeforeDate:function(e,t){return ee.length?t:e})},lowercaseKeys:function(e){return Object.keys(e).reduce(function(t,n){return t[n.toLowerCase()]=e[n],t},{})},luhnCheck:function(e){var t=(e+'').split('').reverse().map(function(e){return parseInt(e)}),n=t.splice(0,1)[0],i=t.reduce(function(e,t,n){return 0==n%2?e+2*t%9||9:e+t},0);return i+=n,0==i%10},mapKeys:function(e,t){return Object.keys(e).reduce(function(n,i){return n[t(e[i],i,e)]=e[i],n},{})},mapObject:function(e,t){return function(n){return n=[e,e.map(t)],n[0].reduce(function(e,t,i){return e[t]=n[1][i],e},{})}()},mapString:function(e,t){return e.split('').map(function(n,r){return t(n,r,e)}).join('')},mapValues:function(e,t){return Object.keys(e).reduce(function(n,i){return n[i]=t(e[i],i,e),n},{})},mask:function(e){var t=1r-n&&(t='mouse',e(t),document.removeEventListener('mousemove',i)),n=r};document.addEventListener('touchstart',function(){'touch'==t||(t='touch',e(t),document.addEventListener('mousemove',i))})},orderBy:function(e,t,n){return o(e).sort(function(e,a){return t.reduce(function(t,l,o){if(0===t){var i=n&&'desc'===n[o]?[a[l],e[l]]:[e[l],a[l]],c=r(i,2),s=c[0],d=c[1];t=s>d?1:sv(e))return e+(i?' ':'')+r[0];var a=m(y(Math.log10(0>e?-e:e)/3),r.length-1),l=+((0>e?-e:e)/g(1e3,a)).toPrecision(t);return(0>e?'-':'')+l+(i?' ':'')+r[a]},primes:function(e){var t=Array.from({length:e-1}).map(function(e,t){return t+2}),n=y(h(e)),i=Array.from({length:n-1}).map(function(e,t){return t+2});return i.forEach(function(e){return t=t.filter(function(t){return 0!=t%e||t===e})}),t},promisify:function(e){return function(){for(var t=arguments.length,n=Array(t),i=0;ie[e.length-1],i=e.findIndex(function(e){return n?t>=e:t<=e});return-1===i?e.length:i},sortedIndexBy:function(e,t,n){var i=n(e[0])>n(e[e.length-1]),r=n(t),a=e.findIndex(function(e){return i?r>=n(e):r<=n(e)});return-1===a?e.length:a},sortedLastIndex:function(e,t){var n=e[0]>e[e.length-1],i=e.reverse().findIndex(function(e){return n?t<=e:t>=e});return-1===i?0:e.length-i},sortedLastIndexBy:function(e,t,n){var i=n(e[0])>n(e[e.length-1]),r=n(t),a=e.map(n).reverse().findIndex(function(e){return i?r<=e:r>=e});return-1===a?0:e.length-a},splitLines:function(e){return e.split(/\r?\n/)},spreadOver:function(e){return function(t){return e.apply(void 0,o(t))}},stableSort:function(e,t){return e.map(function(e,t){return{item:e,index:t}}).sort(function(e,n){return t(e.item,n.item)||e.index-n.index}).map(function(e){var t=e.item;return t})},standardDeviation:function(e){var t=!!(1=t.length?2===t.length?[t,t[1]+t[0]]:[t]:t.split('').reduce(function(n,r,a){return n.concat(e(t.slice(0,a)+t.slice(a+1)).map(function(e){return r+e}))},[])},stripHTMLTags:function(e){return e.replace(/<[^>]*>/g,'')},sum:function(){for(var e=arguments.length,t=Array(e),n=0;n=t&&(e.apply(a,l),r=Date.now())},k(t-(Date.now()-r),0))):(e.apply(a,l),r=Date.now(),n=!0)}},times:function(e,t){for(var n=2t?e.slice(0,3r.length)throw new RangeError('Arguments too few!');return n(e)(r.slice(0,t))}},unescapeHTML:function(e){return e.replace(/&|<|>|'|"/g,function(e){return{"&":'&',"<":'<',">":'>',"'":'\'',""":'"'}[e]||e})},unflattenObject:function(e){return Object.keys(e).reduce(function(t,n){if(-1!==n.indexOf('.')){var r=n.split('.');Object.assign(t,JSON.parse('{'+r.map(function(e,t){return t===r.length-1?'"'.concat(e,'":'):'"'.concat(e,'":{')}).join('')+e[n]+'}'.repeat(r.length)))}else t[n]=e[n];return t},{})},unfold:function(e,t){for(var n=[],i=[null,t];i=e(i[1]);)n.push(i[0]);return n},union:function(e,t){return Array.from(new Set(o(e).concat(o(t))))},unionBy:function(e,t,n){var i=new Set(e.map(n));return Array.from(new Set(o(e).concat(o(t.filter(function(e){return!i.has(n(e))})))))},unionWith:function(e,t,n){return Array.from(new Set(o(e).concat(o(t.filter(function(t){return-1===e.findIndex(function(e){return n(t,e)})})))))},uniqueElements:function(e){return o(new Set(e))},uniqueElementsBy:function(e,t){return e.reduce(function(e,n){return e.some(function(e){return t(n,e)})||e.push(n),e},[])},uniqueElementsByRight:function(e,t){return e.reduceRight(function(e,n){return e.some(function(e){return t(n,e)})||e.push(n),e},[])},uniqueSymmetricDifference:function(e,t){return o(new Set(o(e.filter(function(e){return!t.includes(e)})).concat(o(t.filter(function(t){return!e.includes(t)})))))},untildify:function(e){return e.replace(/^~($|\/|\\)/,''.concat(require('os').homedir(),'$1'))},unzip:function(e){return e.reduce(function(e,t){return t.forEach(function(t,n){return e[n].push(t)}),e},Array.from({length:k.apply(Math,o(e.map(function(e){return e.length})))}).map(function(){return[]}))},unzipWith:function(e,t){return e.reduce(function(e,t){return t.forEach(function(t,n){return e[n].push(t)}),e},Array.from({length:k.apply(Math,o(e.map(function(e){return e.length})))}).map(function(){return[]})).map(function(e){return t.apply(void 0,o(e))})},URLJoin:function(){for(var e=arguments.length,t=Array(e),n=0;n>e/4).toString(16)})},UUIDGeneratorNode:function(){return'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,function(e){return(e^j.randomBytes(1)[0]&15>>e/4).toString(16)})},validateNumber:function(e){return!isNaN(parseFloat(e))&&isFinite(e)&&+e==e},when:function(e,t){return function(n){return e(n)?t(n):n}},without:function(e){for(var t=arguments.length,n=Array(1>e/4).toString(16)})},UUIDGeneratorNode:function(){return'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,function(e){return(e^S.randomBytes(1)[0]&15>>e/4).toString(16)})},all:function(e){var t=1'.concat(e,'')}).join('')}()},ary:function(e,t){return function(){for(var n=arguments.length,i=Array(n),r=0;rt||t>e)return 0;if(0===t||t===e)return 1;if(1===t||t===e-1)return e;e-t=(document.documentElement.scrollHeight||document.documentElement.clientHeight)},btoa:function(e){return Buffer.from(e,'binary').toString('base64')},byteSize:function(e){return new Blob([e]).size},call:function(e){for(var t=arguments.length,n=Array(1(n-t)*i?-i:i,o=setInterval(function(){a+=l,document.querySelector(e).innerHTML=a,a>=n&&(document.querySelector(e).innerHTML=n),a>=n&&clearInterval(o)},v(y(r/(n-t))));return o},createElement:function(e){var t=document.createElement('div');return t.innerHTML=e,t.firstElementChild},createEventHub:function(){return{hub:Object.create(null),emit:function(e,t){(this.hub[e]||[]).forEach(function(e){return e(t)})},on:function(e,t){this.hub[e]||(this.hub[e]=[]),this.hub[e].push(t)},off:function(e,t){var n=(this.hub[e]||[]).findIndex(function(e){return e===t});-1'"]/g,function(e){return{"&":'&',"<":'<',">":'>',"'":''','"':'"'}[e]||e})},escapeRegExp:function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')},everyNth:function(e,t){return e.filter(function(n,e){return e%t==t-1})},extendHex:function(e){return'#'+e.slice(e.startsWith('#')?1:0).split('').map(function(e){return e+e}).join('')},factorial:function e(t){return 0>t?function(){throw new TypeError('Negative numbers are not allowed!')}():1>=t?1:t*e(t-1)},fibonacci:function(e){return Array.from({length:e}).reduce(function(e,t,n){return e.concat(1e&&(e=-e);var t={day:y(e/864e5),hour:y(e/36e5)%24,minute:y(e/6e4)%60,second:y(e/1e3)%60,millisecond:y(e)%1e3};return Object.entries(t).filter(function(e){return 0!==e[1]}).map(function(e){var t=r(e,2),n=t[0],i=t[1];return''.concat(i,' ').concat(n).concat(1===i?'':'s')}).join(', ')},fromCamelCase:function(e){var t=1e?e%12+'am':e%12+'pm'},getScrollPosition:function(){var e=0>>(t?24:16))+', '+((n&(t?16711680:65280))>>>(t?16:8))+', '+((n&(t?65280:255))>>>(t?8:0))+(t?', '.concat(255&n):'')+')'},hide:function(){for(var e=arguments.length,t=Array(e),n=0;nn){var i=[t,n];n=i[0],t=i[1]}return null==n?0<=e&&e=t&&et},isAnagram:function(e,t){var n=function(e){return e.toLowerCase().replace(/[^a-z0-9]/gi,'').split('').sort().join('')};return n(e)===n(t)},isArrayLike:function(e){return null!=e&&'function'==typeof e[Symbol.iterator]},isBeforeDate:function(e,t){return ee.length?t:e})},lowercaseKeys:function(e){return Object.keys(e).reduce(function(t,n){return t[n.toLowerCase()]=e[n],t},{})},luhnCheck:function(e){var t=(e+'').split('').reverse().map(function(e){return parseInt(e)}),n=t.splice(0,1)[0],i=t.reduce(function(e,t,n){return 0==n%2?e+2*t%9||9:e+t},0);return i+=n,0==i%10},mapKeys:function(e,t){return Object.keys(e).reduce(function(n,i){return n[t(e[i],i,e)]=e[i],n},{})},mapObject:function(e,t){return function(n){return n=[e,e.map(t)],n[0].reduce(function(e,t,i){return e[t]=n[1][i],e},{})}()},mapString:function(e,t){return e.split('').map(function(n,r){return t(n,r,e)}).join('')},mapValues:function(e,t){return Object.keys(e).reduce(function(n,i){return n[i]=t(e[i],i,e),n},{})},mask:function(e){var t=1r-n&&(t='mouse',e(t),document.removeEventListener('mousemove',i)),n=r};document.addEventListener('touchstart',function(){'touch'==t||(t='touch',e(t),document.addEventListener('mousemove',i))})},once:function(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,i=Array(n),r=0;rd?1:sv(e))return e+(i?' ':'')+r[0];var a=m(y(Math.log10(0>e?-e:e)/3),r.length-1),l=+((0>e?-e:e)/g(1e3,a)).toPrecision(t);return(0>e?'-':'')+l+(i?' ':'')+r[a]},primes:function(e){var t=Array.from({length:e-1}).map(function(e,t){return t+2}),n=y(h(e)),i=Array.from({length:n-1}).map(function(e,t){return t+2});return i.forEach(function(e){return t=t.filter(function(t){return 0!=t%e||t===e})}),t},promisify:function(e){return function(){for(var t=arguments.length,n=Array(t),i=0;ie[e.length-1],i=e.findIndex(function(e){return n?t>=e:t<=e});return-1===i?e.length:i},sortedIndexBy:function(e,t,n){var i=n(e[0])>n(e[e.length-1]),r=n(t),a=e.findIndex(function(e){return i?r>=n(e):r<=n(e)});return-1===a?e.length:a},sortedLastIndex:function(e,t){var n=e[0]>e[e.length-1],i=e.reverse().findIndex(function(e){return n?t<=e:t>=e});return-1===i?0:e.length-i},sortedLastIndexBy:function(e,t,n){var i=n(e[0])>n(e[e.length-1]),r=n(t),a=e.map(n).reverse().findIndex(function(e){return i?r<=e:r>=e});return-1===a?0:e.length-a},splitLines:function(e){return e.split(/\r?\n/)},spreadOver:function(e){return function(t){return e.apply(void 0,o(t))}},stableSort:function(e,t){return e.map(function(e,t){return{item:e,index:t}}).sort(function(e,n){return t(e.item,n.item)||e.index-n.index}).map(function(e){var t=e.item;return t})},standardDeviation:function(e){var t=!!(1=t.length?2===t.length?[t,t[1]+t[0]]:[t]:t.split('').reduce(function(n,r,a){return n.concat(e(t.slice(0,a)+t.slice(a+1)).map(function(e){return r+e}))},[])},stripHTMLTags:function(e){return e.replace(/<[^>]*>/g,'')},sum:function(){for(var e=arguments.length,t=Array(e),n=0;n=t&&(e.apply(a,l),r=Date.now())},k(t-(Date.now()-r),0))):(e.apply(a,l),r=Date.now(),n=!0)}},timeTaken:function(e){console.time('timeTaken');var t=e();return console.timeEnd('timeTaken'),t},times:function(e,t){for(var n=2t?e.slice(0,3r.length)throw new RangeError('Arguments too few!');return n(e)(r.slice(0,t))}},unescapeHTML:function(e){return e.replace(/&|<|>|'|"/g,function(e){return{"&":'&',"<":'<',">":'>',"'":'\'',""":'"'}[e]||e})},unflattenObject:function(e){return Object.keys(e).reduce(function(t,n){if(-1!==n.indexOf('.')){var r=n.split('.');Object.assign(t,JSON.parse('{'+r.map(function(e,t){return t===r.length-1?'"'.concat(e,'":'):'"'.concat(e,'":{')}).join('')+e[n]+'}'.repeat(r.length)))}else t[n]=e[n];return t},{})},unfold:function(e,t){for(var n=[],i=[null,t];i=e(i[1]);)n.push(i[0]);return n},union:function(e,t){return Array.from(new Set(o(e).concat(o(t))))},unionBy:function(e,t,n){var i=new Set(e.map(n));return Array.from(new Set(o(e).concat(o(t.filter(function(e){return!i.has(n(e))})))))},unionWith:function(e,t,n){return Array.from(new Set(o(e).concat(o(t.filter(function(t){return-1===e.findIndex(function(e){return n(t,e)})})))))},uniqueElements:function(e){return o(new Set(e))},uniqueElementsBy:function(e,t){return e.reduce(function(e,n){return e.some(function(e){return t(n,e)})||e.push(n),e},[])},uniqueElementsByRight:function(e,t){return e.reduceRight(function(e,n){return e.some(function(e){return t(n,e)})||e.push(n),e},[])},uniqueSymmetricDifference:function(e,t){return o(new Set(o(e.filter(function(e){return!t.includes(e)})).concat(o(t.filter(function(t){return!e.includes(t)})))))},untildify:function(e){return e.replace(/^~($|\/|\\)/,''.concat(require('os').homedir(),'$1'))},unzip:function(e){return e.reduce(function(e,t){return t.forEach(function(t,n){return e[n].push(t)}),e},Array.from({length:k.apply(Math,o(e.map(function(e){return e.length})))}).map(function(){return[]}))},unzipWith:function(e,t){return e.reduce(function(e,t){return t.forEach(function(t,n){return e[n].push(t)}),e},Array.from({length:k.apply(Math,o(e.map(function(e){return e.length})))}).map(function(){return[]})).map(function(e){return t.apply(void 0,o(e))})},validateNumber:function(e){return!isNaN(parseFloat(e))&&isFinite(e)&&+e==e},when:function(e,t){return function(n){return e(n)?t(n):n}},without:function(e){for(var t=arguments.length,n=Array(1 + data + .slice(omitFirstRow ? data.indexOf('\n') + 1 : 0) + .split('\n') + .map(v => v.split(delimiter)); +const CSVToJSON = (data, delimiter = ',') => { + const titles = data.slice(0, data.indexOf('\n')).split(delimiter); + return data + .slice(data.indexOf('\n') + 1) + .split('\n') + .map(v => { + const values = v.split(delimiter); + return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {}); + }); +}; + +const JSONToFile = (obj, filename) => + fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2)); +const JSONtoCSV = (arr, columns, delimiter = ',') => + [ + columns.join(delimiter), + ...arr.map(obj => + columns.reduce( + (acc, key) => `${acc}${!acc.length ? '' : delimiter}"${!obj[key] ? '' : obj[key]}"`, + '' + ) + ) + ].join('\n'); +const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); +const URLJoin = (...args) => + args + .join('/') + .replace(/[\/]+/g, '/') + .replace(/^(.+):\//, '$1://') + .replace(/^file:/, 'file:/') + .replace(/\/(\?|&|#[^!])/g, '$1') + .replace(/\?/g, '&') + .replace('&', '?'); +const UUIDGeneratorBrowser = () => + ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => + (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16) + ); - const all = (arr, fn = Boolean) => arr.every(fn); - const allEqual = arr => arr.every(val => val === arr[0]); - const any = (arr, fn = Boolean) => arr.some(fn); - const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon; - const arrayToCSV = (arr, delimiter = ',') => - arr.map(v => v.map(x => `"${x}"`).join(delimiter)).join('\n'); - const arrayToHtmlList = (arr, listID) => - (el => ( - (el = document.querySelector('#' + listID)), - (el.innerHTML += arr.map(item => `
  • ${item}
  • `).join('')) - ))(); - const ary = (fn, n) => (...args) => fn(...args.slice(0, n)); - const atob = str => Buffer.from(str, 'base64').toString('binary'); - const attempt = (fn, ...args) => { - try { - return fn(...args); - } catch (e) { - return e instanceof Error ? e : new Error(e); - } -}; - const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length; - const averageBy = (arr, fn) => - arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) / - arr.length; - const bifurcate = (arr, filter) => - arr.reduce((acc, val, i) => (acc[filter[i] ? 0 : 1].push(val), acc), [[], []]); - const bifurcateBy = (arr, fn) => - arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [[], []]); - const bind = (fn, context, ...boundArgs) => (...args) => fn.apply(context, [...boundArgs, ...args]); - const bindAll = (obj, ...fns) => - fns.forEach( - fn => ( - (f = obj[fn]), - (obj[fn] = function() { - return f.apply(obj); - }) - ) - ); - const bindKey = (context, fn, ...boundArgs) => (...args) => - context[fn].apply(context, [...boundArgs, ...args]); - const binomialCoefficient = (n, k) => { - if (Number.isNaN(n) || Number.isNaN(k)) return NaN; - if (k < 0 || k > n) return 0; - if (k === 0 || k === n) return 1; - if (k === 1 || k === n - 1) return n; - if (n - k < k) k = n - k; - let res = n; - for (let j = 2; j <= k; j++) res *= (n - j + 1) / j; - return Math.round(res); -}; - const bottomVisible = () => - document.documentElement.clientHeight + window.scrollY >= - (document.documentElement.scrollHeight || document.documentElement.clientHeight); - const btoa = str => Buffer.from(str, 'binary').toString('base64'); - const byteSize = str => new Blob([str]).size; +const UUIDGeneratorNode = () => + ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => + (c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16) + ); +const all = (arr, fn = Boolean) => arr.every(fn); +const allEqual = arr => arr.every(val => val === arr[0]); +const any = (arr, fn = Boolean) => arr.some(fn); +const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon; +const arrayToCSV = (arr, delimiter = ',') => + arr.map(v => v.map(x => `"${x}"`).join(delimiter)).join('\n'); +const arrayToHtmlList = (arr, listID) => + (el => ( + (el = document.querySelector('#' + listID)), + (el.innerHTML += arr.map(item => `
  • ${item}
  • `).join('')) + ))(); +const ary = (fn, n) => (...args) => fn(...args.slice(0, n)); +const atob = str => Buffer.from(str, 'base64').toString('binary'); +const attempt = (fn, ...args) => { + try { + return fn(...args); + } catch (e) { + return e instanceof Error ? e : new Error(e); + } +}; +const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length; +const averageBy = (arr, fn) => + arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) / + arr.length; +const bifurcate = (arr, filter) => + arr.reduce((acc, val, i) => (acc[filter[i] ? 0 : 1].push(val), acc), [[], []]); +const bifurcateBy = (arr, fn) => + arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [[], []]); +const bind = (fn, context, ...boundArgs) => (...args) => fn.apply(context, [...boundArgs, ...args]); +const bindAll = (obj, ...fns) => + fns.forEach( + fn => ( + (f = obj[fn]), + (obj[fn] = function() { + return f.apply(obj); + }) + ) + ); +const bindKey = (context, fn, ...boundArgs) => (...args) => + context[fn].apply(context, [...boundArgs, ...args]); +const binomialCoefficient = (n, k) => { + if (Number.isNaN(n) || Number.isNaN(k)) return NaN; + if (k < 0 || k > n) return 0; + if (k === 0 || k === n) return 1; + if (k === 1 || k === n - 1) return n; + if (n - k < k) k = n - k; + let res = n; + for (let j = 2; j <= k; j++) res *= (n - j + 1) / j; + return Math.round(res); +}; +const bottomVisible = () => + document.documentElement.clientHeight + window.scrollY >= + (document.documentElement.scrollHeight || document.documentElement.clientHeight); +const btoa = str => Buffer.from(str, 'binary').toString('base64'); +const byteSize = str => new Blob([str]).size; const call = (key, ...args) => context => context[key](...args); - const capitalize = ([first, ...rest], lowerRest = false) => - first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join('')); - const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase()); - const castArray = val => (Array.isArray(val) ? val : [val]); - const chainAsync = fns => { - let curr = 0; - const next = () => fns[curr++](next); - next(); -}; - const chunk = (arr, size) => - Array.from({ length: Math.ceil(arr.length / size) }, (v, i) => - arr.slice(i * size, i * size + size) - ); - const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b)); - const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags); - const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_)); - const coalesceFactory = valid => (...args) => args.find(valid); +const capitalize = ([first, ...rest], lowerRest = false) => + first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join('')); +const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase()); +const castArray = val => (Array.isArray(val) ? val : [val]); +const chainAsync = fns => { + let curr = 0; + const next = () => fns[curr++](next); + next(); +}; +const chunk = (arr, size) => + Array.from({ length: Math.ceil(arr.length / size) }, (v, i) => + arr.slice(i * size, i * size + size) + ); +const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b)); +const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags); +const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_)); +const coalesceFactory = valid => (...args) => args.find(valid); const collectInto = fn => (...args) => fn(args); - const colorize = (...args) => ({ - black: `\x1b[30m${args.join(' ')}`, - red: `\x1b[31m${args.join(' ')}`, - green: `\x1b[32m${args.join(' ')}`, - yellow: `\x1b[33m${args.join(' ')}`, - blue: `\x1b[34m${args.join(' ')}`, - magenta: `\x1b[35m${args.join(' ')}`, - cyan: `\x1b[36m${args.join(' ')}`, - white: `\x1b[37m${args.join(' ')}`, - bgBlack: `\x1b[40m${args.join(' ')}\x1b[0m`, - bgRed: `\x1b[41m${args.join(' ')}\x1b[0m`, - bgGreen: `\x1b[42m${args.join(' ')}\x1b[0m`, - bgYellow: `\x1b[43m${args.join(' ')}\x1b[0m`, - bgBlue: `\x1b[44m${args.join(' ')}\x1b[0m`, - bgMagenta: `\x1b[45m${args.join(' ')}\x1b[0m`, - bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`, - bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m` -}); - const compact = arr => arr.filter(Boolean); - const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); - const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); - const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn.apply(null, args))); - const copyToClipboard = str => { - const el = document.createElement('textarea'); - el.value = str; - el.setAttribute('readonly', ''); - el.style.position = 'absolute'; - el.style.left = '-9999px'; - document.body.appendChild(el); - const selected = - document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; - el.select(); - document.execCommand('copy'); - document.body.removeChild(el); - if (selected) { - document.getSelection().removeAllRanges(); - document.getSelection().addRange(selected); - } -}; - const countBy = (arr, fn) => - arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => { - acc[val] = (acc[val] || 0) + 1; - return acc; - }, {}); - const counter = (selector, start, end, step = 1, duration = 2000) => { - let current = start, - _step = (end - start) * step < 0 ? -step : step, - timer = setInterval(() => { - current += _step; - document.querySelector(selector).innerHTML = current; - if (current >= end) document.querySelector(selector).innerHTML = end; - if (current >= end) clearInterval(timer); - }, Math.abs(Math.floor(duration / (end - start)))); - return timer; -}; - const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0); - const createElement = str => { - const el = document.createElement('div'); - el.innerHTML = str; - return el.firstElementChild; -}; - const createEventHub = () => ({ - hub: Object.create(null), - emit(event, data) { - (this.hub[event] || []).forEach(handler => handler(data)); - }, - on(event, handler) { - if (!this.hub[event]) this.hub[event] = []; - this.hub[event].push(handler); - }, - off(event, handler) { - const i = (this.hub[event] || []).findIndex(h => h === handler); - if (i > -1) this.hub[event].splice(i, 1); - } -}); - const CSVToArray = (data, delimiter = ',', omitFirstRow = false) => - data - .slice(omitFirstRow ? data.indexOf('\n') + 1 : 0) - .split('\n') - .map(v => v.split(delimiter)); - const CSVToJSON = (data, delimiter = ',') => { - const titles = data.slice(0, data.indexOf('\n')).split(delimiter); - return data - .slice(data.indexOf('\n') + 1) - .split('\n') - .map(v => { - const values = v.split(delimiter); - return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {}); - }); -}; - const currentURL = () => window.location.href; - const curry = (fn, arity = fn.length, ...args) => - arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args); - const dayOfYear = date => - Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24); - const debounce = (fn, ms = 0) => { - let timeoutId; - return function(...args) { - clearTimeout(timeoutId); - timeoutId = setTimeout(() => fn.apply(this, args), ms); - }; -}; - const decapitalize = ([first, ...rest], upperRest = false) => - first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join('')); - const deepClone = obj => { - let clone = Object.assign({}, obj); - Object.keys(clone).forEach( - key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key]) - ); - return Array.isArray(obj) ? (clone.length = obj.length) && Array.from(clone) : clone; -}; - const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v))); - const deepFreeze = obj => - Object.keys(obj).forEach( - prop => - !(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop]) - ) || Object.freeze(obj); - const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj); - const defer = (fn, ...args) => setTimeout(fn, 1, ...args); - const degreesToRads = deg => (deg * Math.PI) / 180.0; - const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args); - const detectDeviceType = () => - /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) - ? 'Mobile' - : 'Desktop'; - const difference = (a, b) => { - const s = new Set(b); - return a.filter(x => !s.has(x)); -}; - const differenceBy = (a, b, fn) => { - const s = new Set(b.map(fn)); - return a.filter(x => !s.has(fn(x))); -}; - const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1); - const dig = (obj, target) => - target in obj - ? obj[target] - : Object.values(obj).reduce((acc, val) => { - if (acc !== undefined) return acc; - if (typeof val === 'object') return dig(val, target); - }, undefined); - const digitize = n => [...`${n}`].map(i => parseInt(i)); - const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); - const drop = (arr, n = 1) => arr.slice(n); - const dropRight = (arr, n = 1) => arr.slice(0, -n); - const dropRightWhile = (arr, func) => { - while (arr.length > 0 && !func(arr[arr.length - 1])) arr = arr.slice(0, -1); - return arr; -}; - const dropWhile = (arr, func) => { - while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1); - return arr; -}; - const elementContains = (parent, child) => parent !== child && parent.contains(child); - const elementIsVisibleInViewport = (el, partiallyVisible = false) => { - const { top, left, bottom, right } = el.getBoundingClientRect(); - const { innerHeight, innerWidth } = window; - return partiallyVisible - ? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) && - ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth)) - : top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth; -}; - const elo = ([...ratings], kFactor = 32, selfRating) => { - const [a, b] = ratings; - const expectedScore = (self, opponent) => 1 / (1 + 10 ** ((opponent - self) / 400)); - const newRating = (rating, i) => - (selfRating || rating) + kFactor * (i - expectedScore(i ? a : b, i ? b : a)); - if (ratings.length === 2) return [newRating(a, 1), newRating(b, 0)]; - - for (let i = 0, len = ratings.length; i < len; i++) { - let j = i; - while (j < len - 1) { - j++; - [ratings[i], ratings[j]] = elo([ratings[i], ratings[j]], kFactor); - } - } - return ratings; -}; - const equals = (a, b) => { - if (a === b) return true; - if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime(); - if (!a || !b || (typeof a !== 'object' && typeof b !== 'object')) return a === b; - if (a === null || a === undefined || b === null || b === undefined) return false; - if (a.prototype !== b.prototype) return false; - let keys = Object.keys(a); - if (keys.length !== Object.keys(b).length) return false; - return keys.every(k => equals(a[k], b[k])); -}; - const escapeHTML = str => - str.replace( - /[&<>'"]/g, - tag => - ({ - '&': '&', - '<': '<', - '>': '>', - "'": ''', - '"': '"' - }[tag] || tag) - ); - const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); - const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1); - const extendHex = shortHex => - '#' + - shortHex - .slice(shortHex.startsWith('#') ? 1 : 0) - .split('') - .map(x => x + x) - .join(''); - const factorial = n => - n < 0 - ? (() => { - throw new TypeError('Negative numbers are not allowed!'); - })() - : n <= 1 - ? 1 - : n * factorial(n - 1); - const fibonacci = n => - Array.from({ length: n }).reduce( - (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), - [] - ); - const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i)); - const filterNonUniqueBy = (arr, fn) => - arr.filter((v, i) => arr.every((x, j) => (i === j) === fn(v, x, i, j))); - const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj)); - const findLast = (arr, fn) => arr.filter(fn).pop(); - const findLastIndex = (arr, fn) => - arr - .map((val, i) => [i, val]) - .filter(([i, val]) => fn(val, i, arr)) - .pop()[0]; - const findLastKey = (obj, fn) => - Object.keys(obj) - .reverse() - .find(key => fn(obj[key], key, obj)); - const flatten = (arr, depth = 1) => - arr.reduce((a, v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []); - const flattenObject = (obj, prefix = '') => - Object.keys(obj).reduce((acc, k) => { - const pre = prefix.length ? prefix + '.' : ''; - if (typeof obj[k] === 'object') Object.assign(acc, flattenObject(obj[k], pre + k)); - else acc[pre + k] = obj[k]; - return acc; - }, {}); +const colorize = (...args) => ({ + black: `\x1b[30m${args.join(' ')}`, + red: `\x1b[31m${args.join(' ')}`, + green: `\x1b[32m${args.join(' ')}`, + yellow: `\x1b[33m${args.join(' ')}`, + blue: `\x1b[34m${args.join(' ')}`, + magenta: `\x1b[35m${args.join(' ')}`, + cyan: `\x1b[36m${args.join(' ')}`, + white: `\x1b[37m${args.join(' ')}`, + bgBlack: `\x1b[40m${args.join(' ')}\x1b[0m`, + bgRed: `\x1b[41m${args.join(' ')}\x1b[0m`, + bgGreen: `\x1b[42m${args.join(' ')}\x1b[0m`, + bgYellow: `\x1b[43m${args.join(' ')}\x1b[0m`, + bgBlue: `\x1b[44m${args.join(' ')}\x1b[0m`, + bgMagenta: `\x1b[45m${args.join(' ')}\x1b[0m`, + bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`, + bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m` +}); +const compact = arr => arr.filter(Boolean); +const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); +const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); +const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn.apply(null, args))); +const copyToClipboard = str => { + const el = document.createElement('textarea'); + el.value = str; + el.setAttribute('readonly', ''); + el.style.position = 'absolute'; + el.style.left = '-9999px'; + document.body.appendChild(el); + const selected = + document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; + el.select(); + document.execCommand('copy'); + document.body.removeChild(el); + if (selected) { + document.getSelection().removeAllRanges(); + document.getSelection().addRange(selected); + } +}; +const countBy = (arr, fn) => + arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => { + acc[val] = (acc[val] || 0) + 1; + return acc; + }, {}); +const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0); +const counter = (selector, start, end, step = 1, duration = 2000) => { + let current = start, + _step = (end - start) * step < 0 ? -step : step, + timer = setInterval(() => { + current += _step; + document.querySelector(selector).innerHTML = current; + if (current >= end) document.querySelector(selector).innerHTML = end; + if (current >= end) clearInterval(timer); + }, Math.abs(Math.floor(duration / (end - start)))); + return timer; +}; +const createElement = str => { + const el = document.createElement('div'); + el.innerHTML = str; + return el.firstElementChild; +}; +const createEventHub = () => ({ + hub: Object.create(null), + emit(event, data) { + (this.hub[event] || []).forEach(handler => handler(data)); + }, + on(event, handler) { + if (!this.hub[event]) this.hub[event] = []; + this.hub[event].push(handler); + }, + off(event, handler) { + const i = (this.hub[event] || []).findIndex(h => h === handler); + if (i > -1) this.hub[event].splice(i, 1); + } +}); +const currentURL = () => window.location.href; +const curry = (fn, arity = fn.length, ...args) => + arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args); +const dayOfYear = date => + Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24); +const debounce = (fn, ms = 0) => { + let timeoutId; + return function(...args) { + clearTimeout(timeoutId); + timeoutId = setTimeout(() => fn.apply(this, args), ms); + }; +}; +const decapitalize = ([first, ...rest], upperRest = false) => + first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join('')); +const deepClone = obj => { + let clone = Object.assign({}, obj); + Object.keys(clone).forEach( + key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key]) + ); + return Array.isArray(obj) ? (clone.length = obj.length) && Array.from(clone) : clone; +}; +const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v))); +const deepFreeze = obj => + Object.keys(obj).forEach( + prop => + !(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop]) + ) || Object.freeze(obj); +const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj); +const defer = (fn, ...args) => setTimeout(fn, 1, ...args); +const degreesToRads = deg => (deg * Math.PI) / 180.0; +const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args); +const detectDeviceType = () => + /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) + ? 'Mobile' + : 'Desktop'; +const difference = (a, b) => { + const s = new Set(b); + return a.filter(x => !s.has(x)); +}; +const differenceBy = (a, b, fn) => { + const s = new Set(b.map(fn)); + return a.filter(x => !s.has(fn(x))); +}; +const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1); +const dig = (obj, target) => + target in obj + ? obj[target] + : Object.values(obj).reduce((acc, val) => { + if (acc !== undefined) return acc; + if (typeof val === 'object') return dig(val, target); + }, undefined); +const digitize = n => [...`${n}`].map(i => parseInt(i)); +const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); +const drop = (arr, n = 1) => arr.slice(n); +const dropRight = (arr, n = 1) => arr.slice(0, -n); +const dropRightWhile = (arr, func) => { + while (arr.length > 0 && !func(arr[arr.length - 1])) arr = arr.slice(0, -1); + return arr; +}; +const dropWhile = (arr, func) => { + while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1); + return arr; +}; +const elementContains = (parent, child) => parent !== child && parent.contains(child); +const elementIsVisibleInViewport = (el, partiallyVisible = false) => { + const { top, left, bottom, right } = el.getBoundingClientRect(); + const { innerHeight, innerWidth } = window; + return partiallyVisible + ? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) && + ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth)) + : top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth; +}; +const elo = ([...ratings], kFactor = 32, selfRating) => { + const [a, b] = ratings; + const expectedScore = (self, opponent) => 1 / (1 + 10 ** ((opponent - self) / 400)); + const newRating = (rating, i) => + (selfRating || rating) + kFactor * (i - expectedScore(i ? a : b, i ? b : a)); + if (ratings.length === 2) return [newRating(a, 1), newRating(b, 0)]; + + for (let i = 0, len = ratings.length; i < len; i++) { + let j = i; + while (j < len - 1) { + j++; + [ratings[i], ratings[j]] = elo([ratings[i], ratings[j]], kFactor); + } + } + return ratings; +}; +const equals = (a, b) => { + if (a === b) return true; + if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime(); + if (!a || !b || (typeof a !== 'object' && typeof b !== 'object')) return a === b; + if (a === null || a === undefined || b === null || b === undefined) return false; + if (a.prototype !== b.prototype) return false; + let keys = Object.keys(a); + if (keys.length !== Object.keys(b).length) return false; + return keys.every(k => equals(a[k], b[k])); +}; +const escapeHTML = str => + str.replace( + /[&<>'"]/g, + tag => + ({ + '&': '&', + '<': '<', + '>': '>', + "'": ''', + '"': '"' + }[tag] || tag) + ); +const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1); +const extendHex = shortHex => + '#' + + shortHex + .slice(shortHex.startsWith('#') ? 1 : 0) + .split('') + .map(x => x + x) + .join(''); +const factorial = n => + n < 0 + ? (() => { + throw new TypeError('Negative numbers are not allowed!'); + })() + : n <= 1 + ? 1 + : n * factorial(n - 1); +const fibonacci = n => + Array.from({ length: n }).reduce( + (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), + [] + ); +const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i)); +const filterNonUniqueBy = (arr, fn) => + arr.filter((v, i) => arr.every((x, j) => (i === j) === fn(v, x, i, j))); +const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj)); +const findLast = (arr, fn) => arr.filter(fn).pop(); +const findLastIndex = (arr, fn) => + arr + .map((val, i) => [i, val]) + .filter(([i, val]) => fn(val, i, arr)) + .pop()[0]; +const findLastKey = (obj, fn) => + Object.keys(obj) + .reverse() + .find(key => fn(obj[key], key, obj)); +const flatten = (arr, depth = 1) => + arr.reduce((a, v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []); +const flattenObject = (obj, prefix = '') => + Object.keys(obj).reduce((acc, k) => { + const pre = prefix.length ? prefix + '.' : ''; + if (typeof obj[k] === 'object') Object.assign(acc, flattenObject(obj[k], pre + k)); + else acc[pre + k] = obj[k]; + return acc; + }, {}); const flip = fn => (first, ...rest) => fn(...rest, first); - const forEachRight = (arr, callback) => - arr - .slice(0) - .reverse() - .forEach(callback); - const formatDuration = ms => { - if (ms < 0) ms = -ms; - const time = { - day: Math.floor(ms / 86400000), - hour: Math.floor(ms / 3600000) % 24, - minute: Math.floor(ms / 60000) % 60, - second: Math.floor(ms / 1000) % 60, - millisecond: Math.floor(ms) % 1000 - }; - return Object.entries(time) - .filter(val => val[1] !== 0) - .map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`) - .join(', '); -}; - const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj)); - const forOwnRight = (obj, fn) => - Object.keys(obj) - .reverse() - .forEach(key => fn(obj[key], key, obj)); - const fromCamelCase = (str, separator = '_') => - str - .replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2') - .replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2') - .toLowerCase(); - const functionName = fn => (console.debug(fn.name), fn); - const functions = (obj, inherited = false) => - (inherited - ? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))] - : Object.keys(obj) - ).filter(key => typeof obj[key] === 'function'); - const gcd = (...arr) => { - const _gcd = (x, y) => (!y ? x : gcd(y, x % y)); - return [...arr].reduce((a, b) => _gcd(a, b)); -}; - const geometricProgression = (end, start = 1, step = 2) => - Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map( - (v, i) => start * step ** i - ); - const get = (from, ...selectors) => - [...selectors].map(s => - s - .replace(/\[([^\[\]]*)\]/g, '.$1.') - .split('.') - .filter(t => t !== '') - .reduce((prev, cur) => prev && prev[cur], from) - ); - const getColonTimeFromDate = date => date.toTimeString().slice(0, 8); - const getDaysDiffBetweenDates = (dateInitial, dateFinal) => - (dateFinal - dateInitial) / (1000 * 3600 * 24); - const getImages = (el, includeDuplicates = false) => { - const images = [...el.getElementsByTagName('img')].map(img => img.getAttribute('src')); - return includeDuplicates ? images : [...new Set(images)]; -}; - const getMeridiemSuffixOfInteger = num => - num === 0 || num === 24 - ? 12 + 'am' - : num === 12 - ? 12 + 'pm' - : num < 12 - ? (num % 12) + 'am' - : (num % 12) + 'pm'; - const getScrollPosition = (el = window) => ({ - x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft, - y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop -}); - const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName]; - const getType = v => - v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase(); - const getURLParameters = url => - (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce( - (a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), - {} - ); - const groupBy = (arr, fn) => - arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => { - acc[val] = (acc[val] || []).concat(arr[i]); - return acc; - }, {}); - const hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length; - const hasClass = (el, className) => el.classList.contains(className); - const hasFlags = (...flags) => - flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag)); - const hashBrowser = val => - crypto.subtle.digest('SHA-256', new TextEncoder('utf-8').encode(val)).then(h => { - let hexes = [], - view = new DataView(h); - for (let i = 0; i < view.byteLength; i += 4) - hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8)); - return hexes.join(''); - }); - -const hashNode = val => - new Promise(resolve => - setTimeout( - () => - resolve( - crypto - .createHash('sha256') - .update(val) - .digest('hex') - ), - 0 - ) - ); - const head = arr => arr[0]; - const hexToRGB = hex => { - let alpha = false, - h = hex.slice(hex.startsWith('#') ? 1 : 0); - if (h.length === 3) h = [...h].map(x => x + x).join(''); - else if (h.length === 8) alpha = true; - h = parseInt(h, 16); - return ( - 'rgb' + - (alpha ? 'a' : '') + - '(' + - (h >>> (alpha ? 24 : 16)) + - ', ' + - ((h & (alpha ? 0x00ff0000 : 0x00ff00)) >>> (alpha ? 16 : 8)) + - ', ' + - ((h & (alpha ? 0x0000ff00 : 0x0000ff)) >>> (alpha ? 8 : 0)) + - (alpha ? `, ${h & 0x000000ff}` : '') + - ')' - ); -}; - const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); - const httpGet = (url, callback, err = console.error) => { - const request = new XMLHttpRequest(); - request.open('GET', url, true); - request.onload = () => callback(request.responseText); - request.onerror = () => err(request); - request.send(); -}; - const httpPost = (url, data, callback, err = console.error) => { - const request = new XMLHttpRequest(); - request.open('POST', url, true); - request.setRequestHeader('Content-type', 'application/json; charset=utf-8'); - request.onload = () => callback(request.responseText); - request.onerror = () => err(request); - request.send(data); -}; - const httpsRedirect = () => { - if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]); -}; - const hz = (fn, iterations = 100) => { - const before = performance.now(); - for (let i = 0; i < iterations; i++) fn(); - return (1000 * iterations) / (performance.now() - before); -}; - const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count)); - const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []); - const initial = arr => arr.slice(0, -1); - const initialize2DArray = (w, h, val = null) => - Array.from({ length: h }).map(() => Array.from({ length: w }).fill(val)); - const initializeArrayWithRange = (end, start = 0, step = 1) => - Array.from({ length: Math.ceil((end - start + 1) / step) }, (v, i) => i * step + start); - const initializeArrayWithRangeRight = (end, start = 0, step = 1) => - Array.from({ length: Math.ceil((end + 1 - start) / step) }).map( - (v, i, arr) => (arr.length - i - 1) * step + start - ); - const initializeArrayWithValues = (n, val = 0) => Array(n).fill(val); - const initializeNDArray = (val, ...args) => - args.length === 0 - ? val - : Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1))); - const inRange = (n, start, end = null) => { - if (end && start > end) [end, start] = [start, end]; - return end == null ? n >= 0 && n < start : n >= start && n < end; -}; - const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString); - const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString); - const intersection = (a, b) => { - const s = new Set(b); - return a.filter(x => s.has(x)); -}; - const intersectionBy = (a, b, fn) => { - const s = new Set(b.map(fn)); - return a.filter(x => s.has(fn(x))); -}; - const intersectionWith = (a, b, comp) => a.filter(x => b.findIndex(y => comp(x, y)) !== -1); - const invertKeyValues = (obj, fn) => - Object.keys(obj).reduce((acc, key) => { - const val = fn ? fn(obj[key]) : obj[key]; - acc[val] = acc[val] || []; - acc[val].push(key); - return acc; - }, {}); - const is = (type, val) => ![, null].includes(val) && val.constructor === type; - const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); - const isAfterDate = (dateA, dateB) => dateA > dateB; - const isAnagram = (str1, str2) => { - const normalize = str => - str - .toLowerCase() - .replace(/[^a-z0-9]/gi, '') - .split('') - .sort() - .join(''); - return normalize(str1) === normalize(str2); -}; - const isArrayLike = obj => obj != null && typeof obj[Symbol.iterator] === 'function'; - const isBeforeDate = (dateA, dateB) => dateA < dateB; - const isBoolean = val => typeof val === 'boolean'; - const isBrowser = () => ![typeof window, typeof document].includes('undefined'); - const isBrowserTabFocused = () => !document.hidden; - const isDivisible = (dividend, divisor) => dividend % divisor === 0; - const isDuplexStream = val => - val !== null && - typeof val === 'object' && - typeof val.pipe === 'function' && - typeof val._read === 'function' && - typeof val._readableState === 'object' && - typeof val._write === 'function' && - typeof val._writableState === 'object'; - const isEmpty = val => val == null || !(Object.keys(val) || val).length; - const isEven = num => num % 2 === 0; - const isFunction = val => typeof val === 'function'; - const isLowerCase = str => str === str.toLowerCase(); - const isNil = val => val === undefined || val === null; - const isNull = val => val === null; - const isNumber = val => typeof val === 'number'; - const isObject = obj => obj === Object(obj); - const isObjectLike = val => val !== null && typeof val === 'object'; - const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object; - const isPrime = num => { - const boundary = Math.floor(Math.sqrt(num)); - for (var i = 2; i <= boundary; i++) if (num % i === 0) return false; - return num >= 2; -}; - const isPrimitive = val => Object(val) !== val; - const isPromiseLike = obj => - obj !== null && - (typeof obj === 'object' || typeof obj === 'function') && - typeof obj.then === 'function'; - const isReadableStream = val => - val !== null && - typeof val === 'object' && - typeof val.pipe === 'function' && - typeof val._read === 'function' && - typeof val._readableState === 'object'; - const isSameDate = (dateA, dateB) => dateA.toISOString() === dateB.toISOString(); - const isSorted = arr => { - let direction = -(arr[0] - arr[1]); - for (let [i, val] of arr.entries()) { - direction = !direction ? -(arr[i - 1] - arr[i]) : direction; - if (i === arr.length - 1) return !direction ? 0 : direction; - else if ((val - arr[i + 1]) * direction > 0) return 0; - } -}; - const isStream = val => val !== null && typeof val === 'object' && typeof val.pipe === 'function'; - const isString = val => typeof val === 'string'; - const isSymbol = val => typeof val === 'symbol'; - const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; - const isUndefined = val => val === undefined; - const isUpperCase = str => str === str.toUpperCase(); - const isValidJSON = obj => { - try { - JSON.parse(obj); - return true; - } catch (e) { - return false; - } -}; - const isWritableStream = val => - val !== null && - typeof val === 'object' && - typeof val.pipe === 'function' && - typeof val._write === 'function' && - typeof val._writableState === 'object'; - const join = (arr, separator = ',', end = separator) => - arr.reduce( - (acc, val, i) => - i === arr.length - 2 - ? acc + val + end - : i === arr.length - 1 - ? acc + val - : acc + val + separator, - '' - ); - const JSONtoCSV = (arr, columns, delimiter = ',') => - [ - columns.join(delimiter), - ...arr.map(obj => - columns.reduce( - (acc, key) => `${acc}${!acc.length ? '' : delimiter}"${!obj[key] ? '' : obj[key]}"`, - '' - ) - ) - ].join('\n'); - -const JSONToFile = (obj, filename) => - fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2)); - const last = arr => arr[arr.length - 1]; - const lcm = (...arr) => { - const gcd = (x, y) => (!y ? x : gcd(y, x % y)); - const _lcm = (x, y) => (x * y) / gcd(x, y); - return [...arr].reduce((a, b) => _lcm(a, b)); -}; - const longestItem = (...vals) => vals.reduce((a, x) => (x.length > a.length ? x : a)); - const lowercaseKeys = obj => - Object.keys(obj).reduce((acc, key) => { - acc[key.toLowerCase()] = obj[key]; - return acc; - }, {}); - const luhnCheck = num => { - let arr = (num + '') - .split('') - .reverse() - .map(x => parseInt(x)); - let lastDigit = arr.splice(0, 1)[0]; - let sum = arr.reduce((acc, val, i) => (i % 2 !== 0 ? acc + val : acc + ((val * 2) % 9) || 9), 0); - sum += lastDigit; - return sum % 10 === 0; -}; - const mapKeys = (obj, fn) => - Object.keys(obj).reduce((acc, k) => { - acc[fn(obj[k], k, obj)] = obj[k]; - return acc; - }, {}); - const mapObject = (arr, fn) => - (a => ( - (a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {}) - ))(); - const mapString = (str, fn) => - str - .split('') - .map((c, i) => fn(c, i, str)) - .join(''); - const mapValues = (obj, fn) => - Object.keys(obj).reduce((acc, k) => { - acc[k] = fn(obj[k], k, obj); - return acc; - }, {}); - const mask = (cc, num = 4, mask = '*') => `${cc}`.slice(-num).padStart(`${cc}`.length, mask); - const matches = (obj, source) => - Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]); - const matchesWith = (obj, source, fn) => - Object.keys(source).every( - key => - obj.hasOwnProperty(key) && fn - ? fn(obj[key], source[key], key, obj, source) - : obj[key] == source[key] - ); - const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); - const maxDate = (...dates) => new Date(Math.max.apply(null, ...dates)); - const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n); - const median = arr => { - const mid = Math.floor(arr.length / 2), - nums = [...arr].sort((a, b) => a - b); - return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2; -}; - const memoize = fn => { - const cache = new Map(); - const cached = function(val) { - return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val); - }; - cached.cache = cache; - return cached; -}; - const merge = (...objs) => - [...objs].reduce( - (acc, obj) => - Object.keys(obj).reduce((a, k) => { - acc[k] = acc.hasOwnProperty(k) ? [].concat(acc[k]).concat(obj[k]) : obj[k]; - return acc; - }, {}), - {} - ); - const minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); - const minDate = (...dates) => new Date(Math.min.apply(null, ...dates)); - const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n); - const mostPerformant = (fns, iterations = 10000) => { - const times = fns.map(fn => { - const before = performance.now(); - for (let i = 0; i < iterations; i++) fn(); - return performance.now() - before; - }); - return times.indexOf(Math.min(...times)); -}; - const negate = func => (...args) => !func(...args); - const nest = (items, id = null, link = 'parent_id') => - items - .filter(item => item[link] === id) - .map(item => ({ ...item, children: nest(items, item.id) })); - const nodeListToArray = nodeList => [...nodeList]; - const none = (arr, fn = Boolean) => !arr.some(fn); - const nthArg = n => (...args) => args.slice(n)[0]; - const nthElement = (arr, n = 0) => (n === -1 ? arr.slice(n) : arr.slice(n, n + 1))[0]; - const objectFromPairs = arr => arr.reduce((a, [key, val]) => ((a[key] = val), a), {}); - const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]); - const observeMutations = (element, callback, options) => { - const observer = new MutationObserver(mutations => mutations.forEach(m => callback(m))); - observer.observe( - element, - Object.assign( - { - childList: true, - attributes: true, - attributeOldValue: true, - characterData: true, - characterDataOldValue: true, - subtree: true - }, - options - ) - ); - return observer; -}; - const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts); - const offset = (arr, offset) => [...arr.slice(offset), ...arr.slice(0, offset)]; - const omit = (obj, arr) => - Object.keys(obj) - .filter(k => !arr.includes(k)) - .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); - const omitBy = (obj, fn) => - Object.keys(obj) - .filter(k => !fn(obj[k], k)) - .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); - const on = (el, evt, fn, opts = {}) => { - const delegatorFn = e => e.target.matches(opts.target) && fn.call(e.target, e); - el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false); - if (opts.target) return delegatorFn; -}; - const once = fn => { - let called = false; - return function(...args) { - if (called) return; - called = true; - return fn.apply(this, args); - }; -}; - const onUserInputChange = callback => { - let type = 'mouse', - lastTime = 0; - const mousemoveHandler = () => { - const now = performance.now(); - if (now - lastTime < 20) - (type = 'mouse'), callback(type), document.removeEventListener('mousemove', mousemoveHandler); - lastTime = now; - }; - document.addEventListener('touchstart', () => { - if (type === 'touch') return; - (type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler); - }); -}; - const orderBy = (arr, props, orders) => - [...arr].sort((a, b) => - props.reduce((acc, prop, i) => { - if (acc === 0) { - const [p1, p2] = orders && orders[i] === 'desc' ? [b[prop], a[prop]] : [a[prop], b[prop]]; - acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0; - } - return acc; - }, 0) - ); - const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args)); - const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val))); - const pad = (str, length, char = ' ') => - str.padStart((str.length + length) / 2, char).padEnd(length, char); - const palindrome = str => { - const s = str.toLowerCase().replace(/[\W_]/g, ''); - return s === [...s].reverse().join(''); -}; - const parseCookie = str => - str - .split(';') - .map(v => v.split('=')) - .reduce((acc, v) => { - acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim()); - return acc; - }, {}); - const partial = (fn, ...partials) => (...args) => fn(...partials, ...args); - const partialRight = (fn, ...partials) => (...args) => fn(...args, ...partials); - const partition = (arr, fn) => - arr.reduce( - (acc, val, i, arr) => { - acc[fn(val, i, arr) ? 0 : 1].push(val); - return acc; - }, - [[], []] - ); - const percentile = (arr, val) => - (100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0)) / arr.length; - const permutations = arr => { - if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr; - return arr.reduce( - (acc, item, i) => - acc.concat( - permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val => [item, ...val]) - ), - [] - ); -}; - const pick = (obj, arr) => - arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {}); - const pickBy = (obj, fn) => - Object.keys(obj) - .filter(k => fn(obj[k], k)) - .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); - const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg)); - const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); - const pluralize = (val, word, plural = word + 's') => { - const _pluralize = (num, word, plural = word + 's') => - [1, -1].includes(Number(num)) ? word : plural; - if (typeof val === 'object') return (num, word) => _pluralize(num, word, val[word]); - return _pluralize(val, word, plural); -}; - const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]); - const prefix = prop => { - const capitalizedProp = prop.charAt(0).toUpperCase() + prop.slice(1); - const prefixes = ['', 'webkit', 'moz', 'ms', 'o']; - const i = prefixes.findIndex( - prefix => typeof document.body.style[prefix ? prefix + capitalizedProp : prop] !== 'undefined' - ); - return i !== -1 ? (i === 0 ? prop : prefixes[i] + capitalizedProp) : null; -}; - const prettyBytes = (num, precision = 3, addSpace = true) => { - const UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; - if (Math.abs(num) < 1) return num + (addSpace ? ' ' : '') + UNITS[0]; - const exponent = Math.min(Math.floor(Math.log10(num < 0 ? -num : num) / 3), UNITS.length - 1); - const n = Number(((num < 0 ? -num : num) / 1000 ** exponent).toPrecision(precision)); - return (num < 0 ? '-' : '') + n + (addSpace ? ' ' : '') + UNITS[exponent]; -}; - const primes = num => { - let arr = Array.from({ length: num - 1 }).map((x, i) => i + 2), - sqroot = Math.floor(Math.sqrt(num)), - numsTillSqroot = Array.from({ length: sqroot - 1 }).map((x, i) => i + 2); - numsTillSqroot.forEach(x => (arr = arr.filter(y => y % x !== 0 || y === x))); - return arr; -}; - const promisify = func => (...args) => - new Promise((resolve, reject) => - func(...args, (err, result) => (err ? reject(err) : resolve(result))) - ); - const pull = (arr, ...args) => { - let argState = Array.isArray(args[0]) ? args[0] : args; - let pulled = arr.filter((v, i) => !argState.includes(v)); - arr.length = 0; - pulled.forEach(v => arr.push(v)); -}; - const pullAtIndex = (arr, pullArr) => { - let removed = []; - let pulled = arr - .map((v, i) => (pullArr.includes(i) ? removed.push(v) : v)) - .filter((v, i) => !pullArr.includes(i)); - arr.length = 0; - pulled.forEach(v => arr.push(v)); - return removed; -}; - const pullAtValue = (arr, pullArr) => { - let removed = [], - pushToRemove = arr.forEach((v, i) => (pullArr.includes(v) ? removed.push(v) : v)), - mutateTo = arr.filter((v, i) => !pullArr.includes(v)); - arr.length = 0; - mutateTo.forEach(v => arr.push(v)); - return removed; -}; - const pullBy = (arr, ...args) => { - const length = args.length; - let fn = length > 1 ? args[length - 1] : undefined; - fn = typeof fn == 'function' ? (args.pop(), fn) : undefined; - let argState = (Array.isArray(args[0]) ? args[0] : args).map(val => fn(val)); - let pulled = arr.filter((v, i) => !argState.includes(fn(v))); - arr.length = 0; - pulled.forEach(v => arr.push(v)); -}; - const radsToDegrees = rad => (rad * 180.0) / Math.PI; - const randomHexColorCode = () => { - let n = (Math.random() * 0xfffff * 1000000).toString(16); - return '#' + n.slice(0, 6); -}; - const randomIntArrayInRange = (min, max, n = 1) => - Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min); - const randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; - const randomNumberInRange = (min, max) => Math.random() * (max - min) + min; - -const readFileLines = filename => - fs - .readFileSync(filename) - .toString('UTF8') - .split('\n'); - const rearg = (fn, indexes) => (...args) => fn(...indexes.map(i => args[i])); - const recordAnimationFrames = (callback, autoStart = true) => { - let running = true, - raf; - const stop = () => { - running = false; - cancelAnimationFrame(raf); - }; - const start = () => { - running = true; - run(); - }; - const run = () => { - raf = requestAnimationFrame(() => { - callback(); - if (running) run(); - }); - }; - if (autoStart) start(); - return { start, stop }; -}; - const redirect = (url, asLink = true) => - asLink ? (window.location.href = url) : window.location.replace(url); - const reducedFilter = (data, keys, fn) => - data.filter(fn).map(el => - keys.reduce((acc, key) => { - acc[key] = el[key]; - return acc; - }, {}) - ); - const reduceSuccessive = (arr, fn, acc) => - arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]); - const reduceWhich = (arr, comparator = (a, b) => a - b) => - arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a)); - const reject = (pred, array) => array.filter((...args) => !pred(...args)); - const remove = (arr, func) => - Array.isArray(arr) - ? arr.filter(func).reduce((acc, val) => { - arr.splice(arr.indexOf(val), 1); - return acc.concat(val); - }, []) - : []; - const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, ''); - const renameKeys = (keysMap, obj) => - Object.keys(obj).reduce( - (acc, key) => ({ - ...acc, - ...{ [keysMap[key] || key]: obj[key] } - }), - {} - ); - const reverseString = str => [...str].reverse().join(''); - const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); - const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`); - const runAsync = fn => { - const worker = new Worker( - URL.createObjectURL(new Blob([`postMessage((${fn})());`]), { - type: 'application/javascript; charset=utf-8' - }) - ); - return new Promise((res, rej) => { - worker.onmessage = ({ data }) => { - res(data), worker.terminate(); - }; - worker.onerror = err => { - rej(err), worker.terminate(); - }; - }); -}; - const runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.resolve()); - const sample = arr => arr[Math.floor(Math.random() * arr.length)]; - const sampleSize = ([...arr], n = 1) => { - let m = arr.length; - while (m) { - const i = Math.floor(Math.random() * m--); - [arr[m], arr[i]] = [arr[i], arr[m]]; - } - return arr.slice(0, n); -}; - const scrollToTop = () => { - const c = document.documentElement.scrollTop || document.body.scrollTop; - if (c > 0) { - window.requestAnimationFrame(scrollToTop); - window.scrollTo(0, c - c / 8); - } -}; - const sdbm = str => { - let arr = str.split(''); - return arr.reduce( - (hashCode, currentVal) => - (hashCode = currentVal.charCodeAt(0) + (hashCode << 6) + (hashCode << 16) - hashCode), - 0 - ); -}; - const serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`; - const setStyle = (el, ruleName, val) => (el.style[ruleName] = val); - const shallowClone = obj => Object.assign({}, obj); - const shank = (arr, index = 0, delCount = 0, ...elements) => - arr - .slice(0, index) - .concat(elements) - .concat(arr.slice(index + delCount)); - const show = (...el) => [...el].forEach(e => (e.style.display = '')); - const shuffle = ([...arr]) => { - let m = arr.length; - while (m) { - const i = Math.floor(Math.random() * m--); - [arr[m], arr[i]] = [arr[i], arr[m]]; - } - return arr; -}; - const similarity = (arr, values) => arr.filter(v => values.includes(v)); - const size = val => - Array.isArray(val) - ? val.length - : val && typeof val === 'object' - ? val.size || val.length || Object.keys(val).length - : typeof val === 'string' - ? new Blob([val]).size - : 0; - const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); - const smoothScroll = element => - document.querySelector(element).scrollIntoView({ - behavior: 'smooth' - }); - const sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join(''); - const sortedIndex = (arr, n) => { - const isDescending = arr[0] > arr[arr.length - 1]; - const index = arr.findIndex(el => (isDescending ? n >= el : n <= el)); - return index === -1 ? arr.length : index; -}; - const sortedIndexBy = (arr, n, fn) => { - const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]); - const val = fn(n); - const index = arr.findIndex(el => (isDescending ? val >= fn(el) : val <= fn(el))); - return index === -1 ? arr.length : index; -}; - const sortedLastIndex = (arr, n) => { - const isDescending = arr[0] > arr[arr.length - 1]; - const index = arr.reverse().findIndex(el => (isDescending ? n <= el : n >= el)); - return index === -1 ? 0 : arr.length - index; -}; - const sortedLastIndexBy = (arr, n, fn) => { - const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]); - const val = fn(n); - const index = arr - .map(fn) - .reverse() - .findIndex(el => (isDescending ? val <= el : val >= el)); - return index === -1 ? 0 : arr.length - index; -}; - const splitLines = str => str.split(/\r?\n/); +const forEachRight = (arr, callback) => + arr + .slice(0) + .reverse() + .forEach(callback); +const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj)); +const forOwnRight = (obj, fn) => + Object.keys(obj) + .reverse() + .forEach(key => fn(obj[key], key, obj)); +const formatDuration = ms => { + if (ms < 0) ms = -ms; + const time = { + day: Math.floor(ms / 86400000), + hour: Math.floor(ms / 3600000) % 24, + minute: Math.floor(ms / 60000) % 60, + second: Math.floor(ms / 1000) % 60, + millisecond: Math.floor(ms) % 1000 + }; + return Object.entries(time) + .filter(val => val[1] !== 0) + .map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`) + .join(', '); +}; +const fromCamelCase = (str, separator = '_') => + str + .replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2') + .replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2') + .toLowerCase(); +const functionName = fn => (console.debug(fn.name), fn); +const functions = (obj, inherited = false) => + (inherited + ? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))] + : Object.keys(obj) + ).filter(key => typeof obj[key] === 'function'); +const gcd = (...arr) => { + const _gcd = (x, y) => (!y ? x : gcd(y, x % y)); + return [...arr].reduce((a, b) => _gcd(a, b)); +}; +const geometricProgression = (end, start = 1, step = 2) => + Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map( + (v, i) => start * step ** i + ); +const get = (from, ...selectors) => + [...selectors].map(s => + s + .replace(/\[([^\[\]]*)\]/g, '.$1.') + .split('.') + .filter(t => t !== '') + .reduce((prev, cur) => prev && prev[cur], from) + ); +const getColonTimeFromDate = date => date.toTimeString().slice(0, 8); +const getDaysDiffBetweenDates = (dateInitial, dateFinal) => + (dateFinal - dateInitial) / (1000 * 3600 * 24); +const getImages = (el, includeDuplicates = false) => { + const images = [...el.getElementsByTagName('img')].map(img => img.getAttribute('src')); + return includeDuplicates ? images : [...new Set(images)]; +}; +const getMeridiemSuffixOfInteger = num => + num === 0 || num === 24 + ? 12 + 'am' + : num === 12 + ? 12 + 'pm' + : num < 12 + ? (num % 12) + 'am' + : (num % 12) + 'pm'; +const getScrollPosition = (el = window) => ({ + x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft, + y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop +}); +const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName]; +const getType = v => + v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase(); +const getURLParameters = url => + (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce( + (a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), + {} + ); +const groupBy = (arr, fn) => + arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => { + acc[val] = (acc[val] || []).concat(arr[i]); + return acc; + }, {}); +const hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length; +const hasClass = (el, className) => el.classList.contains(className); +const hasFlags = (...flags) => + flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag)); +const hashBrowser = val => + crypto.subtle.digest('SHA-256', new TextEncoder('utf-8').encode(val)).then(h => { + let hexes = [], + view = new DataView(h); + for (let i = 0; i < view.byteLength; i += 4) + hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8)); + return hexes.join(''); + }); + +const hashNode = val => + new Promise(resolve => + setTimeout( + () => + resolve( + crypto + .createHash('sha256') + .update(val) + .digest('hex') + ), + 0 + ) + ); +const head = arr => arr[0]; +const hexToRGB = hex => { + let alpha = false, + h = hex.slice(hex.startsWith('#') ? 1 : 0); + if (h.length === 3) h = [...h].map(x => x + x).join(''); + else if (h.length === 8) alpha = true; + h = parseInt(h, 16); + return ( + 'rgb' + + (alpha ? 'a' : '') + + '(' + + (h >>> (alpha ? 24 : 16)) + + ', ' + + ((h & (alpha ? 0x00ff0000 : 0x00ff00)) >>> (alpha ? 16 : 8)) + + ', ' + + ((h & (alpha ? 0x0000ff00 : 0x0000ff)) >>> (alpha ? 8 : 0)) + + (alpha ? `, ${h & 0x000000ff}` : '') + + ')' + ); +}; +const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); +const httpGet = (url, callback, err = console.error) => { + const request = new XMLHttpRequest(); + request.open('GET', url, true); + request.onload = () => callback(request.responseText); + request.onerror = () => err(request); + request.send(); +}; +const httpPost = (url, data, callback, err = console.error) => { + const request = new XMLHttpRequest(); + request.open('POST', url, true); + request.setRequestHeader('Content-type', 'application/json; charset=utf-8'); + request.onload = () => callback(request.responseText); + request.onerror = () => err(request); + request.send(data); +}; +const httpsRedirect = () => { + if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]); +}; +const hz = (fn, iterations = 100) => { + const before = performance.now(); + for (let i = 0; i < iterations; i++) fn(); + return (1000 * iterations) / (performance.now() - before); +}; +const inRange = (n, start, end = null) => { + if (end && start > end) [end, start] = [start, end]; + return end == null ? n >= 0 && n < start : n >= start && n < end; +}; +const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count)); +const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []); +const initial = arr => arr.slice(0, -1); +const initialize2DArray = (w, h, val = null) => + Array.from({ length: h }).map(() => Array.from({ length: w }).fill(val)); +const initializeArrayWithRange = (end, start = 0, step = 1) => + Array.from({ length: Math.ceil((end - start + 1) / step) }, (v, i) => i * step + start); +const initializeArrayWithRangeRight = (end, start = 0, step = 1) => + Array.from({ length: Math.ceil((end + 1 - start) / step) }).map( + (v, i, arr) => (arr.length - i - 1) * step + start + ); +const initializeArrayWithValues = (n, val = 0) => Array(n).fill(val); +const initializeNDArray = (val, ...args) => + args.length === 0 + ? val + : Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1))); +const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString); +const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString); +const intersection = (a, b) => { + const s = new Set(b); + return a.filter(x => s.has(x)); +}; +const intersectionBy = (a, b, fn) => { + const s = new Set(b.map(fn)); + return a.filter(x => s.has(fn(x))); +}; +const intersectionWith = (a, b, comp) => a.filter(x => b.findIndex(y => comp(x, y)) !== -1); +const invertKeyValues = (obj, fn) => + Object.keys(obj).reduce((acc, key) => { + const val = fn ? fn(obj[key]) : obj[key]; + acc[val] = acc[val] || []; + acc[val].push(key); + return acc; + }, {}); +const is = (type, val) => ![, null].includes(val) && val.constructor === type; +const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); +const isAfterDate = (dateA, dateB) => dateA > dateB; +const isAnagram = (str1, str2) => { + const normalize = str => + str + .toLowerCase() + .replace(/[^a-z0-9]/gi, '') + .split('') + .sort() + .join(''); + return normalize(str1) === normalize(str2); +}; +const isArrayLike = obj => obj != null && typeof obj[Symbol.iterator] === 'function'; +const isBeforeDate = (dateA, dateB) => dateA < dateB; +const isBoolean = val => typeof val === 'boolean'; +const isBrowser = () => ![typeof window, typeof document].includes('undefined'); +const isBrowserTabFocused = () => !document.hidden; +const isDivisible = (dividend, divisor) => dividend % divisor === 0; +const isDuplexStream = val => + val !== null && + typeof val === 'object' && + typeof val.pipe === 'function' && + typeof val._read === 'function' && + typeof val._readableState === 'object' && + typeof val._write === 'function' && + typeof val._writableState === 'object'; +const isEmpty = val => val == null || !(Object.keys(val) || val).length; +const isEven = num => num % 2 === 0; +const isFunction = val => typeof val === 'function'; +const isLowerCase = str => str === str.toLowerCase(); +const isNil = val => val === undefined || val === null; +const isNull = val => val === null; +const isNumber = val => typeof val === 'number'; +const isObject = obj => obj === Object(obj); +const isObjectLike = val => val !== null && typeof val === 'object'; +const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object; +const isPrime = num => { + const boundary = Math.floor(Math.sqrt(num)); + for (var i = 2; i <= boundary; i++) if (num % i === 0) return false; + return num >= 2; +}; +const isPrimitive = val => Object(val) !== val; +const isPromiseLike = obj => + obj !== null && + (typeof obj === 'object' || typeof obj === 'function') && + typeof obj.then === 'function'; +const isReadableStream = val => + val !== null && + typeof val === 'object' && + typeof val.pipe === 'function' && + typeof val._read === 'function' && + typeof val._readableState === 'object'; +const isSameDate = (dateA, dateB) => dateA.toISOString() === dateB.toISOString(); +const isSorted = arr => { + let direction = -(arr[0] - arr[1]); + for (let [i, val] of arr.entries()) { + direction = !direction ? -(arr[i - 1] - arr[i]) : direction; + if (i === arr.length - 1) return !direction ? 0 : direction; + else if ((val - arr[i + 1]) * direction > 0) return 0; + } +}; +const isStream = val => val !== null && typeof val === 'object' && typeof val.pipe === 'function'; +const isString = val => typeof val === 'string'; +const isSymbol = val => typeof val === 'symbol'; +const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; +const isUndefined = val => val === undefined; +const isUpperCase = str => str === str.toUpperCase(); +const isValidJSON = obj => { + try { + JSON.parse(obj); + return true; + } catch (e) { + return false; + } +}; +const isWritableStream = val => + val !== null && + typeof val === 'object' && + typeof val.pipe === 'function' && + typeof val._write === 'function' && + typeof val._writableState === 'object'; +const join = (arr, separator = ',', end = separator) => + arr.reduce( + (acc, val, i) => + i === arr.length - 2 + ? acc + val + end + : i === arr.length - 1 + ? acc + val + : acc + val + separator, + '' + ); +const last = arr => arr[arr.length - 1]; +const lcm = (...arr) => { + const gcd = (x, y) => (!y ? x : gcd(y, x % y)); + const _lcm = (x, y) => (x * y) / gcd(x, y); + return [...arr].reduce((a, b) => _lcm(a, b)); +}; +const longestItem = (...vals) => vals.reduce((a, x) => (x.length > a.length ? x : a)); +const lowercaseKeys = obj => + Object.keys(obj).reduce((acc, key) => { + acc[key.toLowerCase()] = obj[key]; + return acc; + }, {}); +const luhnCheck = num => { + let arr = (num + '') + .split('') + .reverse() + .map(x => parseInt(x)); + let lastDigit = arr.splice(0, 1)[0]; + let sum = arr.reduce((acc, val, i) => (i % 2 !== 0 ? acc + val : acc + ((val * 2) % 9) || 9), 0); + sum += lastDigit; + return sum % 10 === 0; +}; +const mapKeys = (obj, fn) => + Object.keys(obj).reduce((acc, k) => { + acc[fn(obj[k], k, obj)] = obj[k]; + return acc; + }, {}); +const mapObject = (arr, fn) => + (a => ( + (a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {}) + ))(); +const mapString = (str, fn) => + str + .split('') + .map((c, i) => fn(c, i, str)) + .join(''); +const mapValues = (obj, fn) => + Object.keys(obj).reduce((acc, k) => { + acc[k] = fn(obj[k], k, obj); + return acc; + }, {}); +const mask = (cc, num = 4, mask = '*') => `${cc}`.slice(-num).padStart(`${cc}`.length, mask); +const matches = (obj, source) => + Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]); +const matchesWith = (obj, source, fn) => + Object.keys(source).every( + key => + obj.hasOwnProperty(key) && fn + ? fn(obj[key], source[key], key, obj, source) + : obj[key] == source[key] + ); +const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); +const maxDate = (...dates) => new Date(Math.max.apply(null, ...dates)); +const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n); +const median = arr => { + const mid = Math.floor(arr.length / 2), + nums = [...arr].sort((a, b) => a - b); + return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2; +}; +const memoize = fn => { + const cache = new Map(); + const cached = function(val) { + return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val); + }; + cached.cache = cache; + return cached; +}; +const merge = (...objs) => + [...objs].reduce( + (acc, obj) => + Object.keys(obj).reduce((a, k) => { + acc[k] = acc.hasOwnProperty(k) ? [].concat(acc[k]).concat(obj[k]) : obj[k]; + return acc; + }, {}), + {} + ); +const minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); +const minDate = (...dates) => new Date(Math.min.apply(null, ...dates)); +const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n); +const mostPerformant = (fns, iterations = 10000) => { + const times = fns.map(fn => { + const before = performance.now(); + for (let i = 0; i < iterations; i++) fn(); + return performance.now() - before; + }); + return times.indexOf(Math.min(...times)); +}; +const negate = func => (...args) => !func(...args); +const nest = (items, id = null, link = 'parent_id') => + items + .filter(item => item[link] === id) + .map(item => ({ ...item, children: nest(items, item.id) })); +const nodeListToArray = nodeList => [...nodeList]; +const none = (arr, fn = Boolean) => !arr.some(fn); +const nthArg = n => (...args) => args.slice(n)[0]; +const nthElement = (arr, n = 0) => (n === -1 ? arr.slice(n) : arr.slice(n, n + 1))[0]; +const objectFromPairs = arr => arr.reduce((a, [key, val]) => ((a[key] = val), a), {}); +const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]); +const observeMutations = (element, callback, options) => { + const observer = new MutationObserver(mutations => mutations.forEach(m => callback(m))); + observer.observe( + element, + Object.assign( + { + childList: true, + attributes: true, + attributeOldValue: true, + characterData: true, + characterDataOldValue: true, + subtree: true + }, + options + ) + ); + return observer; +}; +const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts); +const offset = (arr, offset) => [...arr.slice(offset), ...arr.slice(0, offset)]; +const omit = (obj, arr) => + Object.keys(obj) + .filter(k => !arr.includes(k)) + .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); +const omitBy = (obj, fn) => + Object.keys(obj) + .filter(k => !fn(obj[k], k)) + .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); +const on = (el, evt, fn, opts = {}) => { + const delegatorFn = e => e.target.matches(opts.target) && fn.call(e.target, e); + el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false); + if (opts.target) return delegatorFn; +}; +const onUserInputChange = callback => { + let type = 'mouse', + lastTime = 0; + const mousemoveHandler = () => { + const now = performance.now(); + if (now - lastTime < 20) + (type = 'mouse'), callback(type), document.removeEventListener('mousemove', mousemoveHandler); + lastTime = now; + }; + document.addEventListener('touchstart', () => { + if (type === 'touch') return; + (type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler); + }); +}; +const once = fn => { + let called = false; + return function(...args) { + if (called) return; + called = true; + return fn.apply(this, args); + }; +}; +const orderBy = (arr, props, orders) => + [...arr].sort((a, b) => + props.reduce((acc, prop, i) => { + if (acc === 0) { + const [p1, p2] = orders && orders[i] === 'desc' ? [b[prop], a[prop]] : [a[prop], b[prop]]; + acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0; + } + return acc; + }, 0) + ); +const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args)); +const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val))); +const pad = (str, length, char = ' ') => + str.padStart((str.length + length) / 2, char).padEnd(length, char); +const palindrome = str => { + const s = str.toLowerCase().replace(/[\W_]/g, ''); + return s === [...s].reverse().join(''); +}; +const parseCookie = str => + str + .split(';') + .map(v => v.split('=')) + .reduce((acc, v) => { + acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim()); + return acc; + }, {}); +const partial = (fn, ...partials) => (...args) => fn(...partials, ...args); +const partialRight = (fn, ...partials) => (...args) => fn(...args, ...partials); +const partition = (arr, fn) => + arr.reduce( + (acc, val, i, arr) => { + acc[fn(val, i, arr) ? 0 : 1].push(val); + return acc; + }, + [[], []] + ); +const percentile = (arr, val) => + (100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0)) / arr.length; +const permutations = arr => { + if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr; + return arr.reduce( + (acc, item, i) => + acc.concat( + permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val => [item, ...val]) + ), + [] + ); +}; +const pick = (obj, arr) => + arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {}); +const pickBy = (obj, fn) => + Object.keys(obj) + .filter(k => fn(obj[k], k)) + .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); +const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg)); +const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); +const pluralize = (val, word, plural = word + 's') => { + const _pluralize = (num, word, plural = word + 's') => + [1, -1].includes(Number(num)) ? word : plural; + if (typeof val === 'object') return (num, word) => _pluralize(num, word, val[word]); + return _pluralize(val, word, plural); +}; +const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]); +const prefix = prop => { + const capitalizedProp = prop.charAt(0).toUpperCase() + prop.slice(1); + const prefixes = ['', 'webkit', 'moz', 'ms', 'o']; + const i = prefixes.findIndex( + prefix => typeof document.body.style[prefix ? prefix + capitalizedProp : prop] !== 'undefined' + ); + return i !== -1 ? (i === 0 ? prop : prefixes[i] + capitalizedProp) : null; +}; +const prettyBytes = (num, precision = 3, addSpace = true) => { + const UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + if (Math.abs(num) < 1) return num + (addSpace ? ' ' : '') + UNITS[0]; + const exponent = Math.min(Math.floor(Math.log10(num < 0 ? -num : num) / 3), UNITS.length - 1); + const n = Number(((num < 0 ? -num : num) / 1000 ** exponent).toPrecision(precision)); + return (num < 0 ? '-' : '') + n + (addSpace ? ' ' : '') + UNITS[exponent]; +}; +const primes = num => { + let arr = Array.from({ length: num - 1 }).map((x, i) => i + 2), + sqroot = Math.floor(Math.sqrt(num)), + numsTillSqroot = Array.from({ length: sqroot - 1 }).map((x, i) => i + 2); + numsTillSqroot.forEach(x => (arr = arr.filter(y => y % x !== 0 || y === x))); + return arr; +}; +const promisify = func => (...args) => + new Promise((resolve, reject) => + func(...args, (err, result) => (err ? reject(err) : resolve(result))) + ); +const pull = (arr, ...args) => { + let argState = Array.isArray(args[0]) ? args[0] : args; + let pulled = arr.filter((v, i) => !argState.includes(v)); + arr.length = 0; + pulled.forEach(v => arr.push(v)); +}; +const pullAtIndex = (arr, pullArr) => { + let removed = []; + let pulled = arr + .map((v, i) => (pullArr.includes(i) ? removed.push(v) : v)) + .filter((v, i) => !pullArr.includes(i)); + arr.length = 0; + pulled.forEach(v => arr.push(v)); + return removed; +}; +const pullAtValue = (arr, pullArr) => { + let removed = [], + pushToRemove = arr.forEach((v, i) => (pullArr.includes(v) ? removed.push(v) : v)), + mutateTo = arr.filter((v, i) => !pullArr.includes(v)); + arr.length = 0; + mutateTo.forEach(v => arr.push(v)); + return removed; +}; +const pullBy = (arr, ...args) => { + const length = args.length; + let fn = length > 1 ? args[length - 1] : undefined; + fn = typeof fn == 'function' ? (args.pop(), fn) : undefined; + let argState = (Array.isArray(args[0]) ? args[0] : args).map(val => fn(val)); + let pulled = arr.filter((v, i) => !argState.includes(fn(v))); + arr.length = 0; + pulled.forEach(v => arr.push(v)); +}; +const radsToDegrees = rad => (rad * 180.0) / Math.PI; +const randomHexColorCode = () => { + let n = (Math.random() * 0xfffff * 1000000).toString(16); + return '#' + n.slice(0, 6); +}; +const randomIntArrayInRange = (min, max, n = 1) => + Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min); +const randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; +const randomNumberInRange = (min, max) => Math.random() * (max - min) + min; + +const readFileLines = filename => + fs + .readFileSync(filename) + .toString('UTF8') + .split('\n'); +const rearg = (fn, indexes) => (...args) => fn(...indexes.map(i => args[i])); +const recordAnimationFrames = (callback, autoStart = true) => { + let running = true, + raf; + const stop = () => { + running = false; + cancelAnimationFrame(raf); + }; + const start = () => { + running = true; + run(); + }; + const run = () => { + raf = requestAnimationFrame(() => { + callback(); + if (running) run(); + }); + }; + if (autoStart) start(); + return { start, stop }; +}; +const redirect = (url, asLink = true) => + asLink ? (window.location.href = url) : window.location.replace(url); +const reduceSuccessive = (arr, fn, acc) => + arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]); +const reduceWhich = (arr, comparator = (a, b) => a - b) => + arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a)); +const reducedFilter = (data, keys, fn) => + data.filter(fn).map(el => + keys.reduce((acc, key) => { + acc[key] = el[key]; + return acc; + }, {}) + ); +const reject = (pred, array) => array.filter((...args) => !pred(...args)); +const remove = (arr, func) => + Array.isArray(arr) + ? arr.filter(func).reduce((acc, val) => { + arr.splice(arr.indexOf(val), 1); + return acc.concat(val); + }, []) + : []; +const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, ''); +const renameKeys = (keysMap, obj) => + Object.keys(obj).reduce( + (acc, key) => ({ + ...acc, + ...{ [keysMap[key] || key]: obj[key] } + }), + {} + ); +const reverseString = str => [...str].reverse().join(''); +const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`); +const runAsync = fn => { + const worker = new Worker( + URL.createObjectURL(new Blob([`postMessage((${fn})());`]), { + type: 'application/javascript; charset=utf-8' + }) + ); + return new Promise((res, rej) => { + worker.onmessage = ({ data }) => { + res(data), worker.terminate(); + }; + worker.onerror = err => { + rej(err), worker.terminate(); + }; + }); +}; +const runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.resolve()); +const sample = arr => arr[Math.floor(Math.random() * arr.length)]; +const sampleSize = ([...arr], n = 1) => { + let m = arr.length; + while (m) { + const i = Math.floor(Math.random() * m--); + [arr[m], arr[i]] = [arr[i], arr[m]]; + } + return arr.slice(0, n); +}; +const scrollToTop = () => { + const c = document.documentElement.scrollTop || document.body.scrollTop; + if (c > 0) { + window.requestAnimationFrame(scrollToTop); + window.scrollTo(0, c - c / 8); + } +}; +const sdbm = str => { + let arr = str.split(''); + return arr.reduce( + (hashCode, currentVal) => + (hashCode = currentVal.charCodeAt(0) + (hashCode << 6) + (hashCode << 16) - hashCode), + 0 + ); +}; +const serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`; +const setStyle = (el, ruleName, val) => (el.style[ruleName] = val); +const shallowClone = obj => Object.assign({}, obj); +const shank = (arr, index = 0, delCount = 0, ...elements) => + arr + .slice(0, index) + .concat(elements) + .concat(arr.slice(index + delCount)); +const show = (...el) => [...el].forEach(e => (e.style.display = '')); +const shuffle = ([...arr]) => { + let m = arr.length; + while (m) { + const i = Math.floor(Math.random() * m--); + [arr[m], arr[i]] = [arr[i], arr[m]]; + } + return arr; +}; +const similarity = (arr, values) => arr.filter(v => values.includes(v)); +const size = val => + Array.isArray(val) + ? val.length + : val && typeof val === 'object' + ? val.size || val.length || Object.keys(val).length + : typeof val === 'string' + ? new Blob([val]).size + : 0; +const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); +const smoothScroll = element => + document.querySelector(element).scrollIntoView({ + behavior: 'smooth' + }); +const sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join(''); +const sortedIndex = (arr, n) => { + const isDescending = arr[0] > arr[arr.length - 1]; + const index = arr.findIndex(el => (isDescending ? n >= el : n <= el)); + return index === -1 ? arr.length : index; +}; +const sortedIndexBy = (arr, n, fn) => { + const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]); + const val = fn(n); + const index = arr.findIndex(el => (isDescending ? val >= fn(el) : val <= fn(el))); + return index === -1 ? arr.length : index; +}; +const sortedLastIndex = (arr, n) => { + const isDescending = arr[0] > arr[arr.length - 1]; + const index = arr.reverse().findIndex(el => (isDescending ? n <= el : n >= el)); + return index === -1 ? 0 : arr.length - index; +}; +const sortedLastIndexBy = (arr, n, fn) => { + const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]); + const val = fn(n); + const index = arr + .map(fn) + .reverse() + .findIndex(el => (isDescending ? val <= el : val >= el)); + return index === -1 ? 0 : arr.length - index; +}; +const splitLines = str => str.split(/\r?\n/); const spreadOver = fn => argsArr => fn(...argsArr); - const stableSort = (arr, compare) => - arr - .map((item, index) => ({ item, index })) - .sort((a, b) => compare(a.item, b.item) || a.index - b.index) - .map(({ item }) => item); - const standardDeviation = (arr, usePopulation = false) => { - const mean = arr.reduce((acc, val) => acc + val, 0) / arr.length; - return Math.sqrt( - arr.reduce((acc, val) => acc.concat((val - mean) ** 2), []).reduce((acc, val) => acc + val, 0) / - (arr.length - (usePopulation ? 0 : 1)) - ); -}; - const stringPermutations = str => { - if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str]; - return str - .split('') - .reduce( - (acc, letter, i) => - acc.concat(stringPermutations(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)), - [] - ); -}; - const stripHTMLTags = str => str.replace(/<[^>]*>/g, ''); - const sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0); - const sumBy = (arr, fn) => - arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0); - const sumPower = (end, power = 2, start = 1) => - Array(end + 1 - start) - .fill(0) - .map((x, i) => (i + start) ** power) - .reduce((a, b) => a + b, 0); - const symmetricDifference = (a, b) => { - const sA = new Set(a), - sB = new Set(b); - return [...a.filter(x => !sB.has(x)), ...b.filter(x => !sA.has(x))]; -}; - const symmetricDifferenceBy = (a, b, fn) => { - const sA = new Set(a.map(v => fn(v))), - sB = new Set(b.map(v => fn(v))); - return [...a.filter(x => !sB.has(fn(x))), ...b.filter(x => !sA.has(fn(x)))]; -}; - const symmetricDifferenceWith = (arr, val, comp) => [ - ...arr.filter(a => val.findIndex(b => comp(a, b)) === -1), - ...val.filter(a => arr.findIndex(b => comp(a, b)) === -1) -]; - const tail = arr => (arr.length > 1 ? arr.slice(1) : arr); - const take = (arr, n = 1) => arr.slice(0, n); - const takeRight = (arr, n = 1) => arr.slice(arr.length - n, arr.length); - const takeRightWhile = (arr, func) => - arr.reduceRight((acc, el) => (func(el) ? acc : [el, ...acc]), []); - const takeWhile = (arr, func) => { - for (const [i, val] of arr.entries()) if (func(val)) return arr.slice(0, i); - return arr; -}; - const throttle = (fn, wait) => { - let inThrottle, lastFn, lastTime; - return function() { - const context = this, - args = arguments; - if (!inThrottle) { - fn.apply(context, args); - lastTime = Date.now(); - inThrottle = true; - } else { - clearTimeout(lastFn); - lastFn = setTimeout(function() { - if (Date.now() - lastTime >= wait) { - fn.apply(context, args); - lastTime = Date.now(); - } - }, Math.max(wait - (Date.now() - lastTime), 0)); - } - }; -}; - const times = (n, fn, context = undefined) => { - let i = 0; - while (fn.call(context, i) !== false && ++i < n) {} -}; - const timeTaken = callback => { - console.time('timeTaken'); - const r = callback(); - console.timeEnd('timeTaken'); - return r; -}; - const toCamelCase = str => { - let s = - str && - str - .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) - .map(x => x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase()) - .join(''); - return s.slice(0, 1).toLowerCase() + s.slice(1); -}; - const toCurrency = (n, curr, LanguageFormat = undefined) => - Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n); - const toDecimalMark = num => num.toLocaleString('en-US'); - const toggleClass = (el, className) => el.classList.toggle(className); - const toHash = (object, key) => - Array.prototype.reduce.call( - object, - (acc, data, index) => ((acc[!key ? index : data[key]] = data), acc), - {} - ); - const toKebabCase = str => - str && - str - .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) - .map(x => x.toLowerCase()) - .join('-'); - const tomorrow = (long = false) => { - let t = new Date(); - t.setDate(t.getDate() + 1); - const ret = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String( - t.getDate() - ).padStart(2, '0')}`; - return !long ? ret : `${ret}T00:00:00`; -}; - const toOrdinalSuffix = num => { - const int = parseInt(num), - digits = [int % 10, int % 100], - ordinals = ['st', 'nd', 'rd', 'th'], - oPattern = [1, 2, 3, 4], - tPattern = [11, 12, 13, 14, 15, 16, 17, 18, 19]; - return oPattern.includes(digits[0]) && !tPattern.includes(digits[1]) - ? int + ordinals[digits[0] - 1] - : int + ordinals[3]; -}; - const toSafeInteger = num => - Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER)); - const toSnakeCase = str => - str && - str - .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) - .map(x => x.toLowerCase()) - .join('_'); - const toTitleCase = str => - str - .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) - .map(x => x.charAt(0).toUpperCase() + x.slice(1)) - .join(' '); - const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc); - const triggerEvent = (el, eventType, detail) => - el.dispatchEvent(new CustomEvent(eventType, { detail })); - const truncateString = (str, num) => - str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str; - const truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]); - const unary = fn => val => fn(val); - const uncurry = (fn, n = 1) => (...args) => { - const next = acc => args => args.reduce((x, y) => x(y), acc); - if (n > args.length) throw new RangeError('Arguments too few!'); - return next(fn)(args.slice(0, n)); -}; - const unescapeHTML = str => - str.replace( - /&|<|>|'|"/g, - tag => - ({ - '&': '&', - '<': '<', - '>': '>', - ''': "'", - '"': '"' - }[tag] || tag) - ); - const unflattenObject = obj => - Object.keys(obj).reduce((acc, k) => { - if (k.indexOf('.') !== -1) { - const keys = k.split('.'); - Object.assign( - acc, - JSON.parse( - '{' + - keys.map((v, i) => (i !== keys.length - 1 ? `"${v}":{` : `"${v}":`)).join('') + - obj[k] + - '}'.repeat(keys.length) - ) - ); - } else acc[k] = obj[k]; - return acc; - }, {}); - const unfold = (fn, seed) => { - let result = [], - val = [null, seed]; - while ((val = fn(val[1]))) result.push(val[0]); - return result; -}; - const union = (a, b) => Array.from(new Set([...a, ...b])); - const unionBy = (a, b, fn) => { - const s = new Set(a.map(fn)); - return Array.from(new Set([...a, ...b.filter(x => !s.has(fn(x)))])); -}; - const unionWith = (a, b, comp) => - Array.from(new Set([...a, ...b.filter(x => a.findIndex(y => comp(x, y)) === -1)])); - const uniqueElements = arr => [...new Set(arr)]; - const uniqueElementsBy = (arr, fn) => - arr.reduce((acc, v) => { - if (!acc.some(x => fn(v, x))) acc.push(v); - return acc; - }, []); - const uniqueElementsByRight = (arr, fn) => - arr.reduceRight((acc, v) => { - if (!acc.some(x => fn(v, x))) acc.push(v); - return acc; - }, []); - const uniqueSymmetricDifference = (a, b) => [ - ...new Set([...a.filter(v => !b.includes(v)), ...b.filter(v => !a.includes(v))]) -]; - const untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`); - const unzip = arr => - arr.reduce( - (acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc), - Array.from({ - length: Math.max(...arr.map(x => x.length)) - }).map(x => []) - ); - const unzipWith = (arr, fn) => - arr - .reduce( - (acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc), - Array.from({ - length: Math.max(...arr.map(x => x.length)) - }).map(x => []) - ) - .map(val => fn(...val)); - const URLJoin = (...args) => - args - .join('/') - .replace(/[\/]+/g, '/') - .replace(/^(.+):\//, '$1://') - .replace(/^file:/, 'file:/') - .replace(/\/(\?|&|#[^!])/g, '$1') - .replace(/\?/g, '&') - .replace('&', '?'); - const UUIDGeneratorBrowser = () => - ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => - (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16) - ); - -const UUIDGeneratorNode = () => - ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => - (c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16) - ); - const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; - const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x); - const without = (arr, ...args) => arr.filter(v => !args.includes(v)); - const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); - const xProd = (a, b) => a.reduce((acc, x) => acc.concat(b.map(y => [x, y])), []); - const yesNo = (val, def = false) => - /^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def; - const zip = (...arrays) => { - const maxLength = Math.max(...arrays.map(x => x.length)); - return Array.from({ length: maxLength }).map((_, i) => { - return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]); - }); -}; - const zipObject = (props, values) => - props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {}); - const zipWith = (...array) => { - const fn = typeof array[array.length - 1] === 'function' ? array.pop() : undefined; - return Array.from( - { length: Math.max(...array.map(a => a.length)) }, - (_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i])) - ); -}; +const stableSort = (arr, compare) => + arr + .map((item, index) => ({ item, index })) + .sort((a, b) => compare(a.item, b.item) || a.index - b.index) + .map(({ item }) => item); +const standardDeviation = (arr, usePopulation = false) => { + const mean = arr.reduce((acc, val) => acc + val, 0) / arr.length; + return Math.sqrt( + arr.reduce((acc, val) => acc.concat((val - mean) ** 2), []).reduce((acc, val) => acc + val, 0) / + (arr.length - (usePopulation ? 0 : 1)) + ); +}; +const stringPermutations = str => { + if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str]; + return str + .split('') + .reduce( + (acc, letter, i) => + acc.concat(stringPermutations(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)), + [] + ); +}; +const stripHTMLTags = str => str.replace(/<[^>]*>/g, ''); +const sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0); +const sumBy = (arr, fn) => + arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0); +const sumPower = (end, power = 2, start = 1) => + Array(end + 1 - start) + .fill(0) + .map((x, i) => (i + start) ** power) + .reduce((a, b) => a + b, 0); +const symmetricDifference = (a, b) => { + const sA = new Set(a), + sB = new Set(b); + return [...a.filter(x => !sB.has(x)), ...b.filter(x => !sA.has(x))]; +}; +const symmetricDifferenceBy = (a, b, fn) => { + const sA = new Set(a.map(v => fn(v))), + sB = new Set(b.map(v => fn(v))); + return [...a.filter(x => !sB.has(fn(x))), ...b.filter(x => !sA.has(fn(x)))]; +}; +const symmetricDifferenceWith = (arr, val, comp) => [ + ...arr.filter(a => val.findIndex(b => comp(a, b)) === -1), + ...val.filter(a => arr.findIndex(b => comp(a, b)) === -1) +]; +const tail = arr => (arr.length > 1 ? arr.slice(1) : arr); +const take = (arr, n = 1) => arr.slice(0, n); +const takeRight = (arr, n = 1) => arr.slice(arr.length - n, arr.length); +const takeRightWhile = (arr, func) => + arr.reduceRight((acc, el) => (func(el) ? acc : [el, ...acc]), []); +const takeWhile = (arr, func) => { + for (const [i, val] of arr.entries()) if (func(val)) return arr.slice(0, i); + return arr; +}; +const throttle = (fn, wait) => { + let inThrottle, lastFn, lastTime; + return function() { + const context = this, + args = arguments; + if (!inThrottle) { + fn.apply(context, args); + lastTime = Date.now(); + inThrottle = true; + } else { + clearTimeout(lastFn); + lastFn = setTimeout(function() { + if (Date.now() - lastTime >= wait) { + fn.apply(context, args); + lastTime = Date.now(); + } + }, Math.max(wait - (Date.now() - lastTime), 0)); + } + }; +}; +const timeTaken = callback => { + console.time('timeTaken'); + const r = callback(); + console.timeEnd('timeTaken'); + return r; +}; +const times = (n, fn, context = undefined) => { + let i = 0; + while (fn.call(context, i) !== false && ++i < n) {} +}; +const toCamelCase = str => { + let s = + str && + str + .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) + .map(x => x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase()) + .join(''); + return s.slice(0, 1).toLowerCase() + s.slice(1); +}; +const toCurrency = (n, curr, LanguageFormat = undefined) => + Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n); +const toDecimalMark = num => num.toLocaleString('en-US'); +const toHash = (object, key) => + Array.prototype.reduce.call( + object, + (acc, data, index) => ((acc[!key ? index : data[key]] = data), acc), + {} + ); +const toKebabCase = str => + str && + str + .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) + .map(x => x.toLowerCase()) + .join('-'); +const toOrdinalSuffix = num => { + const int = parseInt(num), + digits = [int % 10, int % 100], + ordinals = ['st', 'nd', 'rd', 'th'], + oPattern = [1, 2, 3, 4], + tPattern = [11, 12, 13, 14, 15, 16, 17, 18, 19]; + return oPattern.includes(digits[0]) && !tPattern.includes(digits[1]) + ? int + ordinals[digits[0] - 1] + : int + ordinals[3]; +}; +const toSafeInteger = num => + Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER)); +const toSnakeCase = str => + str && + str + .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) + .map(x => x.toLowerCase()) + .join('_'); +const toTitleCase = str => + str + .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) + .map(x => x.charAt(0).toUpperCase() + x.slice(1)) + .join(' '); +const toggleClass = (el, className) => el.classList.toggle(className); +const tomorrow = (long = false) => { + let t = new Date(); + t.setDate(t.getDate() + 1); + const ret = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String( + t.getDate() + ).padStart(2, '0')}`; + return !long ? ret : `${ret}T00:00:00`; +}; +const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc); +const triggerEvent = (el, eventType, detail) => + el.dispatchEvent(new CustomEvent(eventType, { detail })); +const truncateString = (str, num) => + str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str; +const truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]); +const unary = fn => val => fn(val); +const uncurry = (fn, n = 1) => (...args) => { + const next = acc => args => args.reduce((x, y) => x(y), acc); + if (n > args.length) throw new RangeError('Arguments too few!'); + return next(fn)(args.slice(0, n)); +}; +const unescapeHTML = str => + str.replace( + /&|<|>|'|"/g, + tag => + ({ + '&': '&', + '<': '<', + '>': '>', + ''': "'", + '"': '"' + }[tag] || tag) + ); +const unflattenObject = obj => + Object.keys(obj).reduce((acc, k) => { + if (k.indexOf('.') !== -1) { + const keys = k.split('.'); + Object.assign( + acc, + JSON.parse( + '{' + + keys.map((v, i) => (i !== keys.length - 1 ? `"${v}":{` : `"${v}":`)).join('') + + obj[k] + + '}'.repeat(keys.length) + ) + ); + } else acc[k] = obj[k]; + return acc; + }, {}); +const unfold = (fn, seed) => { + let result = [], + val = [null, seed]; + while ((val = fn(val[1]))) result.push(val[0]); + return result; +}; +const union = (a, b) => Array.from(new Set([...a, ...b])); +const unionBy = (a, b, fn) => { + const s = new Set(a.map(fn)); + return Array.from(new Set([...a, ...b.filter(x => !s.has(fn(x)))])); +}; +const unionWith = (a, b, comp) => + Array.from(new Set([...a, ...b.filter(x => a.findIndex(y => comp(x, y)) === -1)])); +const uniqueElements = arr => [...new Set(arr)]; +const uniqueElementsBy = (arr, fn) => + arr.reduce((acc, v) => { + if (!acc.some(x => fn(v, x))) acc.push(v); + return acc; + }, []); +const uniqueElementsByRight = (arr, fn) => + arr.reduceRight((acc, v) => { + if (!acc.some(x => fn(v, x))) acc.push(v); + return acc; + }, []); +const uniqueSymmetricDifference = (a, b) => [ + ...new Set([...a.filter(v => !b.includes(v)), ...b.filter(v => !a.includes(v))]) +]; +const untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`); +const unzip = arr => + arr.reduce( + (acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc), + Array.from({ + length: Math.max(...arr.map(x => x.length)) + }).map(x => []) + ); +const unzipWith = (arr, fn) => + arr + .reduce( + (acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc), + Array.from({ + length: Math.max(...arr.map(x => x.length)) + }).map(x => []) + ) + .map(val => fn(...val)); +const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; +const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x); +const without = (arr, ...args) => arr.filter(v => !args.includes(v)); +const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); +const xProd = (a, b) => a.reduce((acc, x) => acc.concat(b.map(y => [x, y])), []); +const yesNo = (val, def = false) => + /^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def; +const zip = (...arrays) => { + const maxLength = Math.max(...arrays.map(x => x.length)); + return Array.from({ length: maxLength }).map((_, i) => { + return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]); + }); +}; +const zipObject = (props, values) => + props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {}); +const zipWith = (...array) => { + const fn = typeof array[array.length - 1] === 'function' ? array.pop() : undefined; + return Array.from( + { length: Math.max(...array.map(a => a.length)) }, + (_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i])) + ); +}; -module.exports = {all,allEqual,any,approximatelyEqual,arrayToCSV,arrayToHtmlList,ary,atob,attempt,average,averageBy,bifurcate,bifurcateBy,bind,bindAll,bindKey,binomialCoefficient,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,composeRight,converge,copyToClipboard,countBy,counter,countOccurrences,createElement,createEventHub,CSVToArray,CSVToJSON,currentURL,curry,dayOfYear,debounce,decapitalize,deepClone,deepFlatten,deepFreeze,defaults,defer,degreesToRads,delay,detectDeviceType,difference,differenceBy,differenceWith,dig,digitize,distance,drop,dropRight,dropRightWhile,dropWhile,elementContains,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,filterNonUniqueBy,findKey,findLast,findLastIndex,findLastKey,flatten,flattenObject,flip,forEachRight,formatDuration,forOwn,forOwnRight,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getColonTimeFromDate,getDaysDiffBetweenDates,getImages,getMeridiemSuffixOfInteger,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,hz,indentString,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,initializeNDArray,inRange,insertAfter,insertBefore,intersection,intersectionBy,intersectionWith,invertKeyValues,is,isAbsoluteURL,isAfterDate,isAnagram,isArrayLike,isBeforeDate,isBoolean,isBrowser,isBrowserTabFocused,isDivisible,isDuplexStream,isEmpty,isEven,isFunction,isLowerCase,isNil,isNull,isNumber,isObject,isObjectLike,isPlainObject,isPrime,isPrimitive,isPromiseLike,isReadableStream,isSameDate,isSorted,isStream,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,isWritableStream,join,JSONtoCSV,JSONToFile,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapString,mapValues,mask,matches,matchesWith,maxBy,maxDate,maxN,median,memoize,merge,minBy,minDate,minN,mostPerformant,negate,nest,nodeListToArray,none,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,offset,omit,omitBy,on,once,onUserInputChange,orderBy,over,overArgs,pad,palindrome,parseCookie,partial,partialRight,partition,percentile,permutations,pick,pickBy,pipeAsyncFunctions,pipeFunctions,pluralize,powerset,prefix,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,radsToDegrees,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,rearg,recordAnimationFrames,redirect,reducedFilter,reduceSuccessive,reduceWhich,reject,remove,removeNonASCII,renameKeys,reverseString,RGBToHex,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,setStyle,shallowClone,shank,show,shuffle,similarity,size,sleep,smoothScroll,sortCharactersInString,sortedIndex,sortedIndexBy,sortedLastIndex,sortedLastIndexBy,splitLines,spreadOver,stableSort,standardDeviation,stringPermutations,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,times,timeTaken,toCamelCase,toCurrency,toDecimalMark,toggleClass,toHash,toKebabCase,tomorrow,toOrdinalSuffix,toSafeInteger,toSnakeCase,toTitleCase,transform,triggerEvent,truncateString,truthCheckCollection,unary,uncurry,unescapeHTML,unflattenObject,unfold,union,unionBy,unionWith,uniqueElements,uniqueElementsBy,uniqueElementsByRight,uniqueSymmetricDifference,untildify,unzip,unzipWith,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,validateNumber,when,without,words,xProd,yesNo,zip,zipObject,zipWith}; +module.exports = {CSVToArray,CSVToJSON,JSONToFile,JSONtoCSV,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,all,allEqual,any,approximatelyEqual,arrayToCSV,arrayToHtmlList,ary,atob,attempt,average,averageBy,bifurcate,bifurcateBy,bind,bindAll,bindKey,binomialCoefficient,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,composeRight,converge,copyToClipboard,countBy,countOccurrences,counter,createElement,createEventHub,currentURL,curry,dayOfYear,debounce,decapitalize,deepClone,deepFlatten,deepFreeze,defaults,defer,degreesToRads,delay,detectDeviceType,difference,differenceBy,differenceWith,dig,digitize,distance,drop,dropRight,dropRightWhile,dropWhile,elementContains,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,filterNonUniqueBy,findKey,findLast,findLastIndex,findLastKey,flatten,flattenObject,flip,forEachRight,forOwn,forOwnRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getColonTimeFromDate,getDaysDiffBetweenDates,getImages,getMeridiemSuffixOfInteger,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,hz,inRange,indentString,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,initializeNDArray,insertAfter,insertBefore,intersection,intersectionBy,intersectionWith,invertKeyValues,is,isAbsoluteURL,isAfterDate,isAnagram,isArrayLike,isBeforeDate,isBoolean,isBrowser,isBrowserTabFocused,isDivisible,isDuplexStream,isEmpty,isEven,isFunction,isLowerCase,isNil,isNull,isNumber,isObject,isObjectLike,isPlainObject,isPrime,isPrimitive,isPromiseLike,isReadableStream,isSameDate,isSorted,isStream,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,isWritableStream,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapString,mapValues,mask,matches,matchesWith,maxBy,maxDate,maxN,median,memoize,merge,minBy,minDate,minN,mostPerformant,negate,nest,nodeListToArray,none,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,offset,omit,omitBy,on,onUserInputChange,once,orderBy,over,overArgs,pad,palindrome,parseCookie,partial,partialRight,partition,percentile,permutations,pick,pickBy,pipeAsyncFunctions,pipeFunctions,pluralize,powerset,prefix,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,radsToDegrees,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,rearg,recordAnimationFrames,redirect,reduceSuccessive,reduceWhich,reducedFilter,reject,remove,removeNonASCII,renameKeys,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,setStyle,shallowClone,shank,show,shuffle,similarity,size,sleep,smoothScroll,sortCharactersInString,sortedIndex,sortedIndexBy,sortedLastIndex,sortedLastIndexBy,splitLines,spreadOver,stableSort,standardDeviation,stringPermutations,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,timeTaken,times,toCamelCase,toCurrency,toDecimalMark,toHash,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toTitleCase,toggleClass,tomorrow,transform,triggerEvent,truncateString,truthCheckCollection,unary,uncurry,unescapeHTML,unflattenObject,unfold,union,unionBy,unionWith,uniqueElements,uniqueElementsBy,uniqueElementsByRight,uniqueSymmetricDifference,untildify,unzip,unzipWith,validateNumber,when,without,words,xProd,yesNo,zip,zipObject,zipWith}; diff --git a/dist/_30s.js b/dist/_30s.js index 40d3e792c7c..803b0469696 100644 --- a/dist/_30s.js +++ b/dist/_30s.js @@ -4,1333 +4,1333 @@ (factory()); }(this, (function () { 'use strict'; - const crypto = typeof require !== "undefined" && require('crypto'); const fs = typeof require !== "undefined" && require('fs'); + const crypto = typeof require !== "undefined" && require('crypto'); + + const CSVToArray = (data, delimiter = ',', omitFirstRow = false) => + data + .slice(omitFirstRow ? data.indexOf('\n') + 1 : 0) + .split('\n') + .map(v => v.split(delimiter)); + const CSVToJSON = (data, delimiter = ',') => { + const titles = data.slice(0, data.indexOf('\n')).split(delimiter); + return data + .slice(data.indexOf('\n') + 1) + .split('\n') + .map(v => { + const values = v.split(delimiter); + return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {}); + }); + }; + + const JSONToFile = (obj, filename) => + fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2)); + const JSONtoCSV = (arr, columns, delimiter = ',') => + [ + columns.join(delimiter), + ...arr.map(obj => + columns.reduce( + (acc, key) => `${acc}${!acc.length ? '' : delimiter}"${!obj[key] ? '' : obj[key]}"`, + '' + ) + ) + ].join('\n'); + const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); + const URLJoin = (...args) => + args + .join('/') + .replace(/[\/]+/g, '/') + .replace(/^(.+):\//, '$1://') + .replace(/^file:/, 'file:/') + .replace(/\/(\?|&|#[^!])/g, '$1') + .replace(/\?/g, '&') + .replace('&', '?'); + const UUIDGeneratorBrowser = () => + ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => + (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16) + ); - const all = (arr, fn = Boolean) => arr.every(fn); - const allEqual = arr => arr.every(val => val === arr[0]); - const any = (arr, fn = Boolean) => arr.some(fn); - const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon; - const arrayToCSV = (arr, delimiter = ',') => - arr.map(v => v.map(x => `"${x}"`).join(delimiter)).join('\n'); - const arrayToHtmlList = (arr, listID) => - (el => ( - (el = document.querySelector('#' + listID)), - (el.innerHTML += arr.map(item => `
  • ${item}
  • `).join('')) - ))(); - const ary = (fn, n) => (...args) => fn(...args.slice(0, n)); - const atob = str => Buffer.from(str, 'base64').toString('binary'); - const attempt = (fn, ...args) => { - try { - return fn(...args); - } catch (e) { - return e instanceof Error ? e : new Error(e); - } - }; - const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length; - const averageBy = (arr, fn) => - arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) / - arr.length; - const bifurcate = (arr, filter) => - arr.reduce((acc, val, i) => (acc[filter[i] ? 0 : 1].push(val), acc), [[], []]); - const bifurcateBy = (arr, fn) => - arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [[], []]); - const bind = (fn, context, ...boundArgs) => (...args) => fn.apply(context, [...boundArgs, ...args]); - const bindAll = (obj, ...fns) => - fns.forEach( - fn => ( - (f = obj[fn]), - (obj[fn] = function() { - return f.apply(obj); - }) - ) - ); - const bindKey = (context, fn, ...boundArgs) => (...args) => - context[fn].apply(context, [...boundArgs, ...args]); - const binomialCoefficient = (n, k) => { - if (Number.isNaN(n) || Number.isNaN(k)) return NaN; - if (k < 0 || k > n) return 0; - if (k === 0 || k === n) return 1; - if (k === 1 || k === n - 1) return n; - if (n - k < k) k = n - k; - let res = n; - for (let j = 2; j <= k; j++) res *= (n - j + 1) / j; - return Math.round(res); - }; - const bottomVisible = () => - document.documentElement.clientHeight + window.scrollY >= - (document.documentElement.scrollHeight || document.documentElement.clientHeight); - const btoa = str => Buffer.from(str, 'binary').toString('base64'); - const byteSize = str => new Blob([str]).size; + const UUIDGeneratorNode = () => + ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => + (c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16) + ); + const all = (arr, fn = Boolean) => arr.every(fn); + const allEqual = arr => arr.every(val => val === arr[0]); + const any = (arr, fn = Boolean) => arr.some(fn); + const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon; + const arrayToCSV = (arr, delimiter = ',') => + arr.map(v => v.map(x => `"${x}"`).join(delimiter)).join('\n'); + const arrayToHtmlList = (arr, listID) => + (el => ( + (el = document.querySelector('#' + listID)), + (el.innerHTML += arr.map(item => `
  • ${item}
  • `).join('')) + ))(); + const ary = (fn, n) => (...args) => fn(...args.slice(0, n)); + const atob = str => Buffer.from(str, 'base64').toString('binary'); + const attempt = (fn, ...args) => { + try { + return fn(...args); + } catch (e) { + return e instanceof Error ? e : new Error(e); + } + }; + const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length; + const averageBy = (arr, fn) => + arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) / + arr.length; + const bifurcate = (arr, filter) => + arr.reduce((acc, val, i) => (acc[filter[i] ? 0 : 1].push(val), acc), [[], []]); + const bifurcateBy = (arr, fn) => + arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [[], []]); + const bind = (fn, context, ...boundArgs) => (...args) => fn.apply(context, [...boundArgs, ...args]); + const bindAll = (obj, ...fns) => + fns.forEach( + fn => ( + (f = obj[fn]), + (obj[fn] = function() { + return f.apply(obj); + }) + ) + ); + const bindKey = (context, fn, ...boundArgs) => (...args) => + context[fn].apply(context, [...boundArgs, ...args]); + const binomialCoefficient = (n, k) => { + if (Number.isNaN(n) || Number.isNaN(k)) return NaN; + if (k < 0 || k > n) return 0; + if (k === 0 || k === n) return 1; + if (k === 1 || k === n - 1) return n; + if (n - k < k) k = n - k; + let res = n; + for (let j = 2; j <= k; j++) res *= (n - j + 1) / j; + return Math.round(res); + }; + const bottomVisible = () => + document.documentElement.clientHeight + window.scrollY >= + (document.documentElement.scrollHeight || document.documentElement.clientHeight); + const btoa = str => Buffer.from(str, 'binary').toString('base64'); + const byteSize = str => new Blob([str]).size; const call = (key, ...args) => context => context[key](...args); - const capitalize = ([first, ...rest], lowerRest = false) => - first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join('')); - const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase()); - const castArray = val => (Array.isArray(val) ? val : [val]); - const chainAsync = fns => { - let curr = 0; - const next = () => fns[curr++](next); - next(); - }; - const chunk = (arr, size) => - Array.from({ length: Math.ceil(arr.length / size) }, (v, i) => - arr.slice(i * size, i * size + size) - ); - const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b)); - const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags); - const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_)); - const coalesceFactory = valid => (...args) => args.find(valid); + const capitalize = ([first, ...rest], lowerRest = false) => + first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join('')); + const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase()); + const castArray = val => (Array.isArray(val) ? val : [val]); + const chainAsync = fns => { + let curr = 0; + const next = () => fns[curr++](next); + next(); + }; + const chunk = (arr, size) => + Array.from({ length: Math.ceil(arr.length / size) }, (v, i) => + arr.slice(i * size, i * size + size) + ); + const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b)); + const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags); + const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_)); + const coalesceFactory = valid => (...args) => args.find(valid); const collectInto = fn => (...args) => fn(args); - const colorize = (...args) => ({ - black: `\x1b[30m${args.join(' ')}`, - red: `\x1b[31m${args.join(' ')}`, - green: `\x1b[32m${args.join(' ')}`, - yellow: `\x1b[33m${args.join(' ')}`, - blue: `\x1b[34m${args.join(' ')}`, - magenta: `\x1b[35m${args.join(' ')}`, - cyan: `\x1b[36m${args.join(' ')}`, - white: `\x1b[37m${args.join(' ')}`, - bgBlack: `\x1b[40m${args.join(' ')}\x1b[0m`, - bgRed: `\x1b[41m${args.join(' ')}\x1b[0m`, - bgGreen: `\x1b[42m${args.join(' ')}\x1b[0m`, - bgYellow: `\x1b[43m${args.join(' ')}\x1b[0m`, - bgBlue: `\x1b[44m${args.join(' ')}\x1b[0m`, - bgMagenta: `\x1b[45m${args.join(' ')}\x1b[0m`, - bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`, - bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m` - }); - const compact = arr => arr.filter(Boolean); - const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); - const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); - const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn.apply(null, args))); - const copyToClipboard = str => { - const el = document.createElement('textarea'); - el.value = str; - el.setAttribute('readonly', ''); - el.style.position = 'absolute'; - el.style.left = '-9999px'; - document.body.appendChild(el); - const selected = - document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; - el.select(); - document.execCommand('copy'); - document.body.removeChild(el); - if (selected) { - document.getSelection().removeAllRanges(); - document.getSelection().addRange(selected); - } - }; - const countBy = (arr, fn) => - arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => { - acc[val] = (acc[val] || 0) + 1; - return acc; - }, {}); - const counter = (selector, start, end, step = 1, duration = 2000) => { - let current = start, - _step = (end - start) * step < 0 ? -step : step, - timer = setInterval(() => { - current += _step; - document.querySelector(selector).innerHTML = current; - if (current >= end) document.querySelector(selector).innerHTML = end; - if (current >= end) clearInterval(timer); - }, Math.abs(Math.floor(duration / (end - start)))); - return timer; - }; - const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0); - const createElement = str => { - const el = document.createElement('div'); - el.innerHTML = str; - return el.firstElementChild; - }; - const createEventHub = () => ({ - hub: Object.create(null), - emit(event, data) { - (this.hub[event] || []).forEach(handler => handler(data)); - }, - on(event, handler) { - if (!this.hub[event]) this.hub[event] = []; - this.hub[event].push(handler); - }, - off(event, handler) { - const i = (this.hub[event] || []).findIndex(h => h === handler); - if (i > -1) this.hub[event].splice(i, 1); - } - }); - const CSVToArray = (data, delimiter = ',', omitFirstRow = false) => - data - .slice(omitFirstRow ? data.indexOf('\n') + 1 : 0) - .split('\n') - .map(v => v.split(delimiter)); - const CSVToJSON = (data, delimiter = ',') => { - const titles = data.slice(0, data.indexOf('\n')).split(delimiter); - return data - .slice(data.indexOf('\n') + 1) - .split('\n') - .map(v => { - const values = v.split(delimiter); - return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {}); - }); - }; - const currentURL = () => window.location.href; - const curry = (fn, arity = fn.length, ...args) => - arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args); - const dayOfYear = date => - Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24); - const debounce = (fn, ms = 0) => { - let timeoutId; - return function(...args) { - clearTimeout(timeoutId); - timeoutId = setTimeout(() => fn.apply(this, args), ms); - }; - }; - const decapitalize = ([first, ...rest], upperRest = false) => - first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join('')); - const deepClone = obj => { - let clone = Object.assign({}, obj); - Object.keys(clone).forEach( - key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key]) - ); - return Array.isArray(obj) ? (clone.length = obj.length) && Array.from(clone) : clone; - }; - const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v))); - const deepFreeze = obj => - Object.keys(obj).forEach( - prop => - !(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop]) - ) || Object.freeze(obj); - const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj); - const defer = (fn, ...args) => setTimeout(fn, 1, ...args); - const degreesToRads = deg => (deg * Math.PI) / 180.0; - const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args); - const detectDeviceType = () => - /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) - ? 'Mobile' - : 'Desktop'; - const difference = (a, b) => { - const s = new Set(b); - return a.filter(x => !s.has(x)); - }; - const differenceBy = (a, b, fn) => { - const s = new Set(b.map(fn)); - return a.filter(x => !s.has(fn(x))); - }; - const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1); - const dig = (obj, target) => - target in obj - ? obj[target] - : Object.values(obj).reduce((acc, val) => { - if (acc !== undefined) return acc; - if (typeof val === 'object') return dig(val, target); - }, undefined); - const digitize = n => [...`${n}`].map(i => parseInt(i)); - const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); - const drop = (arr, n = 1) => arr.slice(n); - const dropRight = (arr, n = 1) => arr.slice(0, -n); - const dropRightWhile = (arr, func) => { - while (arr.length > 0 && !func(arr[arr.length - 1])) arr = arr.slice(0, -1); - return arr; - }; - const dropWhile = (arr, func) => { - while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1); - return arr; - }; - const elementContains = (parent, child) => parent !== child && parent.contains(child); - const elementIsVisibleInViewport = (el, partiallyVisible = false) => { - const { top, left, bottom, right } = el.getBoundingClientRect(); - const { innerHeight, innerWidth } = window; - return partiallyVisible - ? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) && - ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth)) - : top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth; - }; - const elo = ([...ratings], kFactor = 32, selfRating) => { - const [a, b] = ratings; - const expectedScore = (self, opponent) => 1 / (1 + 10 ** ((opponent - self) / 400)); - const newRating = (rating, i) => - (selfRating || rating) + kFactor * (i - expectedScore(i ? a : b, i ? b : a)); - if (ratings.length === 2) return [newRating(a, 1), newRating(b, 0)]; - - for (let i = 0, len = ratings.length; i < len; i++) { - let j = i; - while (j < len - 1) { - j++; - [ratings[i], ratings[j]] = elo([ratings[i], ratings[j]], kFactor); - } - } - return ratings; - }; - const equals = (a, b) => { - if (a === b) return true; - if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime(); - if (!a || !b || (typeof a !== 'object' && typeof b !== 'object')) return a === b; - if (a === null || a === undefined || b === null || b === undefined) return false; - if (a.prototype !== b.prototype) return false; - let keys = Object.keys(a); - if (keys.length !== Object.keys(b).length) return false; - return keys.every(k => equals(a[k], b[k])); - }; - const escapeHTML = str => - str.replace( - /[&<>'"]/g, - tag => - ({ - '&': '&', - '<': '<', - '>': '>', - "'": ''', - '"': '"' - }[tag] || tag) - ); - const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); - const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1); - const extendHex = shortHex => - '#' + - shortHex - .slice(shortHex.startsWith('#') ? 1 : 0) - .split('') - .map(x => x + x) - .join(''); - const factorial = n => - n < 0 - ? (() => { - throw new TypeError('Negative numbers are not allowed!'); - })() - : n <= 1 - ? 1 - : n * factorial(n - 1); - const fibonacci = n => - Array.from({ length: n }).reduce( - (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), - [] - ); - const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i)); - const filterNonUniqueBy = (arr, fn) => - arr.filter((v, i) => arr.every((x, j) => (i === j) === fn(v, x, i, j))); - const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj)); - const findLast = (arr, fn) => arr.filter(fn).pop(); - const findLastIndex = (arr, fn) => - arr - .map((val, i) => [i, val]) - .filter(([i, val]) => fn(val, i, arr)) - .pop()[0]; - const findLastKey = (obj, fn) => - Object.keys(obj) - .reverse() - .find(key => fn(obj[key], key, obj)); - const flatten = (arr, depth = 1) => - arr.reduce((a, v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []); - const flattenObject = (obj, prefix = '') => - Object.keys(obj).reduce((acc, k) => { - const pre = prefix.length ? prefix + '.' : ''; - if (typeof obj[k] === 'object') Object.assign(acc, flattenObject(obj[k], pre + k)); - else acc[pre + k] = obj[k]; - return acc; - }, {}); + const colorize = (...args) => ({ + black: `\x1b[30m${args.join(' ')}`, + red: `\x1b[31m${args.join(' ')}`, + green: `\x1b[32m${args.join(' ')}`, + yellow: `\x1b[33m${args.join(' ')}`, + blue: `\x1b[34m${args.join(' ')}`, + magenta: `\x1b[35m${args.join(' ')}`, + cyan: `\x1b[36m${args.join(' ')}`, + white: `\x1b[37m${args.join(' ')}`, + bgBlack: `\x1b[40m${args.join(' ')}\x1b[0m`, + bgRed: `\x1b[41m${args.join(' ')}\x1b[0m`, + bgGreen: `\x1b[42m${args.join(' ')}\x1b[0m`, + bgYellow: `\x1b[43m${args.join(' ')}\x1b[0m`, + bgBlue: `\x1b[44m${args.join(' ')}\x1b[0m`, + bgMagenta: `\x1b[45m${args.join(' ')}\x1b[0m`, + bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`, + bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m` + }); + const compact = arr => arr.filter(Boolean); + const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); + const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); + const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn.apply(null, args))); + const copyToClipboard = str => { + const el = document.createElement('textarea'); + el.value = str; + el.setAttribute('readonly', ''); + el.style.position = 'absolute'; + el.style.left = '-9999px'; + document.body.appendChild(el); + const selected = + document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; + el.select(); + document.execCommand('copy'); + document.body.removeChild(el); + if (selected) { + document.getSelection().removeAllRanges(); + document.getSelection().addRange(selected); + } + }; + const countBy = (arr, fn) => + arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => { + acc[val] = (acc[val] || 0) + 1; + return acc; + }, {}); + const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0); + const counter = (selector, start, end, step = 1, duration = 2000) => { + let current = start, + _step = (end - start) * step < 0 ? -step : step, + timer = setInterval(() => { + current += _step; + document.querySelector(selector).innerHTML = current; + if (current >= end) document.querySelector(selector).innerHTML = end; + if (current >= end) clearInterval(timer); + }, Math.abs(Math.floor(duration / (end - start)))); + return timer; + }; + const createElement = str => { + const el = document.createElement('div'); + el.innerHTML = str; + return el.firstElementChild; + }; + const createEventHub = () => ({ + hub: Object.create(null), + emit(event, data) { + (this.hub[event] || []).forEach(handler => handler(data)); + }, + on(event, handler) { + if (!this.hub[event]) this.hub[event] = []; + this.hub[event].push(handler); + }, + off(event, handler) { + const i = (this.hub[event] || []).findIndex(h => h === handler); + if (i > -1) this.hub[event].splice(i, 1); + } + }); + const currentURL = () => window.location.href; + const curry = (fn, arity = fn.length, ...args) => + arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args); + const dayOfYear = date => + Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24); + const debounce = (fn, ms = 0) => { + let timeoutId; + return function(...args) { + clearTimeout(timeoutId); + timeoutId = setTimeout(() => fn.apply(this, args), ms); + }; + }; + const decapitalize = ([first, ...rest], upperRest = false) => + first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join('')); + const deepClone = obj => { + let clone = Object.assign({}, obj); + Object.keys(clone).forEach( + key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key]) + ); + return Array.isArray(obj) ? (clone.length = obj.length) && Array.from(clone) : clone; + }; + const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v))); + const deepFreeze = obj => + Object.keys(obj).forEach( + prop => + !(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop]) + ) || Object.freeze(obj); + const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj); + const defer = (fn, ...args) => setTimeout(fn, 1, ...args); + const degreesToRads = deg => (deg * Math.PI) / 180.0; + const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args); + const detectDeviceType = () => + /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) + ? 'Mobile' + : 'Desktop'; + const difference = (a, b) => { + const s = new Set(b); + return a.filter(x => !s.has(x)); + }; + const differenceBy = (a, b, fn) => { + const s = new Set(b.map(fn)); + return a.filter(x => !s.has(fn(x))); + }; + const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1); + const dig = (obj, target) => + target in obj + ? obj[target] + : Object.values(obj).reduce((acc, val) => { + if (acc !== undefined) return acc; + if (typeof val === 'object') return dig(val, target); + }, undefined); + const digitize = n => [...`${n}`].map(i => parseInt(i)); + const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); + const drop = (arr, n = 1) => arr.slice(n); + const dropRight = (arr, n = 1) => arr.slice(0, -n); + const dropRightWhile = (arr, func) => { + while (arr.length > 0 && !func(arr[arr.length - 1])) arr = arr.slice(0, -1); + return arr; + }; + const dropWhile = (arr, func) => { + while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1); + return arr; + }; + const elementContains = (parent, child) => parent !== child && parent.contains(child); + const elementIsVisibleInViewport = (el, partiallyVisible = false) => { + const { top, left, bottom, right } = el.getBoundingClientRect(); + const { innerHeight, innerWidth } = window; + return partiallyVisible + ? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) && + ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth)) + : top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth; + }; + const elo = ([...ratings], kFactor = 32, selfRating) => { + const [a, b] = ratings; + const expectedScore = (self, opponent) => 1 / (1 + 10 ** ((opponent - self) / 400)); + const newRating = (rating, i) => + (selfRating || rating) + kFactor * (i - expectedScore(i ? a : b, i ? b : a)); + if (ratings.length === 2) return [newRating(a, 1), newRating(b, 0)]; + + for (let i = 0, len = ratings.length; i < len; i++) { + let j = i; + while (j < len - 1) { + j++; + [ratings[i], ratings[j]] = elo([ratings[i], ratings[j]], kFactor); + } + } + return ratings; + }; + const equals = (a, b) => { + if (a === b) return true; + if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime(); + if (!a || !b || (typeof a !== 'object' && typeof b !== 'object')) return a === b; + if (a === null || a === undefined || b === null || b === undefined) return false; + if (a.prototype !== b.prototype) return false; + let keys = Object.keys(a); + if (keys.length !== Object.keys(b).length) return false; + return keys.every(k => equals(a[k], b[k])); + }; + const escapeHTML = str => + str.replace( + /[&<>'"]/g, + tag => + ({ + '&': '&', + '<': '<', + '>': '>', + "'": ''', + '"': '"' + }[tag] || tag) + ); + const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1); + const extendHex = shortHex => + '#' + + shortHex + .slice(shortHex.startsWith('#') ? 1 : 0) + .split('') + .map(x => x + x) + .join(''); + const factorial = n => + n < 0 + ? (() => { + throw new TypeError('Negative numbers are not allowed!'); + })() + : n <= 1 + ? 1 + : n * factorial(n - 1); + const fibonacci = n => + Array.from({ length: n }).reduce( + (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), + [] + ); + const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i)); + const filterNonUniqueBy = (arr, fn) => + arr.filter((v, i) => arr.every((x, j) => (i === j) === fn(v, x, i, j))); + const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj)); + const findLast = (arr, fn) => arr.filter(fn).pop(); + const findLastIndex = (arr, fn) => + arr + .map((val, i) => [i, val]) + .filter(([i, val]) => fn(val, i, arr)) + .pop()[0]; + const findLastKey = (obj, fn) => + Object.keys(obj) + .reverse() + .find(key => fn(obj[key], key, obj)); + const flatten = (arr, depth = 1) => + arr.reduce((a, v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []); + const flattenObject = (obj, prefix = '') => + Object.keys(obj).reduce((acc, k) => { + const pre = prefix.length ? prefix + '.' : ''; + if (typeof obj[k] === 'object') Object.assign(acc, flattenObject(obj[k], pre + k)); + else acc[pre + k] = obj[k]; + return acc; + }, {}); const flip = fn => (first, ...rest) => fn(...rest, first); - const forEachRight = (arr, callback) => - arr - .slice(0) - .reverse() - .forEach(callback); - const formatDuration = ms => { - if (ms < 0) ms = -ms; - const time = { - day: Math.floor(ms / 86400000), - hour: Math.floor(ms / 3600000) % 24, - minute: Math.floor(ms / 60000) % 60, - second: Math.floor(ms / 1000) % 60, - millisecond: Math.floor(ms) % 1000 - }; - return Object.entries(time) - .filter(val => val[1] !== 0) - .map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`) - .join(', '); - }; - const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj)); - const forOwnRight = (obj, fn) => - Object.keys(obj) - .reverse() - .forEach(key => fn(obj[key], key, obj)); - const fromCamelCase = (str, separator = '_') => - str - .replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2') - .replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2') - .toLowerCase(); - const functionName = fn => (console.debug(fn.name), fn); - const functions = (obj, inherited = false) => - (inherited - ? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))] - : Object.keys(obj) - ).filter(key => typeof obj[key] === 'function'); - const gcd = (...arr) => { - const _gcd = (x, y) => (!y ? x : gcd(y, x % y)); - return [...arr].reduce((a, b) => _gcd(a, b)); - }; - const geometricProgression = (end, start = 1, step = 2) => - Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map( - (v, i) => start * step ** i - ); - const get = (from, ...selectors) => - [...selectors].map(s => - s - .replace(/\[([^\[\]]*)\]/g, '.$1.') - .split('.') - .filter(t => t !== '') - .reduce((prev, cur) => prev && prev[cur], from) - ); - const getColonTimeFromDate = date => date.toTimeString().slice(0, 8); - const getDaysDiffBetweenDates = (dateInitial, dateFinal) => - (dateFinal - dateInitial) / (1000 * 3600 * 24); - const getImages = (el, includeDuplicates = false) => { - const images = [...el.getElementsByTagName('img')].map(img => img.getAttribute('src')); - return includeDuplicates ? images : [...new Set(images)]; - }; - const getMeridiemSuffixOfInteger = num => - num === 0 || num === 24 - ? 12 + 'am' - : num === 12 - ? 12 + 'pm' - : num < 12 - ? (num % 12) + 'am' - : (num % 12) + 'pm'; - const getScrollPosition = (el = window) => ({ - x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft, - y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop - }); - const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName]; - const getType = v => - v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase(); - const getURLParameters = url => - (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce( - (a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), - {} - ); - const groupBy = (arr, fn) => - arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => { - acc[val] = (acc[val] || []).concat(arr[i]); - return acc; - }, {}); - const hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length; - const hasClass = (el, className) => el.classList.contains(className); - const hasFlags = (...flags) => - flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag)); - const hashBrowser = val => - crypto.subtle.digest('SHA-256', new TextEncoder('utf-8').encode(val)).then(h => { - let hexes = [], - view = new DataView(h); - for (let i = 0; i < view.byteLength; i += 4) - hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8)); - return hexes.join(''); - }); - - const hashNode = val => - new Promise(resolve => - setTimeout( - () => - resolve( - crypto - .createHash('sha256') - .update(val) - .digest('hex') - ), - 0 - ) - ); - const head = arr => arr[0]; - const hexToRGB = hex => { - let alpha = false, - h = hex.slice(hex.startsWith('#') ? 1 : 0); - if (h.length === 3) h = [...h].map(x => x + x).join(''); - else if (h.length === 8) alpha = true; - h = parseInt(h, 16); - return ( - 'rgb' + - (alpha ? 'a' : '') + - '(' + - (h >>> (alpha ? 24 : 16)) + - ', ' + - ((h & (alpha ? 0x00ff0000 : 0x00ff00)) >>> (alpha ? 16 : 8)) + - ', ' + - ((h & (alpha ? 0x0000ff00 : 0x0000ff)) >>> (alpha ? 8 : 0)) + - (alpha ? `, ${h & 0x000000ff}` : '') + - ')' - ); - }; - const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); - const httpGet = (url, callback, err = console.error) => { - const request = new XMLHttpRequest(); - request.open('GET', url, true); - request.onload = () => callback(request.responseText); - request.onerror = () => err(request); - request.send(); - }; - const httpPost = (url, data, callback, err = console.error) => { - const request = new XMLHttpRequest(); - request.open('POST', url, true); - request.setRequestHeader('Content-type', 'application/json; charset=utf-8'); - request.onload = () => callback(request.responseText); - request.onerror = () => err(request); - request.send(data); - }; - const httpsRedirect = () => { - if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]); - }; - const hz = (fn, iterations = 100) => { - const before = performance.now(); - for (let i = 0; i < iterations; i++) fn(); - return (1000 * iterations) / (performance.now() - before); - }; - const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count)); - const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []); - const initial = arr => arr.slice(0, -1); - const initialize2DArray = (w, h, val = null) => - Array.from({ length: h }).map(() => Array.from({ length: w }).fill(val)); - const initializeArrayWithRange = (end, start = 0, step = 1) => - Array.from({ length: Math.ceil((end - start + 1) / step) }, (v, i) => i * step + start); - const initializeArrayWithRangeRight = (end, start = 0, step = 1) => - Array.from({ length: Math.ceil((end + 1 - start) / step) }).map( - (v, i, arr) => (arr.length - i - 1) * step + start - ); - const initializeArrayWithValues = (n, val = 0) => Array(n).fill(val); - const initializeNDArray = (val, ...args) => - args.length === 0 - ? val - : Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1))); - const inRange = (n, start, end = null) => { - if (end && start > end) [end, start] = [start, end]; - return end == null ? n >= 0 && n < start : n >= start && n < end; - }; - const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString); - const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString); - const intersection = (a, b) => { - const s = new Set(b); - return a.filter(x => s.has(x)); - }; - const intersectionBy = (a, b, fn) => { - const s = new Set(b.map(fn)); - return a.filter(x => s.has(fn(x))); - }; - const intersectionWith = (a, b, comp) => a.filter(x => b.findIndex(y => comp(x, y)) !== -1); - const invertKeyValues = (obj, fn) => - Object.keys(obj).reduce((acc, key) => { - const val = fn ? fn(obj[key]) : obj[key]; - acc[val] = acc[val] || []; - acc[val].push(key); - return acc; - }, {}); - const is = (type, val) => ![, null].includes(val) && val.constructor === type; - const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); - const isAfterDate = (dateA, dateB) => dateA > dateB; - const isAnagram = (str1, str2) => { - const normalize = str => - str - .toLowerCase() - .replace(/[^a-z0-9]/gi, '') - .split('') - .sort() - .join(''); - return normalize(str1) === normalize(str2); - }; - const isArrayLike = obj => obj != null && typeof obj[Symbol.iterator] === 'function'; - const isBeforeDate = (dateA, dateB) => dateA < dateB; - const isBoolean = val => typeof val === 'boolean'; - const isBrowser = () => ![typeof window, typeof document].includes('undefined'); - const isBrowserTabFocused = () => !document.hidden; - const isDivisible = (dividend, divisor) => dividend % divisor === 0; - const isDuplexStream = val => - val !== null && - typeof val === 'object' && - typeof val.pipe === 'function' && - typeof val._read === 'function' && - typeof val._readableState === 'object' && - typeof val._write === 'function' && - typeof val._writableState === 'object'; - const isEmpty = val => val == null || !(Object.keys(val) || val).length; - const isEven = num => num % 2 === 0; - const isFunction = val => typeof val === 'function'; - const isLowerCase = str => str === str.toLowerCase(); - const isNil = val => val === undefined || val === null; - const isNull = val => val === null; - const isNumber = val => typeof val === 'number'; - const isObject = obj => obj === Object(obj); - const isObjectLike = val => val !== null && typeof val === 'object'; - const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object; - const isPrime = num => { - const boundary = Math.floor(Math.sqrt(num)); - for (var i = 2; i <= boundary; i++) if (num % i === 0) return false; - return num >= 2; - }; - const isPrimitive = val => Object(val) !== val; - const isPromiseLike = obj => - obj !== null && - (typeof obj === 'object' || typeof obj === 'function') && - typeof obj.then === 'function'; - const isReadableStream = val => - val !== null && - typeof val === 'object' && - typeof val.pipe === 'function' && - typeof val._read === 'function' && - typeof val._readableState === 'object'; - const isSameDate = (dateA, dateB) => dateA.toISOString() === dateB.toISOString(); - const isSorted = arr => { - let direction = -(arr[0] - arr[1]); - for (let [i, val] of arr.entries()) { - direction = !direction ? -(arr[i - 1] - arr[i]) : direction; - if (i === arr.length - 1) return !direction ? 0 : direction; - else if ((val - arr[i + 1]) * direction > 0) return 0; - } - }; - const isStream = val => val !== null && typeof val === 'object' && typeof val.pipe === 'function'; - const isString = val => typeof val === 'string'; - const isSymbol = val => typeof val === 'symbol'; - const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; - const isUndefined = val => val === undefined; - const isUpperCase = str => str === str.toUpperCase(); - const isValidJSON = obj => { - try { - JSON.parse(obj); - return true; - } catch (e) { - return false; - } - }; - const isWritableStream = val => - val !== null && - typeof val === 'object' && - typeof val.pipe === 'function' && - typeof val._write === 'function' && - typeof val._writableState === 'object'; - const join = (arr, separator = ',', end = separator) => - arr.reduce( - (acc, val, i) => - i === arr.length - 2 - ? acc + val + end - : i === arr.length - 1 - ? acc + val - : acc + val + separator, - '' - ); - const JSONtoCSV = (arr, columns, delimiter = ',') => - [ - columns.join(delimiter), - ...arr.map(obj => - columns.reduce( - (acc, key) => `${acc}${!acc.length ? '' : delimiter}"${!obj[key] ? '' : obj[key]}"`, - '' - ) - ) - ].join('\n'); - - const JSONToFile = (obj, filename) => - fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2)); - const last = arr => arr[arr.length - 1]; - const lcm = (...arr) => { - const gcd = (x, y) => (!y ? x : gcd(y, x % y)); - const _lcm = (x, y) => (x * y) / gcd(x, y); - return [...arr].reduce((a, b) => _lcm(a, b)); - }; - const longestItem = (...vals) => vals.reduce((a, x) => (x.length > a.length ? x : a)); - const lowercaseKeys = obj => - Object.keys(obj).reduce((acc, key) => { - acc[key.toLowerCase()] = obj[key]; - return acc; - }, {}); - const luhnCheck = num => { - let arr = (num + '') - .split('') - .reverse() - .map(x => parseInt(x)); - let lastDigit = arr.splice(0, 1)[0]; - let sum = arr.reduce((acc, val, i) => (i % 2 !== 0 ? acc + val : acc + ((val * 2) % 9) || 9), 0); - sum += lastDigit; - return sum % 10 === 0; - }; - const mapKeys = (obj, fn) => - Object.keys(obj).reduce((acc, k) => { - acc[fn(obj[k], k, obj)] = obj[k]; - return acc; - }, {}); - const mapObject = (arr, fn) => - (a => ( - (a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {}) - ))(); - const mapString = (str, fn) => - str - .split('') - .map((c, i) => fn(c, i, str)) - .join(''); - const mapValues = (obj, fn) => - Object.keys(obj).reduce((acc, k) => { - acc[k] = fn(obj[k], k, obj); - return acc; - }, {}); - const mask = (cc, num = 4, mask = '*') => `${cc}`.slice(-num).padStart(`${cc}`.length, mask); - const matches = (obj, source) => - Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]); - const matchesWith = (obj, source, fn) => - Object.keys(source).every( - key => - obj.hasOwnProperty(key) && fn - ? fn(obj[key], source[key], key, obj, source) - : obj[key] == source[key] - ); - const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); - const maxDate = (...dates) => new Date(Math.max.apply(null, ...dates)); - const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n); - const median = arr => { - const mid = Math.floor(arr.length / 2), - nums = [...arr].sort((a, b) => a - b); - return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2; - }; - const memoize = fn => { - const cache = new Map(); - const cached = function(val) { - return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val); - }; - cached.cache = cache; - return cached; - }; - const merge = (...objs) => - [...objs].reduce( - (acc, obj) => - Object.keys(obj).reduce((a, k) => { - acc[k] = acc.hasOwnProperty(k) ? [].concat(acc[k]).concat(obj[k]) : obj[k]; - return acc; - }, {}), - {} - ); - const minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); - const minDate = (...dates) => new Date(Math.min.apply(null, ...dates)); - const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n); - const mostPerformant = (fns, iterations = 10000) => { - const times = fns.map(fn => { - const before = performance.now(); - for (let i = 0; i < iterations; i++) fn(); - return performance.now() - before; - }); - return times.indexOf(Math.min(...times)); - }; - const negate = func => (...args) => !func(...args); - const nest = (items, id = null, link = 'parent_id') => - items - .filter(item => item[link] === id) - .map(item => ({ ...item, children: nest(items, item.id) })); - const nodeListToArray = nodeList => [...nodeList]; - const none = (arr, fn = Boolean) => !arr.some(fn); - const nthArg = n => (...args) => args.slice(n)[0]; - const nthElement = (arr, n = 0) => (n === -1 ? arr.slice(n) : arr.slice(n, n + 1))[0]; - const objectFromPairs = arr => arr.reduce((a, [key, val]) => ((a[key] = val), a), {}); - const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]); - const observeMutations = (element, callback, options) => { - const observer = new MutationObserver(mutations => mutations.forEach(m => callback(m))); - observer.observe( - element, - Object.assign( - { - childList: true, - attributes: true, - attributeOldValue: true, - characterData: true, - characterDataOldValue: true, - subtree: true - }, - options - ) - ); - return observer; - }; - const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts); - const offset = (arr, offset) => [...arr.slice(offset), ...arr.slice(0, offset)]; - const omit = (obj, arr) => - Object.keys(obj) - .filter(k => !arr.includes(k)) - .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); - const omitBy = (obj, fn) => - Object.keys(obj) - .filter(k => !fn(obj[k], k)) - .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); - const on = (el, evt, fn, opts = {}) => { - const delegatorFn = e => e.target.matches(opts.target) && fn.call(e.target, e); - el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false); - if (opts.target) return delegatorFn; - }; - const once = fn => { - let called = false; - return function(...args) { - if (called) return; - called = true; - return fn.apply(this, args); - }; - }; - const onUserInputChange = callback => { - let type = 'mouse', - lastTime = 0; - const mousemoveHandler = () => { - const now = performance.now(); - if (now - lastTime < 20) - (type = 'mouse'), callback(type), document.removeEventListener('mousemove', mousemoveHandler); - lastTime = now; - }; - document.addEventListener('touchstart', () => { - if (type === 'touch') return; - (type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler); - }); - }; - const orderBy = (arr, props, orders) => - [...arr].sort((a, b) => - props.reduce((acc, prop, i) => { - if (acc === 0) { - const [p1, p2] = orders && orders[i] === 'desc' ? [b[prop], a[prop]] : [a[prop], b[prop]]; - acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0; - } - return acc; - }, 0) - ); - const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args)); - const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val))); - const pad = (str, length, char = ' ') => - str.padStart((str.length + length) / 2, char).padEnd(length, char); - const palindrome = str => { - const s = str.toLowerCase().replace(/[\W_]/g, ''); - return s === [...s].reverse().join(''); - }; - const parseCookie = str => - str - .split(';') - .map(v => v.split('=')) - .reduce((acc, v) => { - acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim()); - return acc; - }, {}); - const partial = (fn, ...partials) => (...args) => fn(...partials, ...args); - const partialRight = (fn, ...partials) => (...args) => fn(...args, ...partials); - const partition = (arr, fn) => - arr.reduce( - (acc, val, i, arr) => { - acc[fn(val, i, arr) ? 0 : 1].push(val); - return acc; - }, - [[], []] - ); - const percentile = (arr, val) => - (100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0)) / arr.length; - const permutations = arr => { - if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr; - return arr.reduce( - (acc, item, i) => - acc.concat( - permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val => [item, ...val]) - ), - [] - ); - }; - const pick = (obj, arr) => - arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {}); - const pickBy = (obj, fn) => - Object.keys(obj) - .filter(k => fn(obj[k], k)) - .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); - const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg)); - const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); - const pluralize = (val, word, plural = word + 's') => { - const _pluralize = (num, word, plural = word + 's') => - [1, -1].includes(Number(num)) ? word : plural; - if (typeof val === 'object') return (num, word) => _pluralize(num, word, val[word]); - return _pluralize(val, word, plural); - }; - const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]); - const prefix = prop => { - const capitalizedProp = prop.charAt(0).toUpperCase() + prop.slice(1); - const prefixes = ['', 'webkit', 'moz', 'ms', 'o']; - const i = prefixes.findIndex( - prefix => typeof document.body.style[prefix ? prefix + capitalizedProp : prop] !== 'undefined' - ); - return i !== -1 ? (i === 0 ? prop : prefixes[i] + capitalizedProp) : null; - }; - const prettyBytes = (num, precision = 3, addSpace = true) => { - const UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; - if (Math.abs(num) < 1) return num + (addSpace ? ' ' : '') + UNITS[0]; - const exponent = Math.min(Math.floor(Math.log10(num < 0 ? -num : num) / 3), UNITS.length - 1); - const n = Number(((num < 0 ? -num : num) / 1000 ** exponent).toPrecision(precision)); - return (num < 0 ? '-' : '') + n + (addSpace ? ' ' : '') + UNITS[exponent]; - }; - const primes = num => { - let arr = Array.from({ length: num - 1 }).map((x, i) => i + 2), - sqroot = Math.floor(Math.sqrt(num)), - numsTillSqroot = Array.from({ length: sqroot - 1 }).map((x, i) => i + 2); - numsTillSqroot.forEach(x => (arr = arr.filter(y => y % x !== 0 || y === x))); - return arr; - }; - const promisify = func => (...args) => - new Promise((resolve, reject) => - func(...args, (err, result) => (err ? reject(err) : resolve(result))) - ); - const pull = (arr, ...args) => { - let argState = Array.isArray(args[0]) ? args[0] : args; - let pulled = arr.filter((v, i) => !argState.includes(v)); - arr.length = 0; - pulled.forEach(v => arr.push(v)); - }; - const pullAtIndex = (arr, pullArr) => { - let removed = []; - let pulled = arr - .map((v, i) => (pullArr.includes(i) ? removed.push(v) : v)) - .filter((v, i) => !pullArr.includes(i)); - arr.length = 0; - pulled.forEach(v => arr.push(v)); - return removed; - }; - const pullAtValue = (arr, pullArr) => { - let removed = [], - pushToRemove = arr.forEach((v, i) => (pullArr.includes(v) ? removed.push(v) : v)), - mutateTo = arr.filter((v, i) => !pullArr.includes(v)); - arr.length = 0; - mutateTo.forEach(v => arr.push(v)); - return removed; - }; - const pullBy = (arr, ...args) => { - const length = args.length; - let fn = length > 1 ? args[length - 1] : undefined; - fn = typeof fn == 'function' ? (args.pop(), fn) : undefined; - let argState = (Array.isArray(args[0]) ? args[0] : args).map(val => fn(val)); - let pulled = arr.filter((v, i) => !argState.includes(fn(v))); - arr.length = 0; - pulled.forEach(v => arr.push(v)); - }; - const radsToDegrees = rad => (rad * 180.0) / Math.PI; - const randomHexColorCode = () => { - let n = (Math.random() * 0xfffff * 1000000).toString(16); - return '#' + n.slice(0, 6); - }; - const randomIntArrayInRange = (min, max, n = 1) => - Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min); - const randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; - const randomNumberInRange = (min, max) => Math.random() * (max - min) + min; - - const readFileLines = filename => - fs - .readFileSync(filename) - .toString('UTF8') - .split('\n'); - const rearg = (fn, indexes) => (...args) => fn(...indexes.map(i => args[i])); - const recordAnimationFrames = (callback, autoStart = true) => { - let running = true, - raf; - const stop = () => { - running = false; - cancelAnimationFrame(raf); - }; - const start = () => { - running = true; - run(); - }; - const run = () => { - raf = requestAnimationFrame(() => { - callback(); - if (running) run(); - }); - }; - if (autoStart) start(); - return { start, stop }; - }; - const redirect = (url, asLink = true) => - asLink ? (window.location.href = url) : window.location.replace(url); - const reducedFilter = (data, keys, fn) => - data.filter(fn).map(el => - keys.reduce((acc, key) => { - acc[key] = el[key]; - return acc; - }, {}) - ); - const reduceSuccessive = (arr, fn, acc) => - arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]); - const reduceWhich = (arr, comparator = (a, b) => a - b) => - arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a)); - const reject = (pred, array) => array.filter((...args) => !pred(...args)); - const remove = (arr, func) => - Array.isArray(arr) - ? arr.filter(func).reduce((acc, val) => { - arr.splice(arr.indexOf(val), 1); - return acc.concat(val); - }, []) - : []; - const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, ''); - const renameKeys = (keysMap, obj) => - Object.keys(obj).reduce( - (acc, key) => ({ - ...acc, - ...{ [keysMap[key] || key]: obj[key] } - }), - {} - ); - const reverseString = str => [...str].reverse().join(''); - const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); - const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`); - const runAsync = fn => { - const worker = new Worker( - URL.createObjectURL(new Blob([`postMessage((${fn})());`]), { - type: 'application/javascript; charset=utf-8' - }) - ); - return new Promise((res, rej) => { - worker.onmessage = ({ data }) => { - res(data), worker.terminate(); - }; - worker.onerror = err => { - rej(err), worker.terminate(); - }; - }); - }; - const runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.resolve()); - const sample = arr => arr[Math.floor(Math.random() * arr.length)]; - const sampleSize = ([...arr], n = 1) => { - let m = arr.length; - while (m) { - const i = Math.floor(Math.random() * m--); - [arr[m], arr[i]] = [arr[i], arr[m]]; - } - return arr.slice(0, n); - }; - const scrollToTop = () => { - const c = document.documentElement.scrollTop || document.body.scrollTop; - if (c > 0) { - window.requestAnimationFrame(scrollToTop); - window.scrollTo(0, c - c / 8); - } - }; - const sdbm = str => { - let arr = str.split(''); - return arr.reduce( - (hashCode, currentVal) => - (hashCode = currentVal.charCodeAt(0) + (hashCode << 6) + (hashCode << 16) - hashCode), - 0 - ); - }; - const serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`; - const setStyle = (el, ruleName, val) => (el.style[ruleName] = val); - const shallowClone = obj => Object.assign({}, obj); - const shank = (arr, index = 0, delCount = 0, ...elements) => - arr - .slice(0, index) - .concat(elements) - .concat(arr.slice(index + delCount)); - const show = (...el) => [...el].forEach(e => (e.style.display = '')); - const shuffle = ([...arr]) => { - let m = arr.length; - while (m) { - const i = Math.floor(Math.random() * m--); - [arr[m], arr[i]] = [arr[i], arr[m]]; - } - return arr; - }; - const similarity = (arr, values) => arr.filter(v => values.includes(v)); - const size = val => - Array.isArray(val) - ? val.length - : val && typeof val === 'object' - ? val.size || val.length || Object.keys(val).length - : typeof val === 'string' - ? new Blob([val]).size - : 0; - const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); - const smoothScroll = element => - document.querySelector(element).scrollIntoView({ - behavior: 'smooth' - }); - const sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join(''); - const sortedIndex = (arr, n) => { - const isDescending = arr[0] > arr[arr.length - 1]; - const index = arr.findIndex(el => (isDescending ? n >= el : n <= el)); - return index === -1 ? arr.length : index; - }; - const sortedIndexBy = (arr, n, fn) => { - const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]); - const val = fn(n); - const index = arr.findIndex(el => (isDescending ? val >= fn(el) : val <= fn(el))); - return index === -1 ? arr.length : index; - }; - const sortedLastIndex = (arr, n) => { - const isDescending = arr[0] > arr[arr.length - 1]; - const index = arr.reverse().findIndex(el => (isDescending ? n <= el : n >= el)); - return index === -1 ? 0 : arr.length - index; - }; - const sortedLastIndexBy = (arr, n, fn) => { - const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]); - const val = fn(n); - const index = arr - .map(fn) - .reverse() - .findIndex(el => (isDescending ? val <= el : val >= el)); - return index === -1 ? 0 : arr.length - index; - }; - const splitLines = str => str.split(/\r?\n/); + const forEachRight = (arr, callback) => + arr + .slice(0) + .reverse() + .forEach(callback); + const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj)); + const forOwnRight = (obj, fn) => + Object.keys(obj) + .reverse() + .forEach(key => fn(obj[key], key, obj)); + const formatDuration = ms => { + if (ms < 0) ms = -ms; + const time = { + day: Math.floor(ms / 86400000), + hour: Math.floor(ms / 3600000) % 24, + minute: Math.floor(ms / 60000) % 60, + second: Math.floor(ms / 1000) % 60, + millisecond: Math.floor(ms) % 1000 + }; + return Object.entries(time) + .filter(val => val[1] !== 0) + .map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`) + .join(', '); + }; + const fromCamelCase = (str, separator = '_') => + str + .replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2') + .replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2') + .toLowerCase(); + const functionName = fn => (console.debug(fn.name), fn); + const functions = (obj, inherited = false) => + (inherited + ? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))] + : Object.keys(obj) + ).filter(key => typeof obj[key] === 'function'); + const gcd = (...arr) => { + const _gcd = (x, y) => (!y ? x : gcd(y, x % y)); + return [...arr].reduce((a, b) => _gcd(a, b)); + }; + const geometricProgression = (end, start = 1, step = 2) => + Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map( + (v, i) => start * step ** i + ); + const get = (from, ...selectors) => + [...selectors].map(s => + s + .replace(/\[([^\[\]]*)\]/g, '.$1.') + .split('.') + .filter(t => t !== '') + .reduce((prev, cur) => prev && prev[cur], from) + ); + const getColonTimeFromDate = date => date.toTimeString().slice(0, 8); + const getDaysDiffBetweenDates = (dateInitial, dateFinal) => + (dateFinal - dateInitial) / (1000 * 3600 * 24); + const getImages = (el, includeDuplicates = false) => { + const images = [...el.getElementsByTagName('img')].map(img => img.getAttribute('src')); + return includeDuplicates ? images : [...new Set(images)]; + }; + const getMeridiemSuffixOfInteger = num => + num === 0 || num === 24 + ? 12 + 'am' + : num === 12 + ? 12 + 'pm' + : num < 12 + ? (num % 12) + 'am' + : (num % 12) + 'pm'; + const getScrollPosition = (el = window) => ({ + x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft, + y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop + }); + const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName]; + const getType = v => + v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase(); + const getURLParameters = url => + (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce( + (a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), + {} + ); + const groupBy = (arr, fn) => + arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => { + acc[val] = (acc[val] || []).concat(arr[i]); + return acc; + }, {}); + const hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length; + const hasClass = (el, className) => el.classList.contains(className); + const hasFlags = (...flags) => + flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag)); + const hashBrowser = val => + crypto.subtle.digest('SHA-256', new TextEncoder('utf-8').encode(val)).then(h => { + let hexes = [], + view = new DataView(h); + for (let i = 0; i < view.byteLength; i += 4) + hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8)); + return hexes.join(''); + }); + + const hashNode = val => + new Promise(resolve => + setTimeout( + () => + resolve( + crypto + .createHash('sha256') + .update(val) + .digest('hex') + ), + 0 + ) + ); + const head = arr => arr[0]; + const hexToRGB = hex => { + let alpha = false, + h = hex.slice(hex.startsWith('#') ? 1 : 0); + if (h.length === 3) h = [...h].map(x => x + x).join(''); + else if (h.length === 8) alpha = true; + h = parseInt(h, 16); + return ( + 'rgb' + + (alpha ? 'a' : '') + + '(' + + (h >>> (alpha ? 24 : 16)) + + ', ' + + ((h & (alpha ? 0x00ff0000 : 0x00ff00)) >>> (alpha ? 16 : 8)) + + ', ' + + ((h & (alpha ? 0x0000ff00 : 0x0000ff)) >>> (alpha ? 8 : 0)) + + (alpha ? `, ${h & 0x000000ff}` : '') + + ')' + ); + }; + const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); + const httpGet = (url, callback, err = console.error) => { + const request = new XMLHttpRequest(); + request.open('GET', url, true); + request.onload = () => callback(request.responseText); + request.onerror = () => err(request); + request.send(); + }; + const httpPost = (url, data, callback, err = console.error) => { + const request = new XMLHttpRequest(); + request.open('POST', url, true); + request.setRequestHeader('Content-type', 'application/json; charset=utf-8'); + request.onload = () => callback(request.responseText); + request.onerror = () => err(request); + request.send(data); + }; + const httpsRedirect = () => { + if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]); + }; + const hz = (fn, iterations = 100) => { + const before = performance.now(); + for (let i = 0; i < iterations; i++) fn(); + return (1000 * iterations) / (performance.now() - before); + }; + const inRange = (n, start, end = null) => { + if (end && start > end) [end, start] = [start, end]; + return end == null ? n >= 0 && n < start : n >= start && n < end; + }; + const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count)); + const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []); + const initial = arr => arr.slice(0, -1); + const initialize2DArray = (w, h, val = null) => + Array.from({ length: h }).map(() => Array.from({ length: w }).fill(val)); + const initializeArrayWithRange = (end, start = 0, step = 1) => + Array.from({ length: Math.ceil((end - start + 1) / step) }, (v, i) => i * step + start); + const initializeArrayWithRangeRight = (end, start = 0, step = 1) => + Array.from({ length: Math.ceil((end + 1 - start) / step) }).map( + (v, i, arr) => (arr.length - i - 1) * step + start + ); + const initializeArrayWithValues = (n, val = 0) => Array(n).fill(val); + const initializeNDArray = (val, ...args) => + args.length === 0 + ? val + : Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1))); + const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString); + const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString); + const intersection = (a, b) => { + const s = new Set(b); + return a.filter(x => s.has(x)); + }; + const intersectionBy = (a, b, fn) => { + const s = new Set(b.map(fn)); + return a.filter(x => s.has(fn(x))); + }; + const intersectionWith = (a, b, comp) => a.filter(x => b.findIndex(y => comp(x, y)) !== -1); + const invertKeyValues = (obj, fn) => + Object.keys(obj).reduce((acc, key) => { + const val = fn ? fn(obj[key]) : obj[key]; + acc[val] = acc[val] || []; + acc[val].push(key); + return acc; + }, {}); + const is = (type, val) => ![, null].includes(val) && val.constructor === type; + const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); + const isAfterDate = (dateA, dateB) => dateA > dateB; + const isAnagram = (str1, str2) => { + const normalize = str => + str + .toLowerCase() + .replace(/[^a-z0-9]/gi, '') + .split('') + .sort() + .join(''); + return normalize(str1) === normalize(str2); + }; + const isArrayLike = obj => obj != null && typeof obj[Symbol.iterator] === 'function'; + const isBeforeDate = (dateA, dateB) => dateA < dateB; + const isBoolean = val => typeof val === 'boolean'; + const isBrowser = () => ![typeof window, typeof document].includes('undefined'); + const isBrowserTabFocused = () => !document.hidden; + const isDivisible = (dividend, divisor) => dividend % divisor === 0; + const isDuplexStream = val => + val !== null && + typeof val === 'object' && + typeof val.pipe === 'function' && + typeof val._read === 'function' && + typeof val._readableState === 'object' && + typeof val._write === 'function' && + typeof val._writableState === 'object'; + const isEmpty = val => val == null || !(Object.keys(val) || val).length; + const isEven = num => num % 2 === 0; + const isFunction = val => typeof val === 'function'; + const isLowerCase = str => str === str.toLowerCase(); + const isNil = val => val === undefined || val === null; + const isNull = val => val === null; + const isNumber = val => typeof val === 'number'; + const isObject = obj => obj === Object(obj); + const isObjectLike = val => val !== null && typeof val === 'object'; + const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object; + const isPrime = num => { + const boundary = Math.floor(Math.sqrt(num)); + for (var i = 2; i <= boundary; i++) if (num % i === 0) return false; + return num >= 2; + }; + const isPrimitive = val => Object(val) !== val; + const isPromiseLike = obj => + obj !== null && + (typeof obj === 'object' || typeof obj === 'function') && + typeof obj.then === 'function'; + const isReadableStream = val => + val !== null && + typeof val === 'object' && + typeof val.pipe === 'function' && + typeof val._read === 'function' && + typeof val._readableState === 'object'; + const isSameDate = (dateA, dateB) => dateA.toISOString() === dateB.toISOString(); + const isSorted = arr => { + let direction = -(arr[0] - arr[1]); + for (let [i, val] of arr.entries()) { + direction = !direction ? -(arr[i - 1] - arr[i]) : direction; + if (i === arr.length - 1) return !direction ? 0 : direction; + else if ((val - arr[i + 1]) * direction > 0) return 0; + } + }; + const isStream = val => val !== null && typeof val === 'object' && typeof val.pipe === 'function'; + const isString = val => typeof val === 'string'; + const isSymbol = val => typeof val === 'symbol'; + const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; + const isUndefined = val => val === undefined; + const isUpperCase = str => str === str.toUpperCase(); + const isValidJSON = obj => { + try { + JSON.parse(obj); + return true; + } catch (e) { + return false; + } + }; + const isWritableStream = val => + val !== null && + typeof val === 'object' && + typeof val.pipe === 'function' && + typeof val._write === 'function' && + typeof val._writableState === 'object'; + const join = (arr, separator = ',', end = separator) => + arr.reduce( + (acc, val, i) => + i === arr.length - 2 + ? acc + val + end + : i === arr.length - 1 + ? acc + val + : acc + val + separator, + '' + ); + const last = arr => arr[arr.length - 1]; + const lcm = (...arr) => { + const gcd = (x, y) => (!y ? x : gcd(y, x % y)); + const _lcm = (x, y) => (x * y) / gcd(x, y); + return [...arr].reduce((a, b) => _lcm(a, b)); + }; + const longestItem = (...vals) => vals.reduce((a, x) => (x.length > a.length ? x : a)); + const lowercaseKeys = obj => + Object.keys(obj).reduce((acc, key) => { + acc[key.toLowerCase()] = obj[key]; + return acc; + }, {}); + const luhnCheck = num => { + let arr = (num + '') + .split('') + .reverse() + .map(x => parseInt(x)); + let lastDigit = arr.splice(0, 1)[0]; + let sum = arr.reduce((acc, val, i) => (i % 2 !== 0 ? acc + val : acc + ((val * 2) % 9) || 9), 0); + sum += lastDigit; + return sum % 10 === 0; + }; + const mapKeys = (obj, fn) => + Object.keys(obj).reduce((acc, k) => { + acc[fn(obj[k], k, obj)] = obj[k]; + return acc; + }, {}); + const mapObject = (arr, fn) => + (a => ( + (a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {}) + ))(); + const mapString = (str, fn) => + str + .split('') + .map((c, i) => fn(c, i, str)) + .join(''); + const mapValues = (obj, fn) => + Object.keys(obj).reduce((acc, k) => { + acc[k] = fn(obj[k], k, obj); + return acc; + }, {}); + const mask = (cc, num = 4, mask = '*') => `${cc}`.slice(-num).padStart(`${cc}`.length, mask); + const matches = (obj, source) => + Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]); + const matchesWith = (obj, source, fn) => + Object.keys(source).every( + key => + obj.hasOwnProperty(key) && fn + ? fn(obj[key], source[key], key, obj, source) + : obj[key] == source[key] + ); + const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); + const maxDate = (...dates) => new Date(Math.max.apply(null, ...dates)); + const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n); + const median = arr => { + const mid = Math.floor(arr.length / 2), + nums = [...arr].sort((a, b) => a - b); + return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2; + }; + const memoize = fn => { + const cache = new Map(); + const cached = function(val) { + return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val); + }; + cached.cache = cache; + return cached; + }; + const merge = (...objs) => + [...objs].reduce( + (acc, obj) => + Object.keys(obj).reduce((a, k) => { + acc[k] = acc.hasOwnProperty(k) ? [].concat(acc[k]).concat(obj[k]) : obj[k]; + return acc; + }, {}), + {} + ); + const minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); + const minDate = (...dates) => new Date(Math.min.apply(null, ...dates)); + const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n); + const mostPerformant = (fns, iterations = 10000) => { + const times = fns.map(fn => { + const before = performance.now(); + for (let i = 0; i < iterations; i++) fn(); + return performance.now() - before; + }); + return times.indexOf(Math.min(...times)); + }; + const negate = func => (...args) => !func(...args); + const nest = (items, id = null, link = 'parent_id') => + items + .filter(item => item[link] === id) + .map(item => ({ ...item, children: nest(items, item.id) })); + const nodeListToArray = nodeList => [...nodeList]; + const none = (arr, fn = Boolean) => !arr.some(fn); + const nthArg = n => (...args) => args.slice(n)[0]; + const nthElement = (arr, n = 0) => (n === -1 ? arr.slice(n) : arr.slice(n, n + 1))[0]; + const objectFromPairs = arr => arr.reduce((a, [key, val]) => ((a[key] = val), a), {}); + const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]); + const observeMutations = (element, callback, options) => { + const observer = new MutationObserver(mutations => mutations.forEach(m => callback(m))); + observer.observe( + element, + Object.assign( + { + childList: true, + attributes: true, + attributeOldValue: true, + characterData: true, + characterDataOldValue: true, + subtree: true + }, + options + ) + ); + return observer; + }; + const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts); + const offset = (arr, offset) => [...arr.slice(offset), ...arr.slice(0, offset)]; + const omit = (obj, arr) => + Object.keys(obj) + .filter(k => !arr.includes(k)) + .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); + const omitBy = (obj, fn) => + Object.keys(obj) + .filter(k => !fn(obj[k], k)) + .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); + const on = (el, evt, fn, opts = {}) => { + const delegatorFn = e => e.target.matches(opts.target) && fn.call(e.target, e); + el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false); + if (opts.target) return delegatorFn; + }; + const onUserInputChange = callback => { + let type = 'mouse', + lastTime = 0; + const mousemoveHandler = () => { + const now = performance.now(); + if (now - lastTime < 20) + (type = 'mouse'), callback(type), document.removeEventListener('mousemove', mousemoveHandler); + lastTime = now; + }; + document.addEventListener('touchstart', () => { + if (type === 'touch') return; + (type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler); + }); + }; + const once = fn => { + let called = false; + return function(...args) { + if (called) return; + called = true; + return fn.apply(this, args); + }; + }; + const orderBy = (arr, props, orders) => + [...arr].sort((a, b) => + props.reduce((acc, prop, i) => { + if (acc === 0) { + const [p1, p2] = orders && orders[i] === 'desc' ? [b[prop], a[prop]] : [a[prop], b[prop]]; + acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0; + } + return acc; + }, 0) + ); + const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args)); + const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val))); + const pad = (str, length, char = ' ') => + str.padStart((str.length + length) / 2, char).padEnd(length, char); + const palindrome = str => { + const s = str.toLowerCase().replace(/[\W_]/g, ''); + return s === [...s].reverse().join(''); + }; + const parseCookie = str => + str + .split(';') + .map(v => v.split('=')) + .reduce((acc, v) => { + acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim()); + return acc; + }, {}); + const partial = (fn, ...partials) => (...args) => fn(...partials, ...args); + const partialRight = (fn, ...partials) => (...args) => fn(...args, ...partials); + const partition = (arr, fn) => + arr.reduce( + (acc, val, i, arr) => { + acc[fn(val, i, arr) ? 0 : 1].push(val); + return acc; + }, + [[], []] + ); + const percentile = (arr, val) => + (100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0)) / arr.length; + const permutations = arr => { + if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr; + return arr.reduce( + (acc, item, i) => + acc.concat( + permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val => [item, ...val]) + ), + [] + ); + }; + const pick = (obj, arr) => + arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {}); + const pickBy = (obj, fn) => + Object.keys(obj) + .filter(k => fn(obj[k], k)) + .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); + const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg)); + const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); + const pluralize = (val, word, plural = word + 's') => { + const _pluralize = (num, word, plural = word + 's') => + [1, -1].includes(Number(num)) ? word : plural; + if (typeof val === 'object') return (num, word) => _pluralize(num, word, val[word]); + return _pluralize(val, word, plural); + }; + const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]); + const prefix = prop => { + const capitalizedProp = prop.charAt(0).toUpperCase() + prop.slice(1); + const prefixes = ['', 'webkit', 'moz', 'ms', 'o']; + const i = prefixes.findIndex( + prefix => typeof document.body.style[prefix ? prefix + capitalizedProp : prop] !== 'undefined' + ); + return i !== -1 ? (i === 0 ? prop : prefixes[i] + capitalizedProp) : null; + }; + const prettyBytes = (num, precision = 3, addSpace = true) => { + const UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + if (Math.abs(num) < 1) return num + (addSpace ? ' ' : '') + UNITS[0]; + const exponent = Math.min(Math.floor(Math.log10(num < 0 ? -num : num) / 3), UNITS.length - 1); + const n = Number(((num < 0 ? -num : num) / 1000 ** exponent).toPrecision(precision)); + return (num < 0 ? '-' : '') + n + (addSpace ? ' ' : '') + UNITS[exponent]; + }; + const primes = num => { + let arr = Array.from({ length: num - 1 }).map((x, i) => i + 2), + sqroot = Math.floor(Math.sqrt(num)), + numsTillSqroot = Array.from({ length: sqroot - 1 }).map((x, i) => i + 2); + numsTillSqroot.forEach(x => (arr = arr.filter(y => y % x !== 0 || y === x))); + return arr; + }; + const promisify = func => (...args) => + new Promise((resolve, reject) => + func(...args, (err, result) => (err ? reject(err) : resolve(result))) + ); + const pull = (arr, ...args) => { + let argState = Array.isArray(args[0]) ? args[0] : args; + let pulled = arr.filter((v, i) => !argState.includes(v)); + arr.length = 0; + pulled.forEach(v => arr.push(v)); + }; + const pullAtIndex = (arr, pullArr) => { + let removed = []; + let pulled = arr + .map((v, i) => (pullArr.includes(i) ? removed.push(v) : v)) + .filter((v, i) => !pullArr.includes(i)); + arr.length = 0; + pulled.forEach(v => arr.push(v)); + return removed; + }; + const pullAtValue = (arr, pullArr) => { + let removed = [], + pushToRemove = arr.forEach((v, i) => (pullArr.includes(v) ? removed.push(v) : v)), + mutateTo = arr.filter((v, i) => !pullArr.includes(v)); + arr.length = 0; + mutateTo.forEach(v => arr.push(v)); + return removed; + }; + const pullBy = (arr, ...args) => { + const length = args.length; + let fn = length > 1 ? args[length - 1] : undefined; + fn = typeof fn == 'function' ? (args.pop(), fn) : undefined; + let argState = (Array.isArray(args[0]) ? args[0] : args).map(val => fn(val)); + let pulled = arr.filter((v, i) => !argState.includes(fn(v))); + arr.length = 0; + pulled.forEach(v => arr.push(v)); + }; + const radsToDegrees = rad => (rad * 180.0) / Math.PI; + const randomHexColorCode = () => { + let n = (Math.random() * 0xfffff * 1000000).toString(16); + return '#' + n.slice(0, 6); + }; + const randomIntArrayInRange = (min, max, n = 1) => + Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min); + const randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; + const randomNumberInRange = (min, max) => Math.random() * (max - min) + min; + + const readFileLines = filename => + fs + .readFileSync(filename) + .toString('UTF8') + .split('\n'); + const rearg = (fn, indexes) => (...args) => fn(...indexes.map(i => args[i])); + const recordAnimationFrames = (callback, autoStart = true) => { + let running = true, + raf; + const stop = () => { + running = false; + cancelAnimationFrame(raf); + }; + const start = () => { + running = true; + run(); + }; + const run = () => { + raf = requestAnimationFrame(() => { + callback(); + if (running) run(); + }); + }; + if (autoStart) start(); + return { start, stop }; + }; + const redirect = (url, asLink = true) => + asLink ? (window.location.href = url) : window.location.replace(url); + const reduceSuccessive = (arr, fn, acc) => + arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]); + const reduceWhich = (arr, comparator = (a, b) => a - b) => + arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a)); + const reducedFilter = (data, keys, fn) => + data.filter(fn).map(el => + keys.reduce((acc, key) => { + acc[key] = el[key]; + return acc; + }, {}) + ); + const reject = (pred, array) => array.filter((...args) => !pred(...args)); + const remove = (arr, func) => + Array.isArray(arr) + ? arr.filter(func).reduce((acc, val) => { + arr.splice(arr.indexOf(val), 1); + return acc.concat(val); + }, []) + : []; + const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, ''); + const renameKeys = (keysMap, obj) => + Object.keys(obj).reduce( + (acc, key) => ({ + ...acc, + ...{ [keysMap[key] || key]: obj[key] } + }), + {} + ); + const reverseString = str => [...str].reverse().join(''); + const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`); + const runAsync = fn => { + const worker = new Worker( + URL.createObjectURL(new Blob([`postMessage((${fn})());`]), { + type: 'application/javascript; charset=utf-8' + }) + ); + return new Promise((res, rej) => { + worker.onmessage = ({ data }) => { + res(data), worker.terminate(); + }; + worker.onerror = err => { + rej(err), worker.terminate(); + }; + }); + }; + const runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.resolve()); + const sample = arr => arr[Math.floor(Math.random() * arr.length)]; + const sampleSize = ([...arr], n = 1) => { + let m = arr.length; + while (m) { + const i = Math.floor(Math.random() * m--); + [arr[m], arr[i]] = [arr[i], arr[m]]; + } + return arr.slice(0, n); + }; + const scrollToTop = () => { + const c = document.documentElement.scrollTop || document.body.scrollTop; + if (c > 0) { + window.requestAnimationFrame(scrollToTop); + window.scrollTo(0, c - c / 8); + } + }; + const sdbm = str => { + let arr = str.split(''); + return arr.reduce( + (hashCode, currentVal) => + (hashCode = currentVal.charCodeAt(0) + (hashCode << 6) + (hashCode << 16) - hashCode), + 0 + ); + }; + const serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`; + const setStyle = (el, ruleName, val) => (el.style[ruleName] = val); + const shallowClone = obj => Object.assign({}, obj); + const shank = (arr, index = 0, delCount = 0, ...elements) => + arr + .slice(0, index) + .concat(elements) + .concat(arr.slice(index + delCount)); + const show = (...el) => [...el].forEach(e => (e.style.display = '')); + const shuffle = ([...arr]) => { + let m = arr.length; + while (m) { + const i = Math.floor(Math.random() * m--); + [arr[m], arr[i]] = [arr[i], arr[m]]; + } + return arr; + }; + const similarity = (arr, values) => arr.filter(v => values.includes(v)); + const size = val => + Array.isArray(val) + ? val.length + : val && typeof val === 'object' + ? val.size || val.length || Object.keys(val).length + : typeof val === 'string' + ? new Blob([val]).size + : 0; + const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); + const smoothScroll = element => + document.querySelector(element).scrollIntoView({ + behavior: 'smooth' + }); + const sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join(''); + const sortedIndex = (arr, n) => { + const isDescending = arr[0] > arr[arr.length - 1]; + const index = arr.findIndex(el => (isDescending ? n >= el : n <= el)); + return index === -1 ? arr.length : index; + }; + const sortedIndexBy = (arr, n, fn) => { + const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]); + const val = fn(n); + const index = arr.findIndex(el => (isDescending ? val >= fn(el) : val <= fn(el))); + return index === -1 ? arr.length : index; + }; + const sortedLastIndex = (arr, n) => { + const isDescending = arr[0] > arr[arr.length - 1]; + const index = arr.reverse().findIndex(el => (isDescending ? n <= el : n >= el)); + return index === -1 ? 0 : arr.length - index; + }; + const sortedLastIndexBy = (arr, n, fn) => { + const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]); + const val = fn(n); + const index = arr + .map(fn) + .reverse() + .findIndex(el => (isDescending ? val <= el : val >= el)); + return index === -1 ? 0 : arr.length - index; + }; + const splitLines = str => str.split(/\r?\n/); const spreadOver = fn => argsArr => fn(...argsArr); - const stableSort = (arr, compare) => - arr - .map((item, index) => ({ item, index })) - .sort((a, b) => compare(a.item, b.item) || a.index - b.index) - .map(({ item }) => item); - const standardDeviation = (arr, usePopulation = false) => { - const mean = arr.reduce((acc, val) => acc + val, 0) / arr.length; - return Math.sqrt( - arr.reduce((acc, val) => acc.concat((val - mean) ** 2), []).reduce((acc, val) => acc + val, 0) / - (arr.length - (usePopulation ? 0 : 1)) - ); - }; - const stringPermutations = str => { - if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str]; - return str - .split('') - .reduce( - (acc, letter, i) => - acc.concat(stringPermutations(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)), - [] - ); - }; - const stripHTMLTags = str => str.replace(/<[^>]*>/g, ''); - const sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0); - const sumBy = (arr, fn) => - arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0); - const sumPower = (end, power = 2, start = 1) => - Array(end + 1 - start) - .fill(0) - .map((x, i) => (i + start) ** power) - .reduce((a, b) => a + b, 0); - const symmetricDifference = (a, b) => { - const sA = new Set(a), - sB = new Set(b); - return [...a.filter(x => !sB.has(x)), ...b.filter(x => !sA.has(x))]; - }; - const symmetricDifferenceBy = (a, b, fn) => { - const sA = new Set(a.map(v => fn(v))), - sB = new Set(b.map(v => fn(v))); - return [...a.filter(x => !sB.has(fn(x))), ...b.filter(x => !sA.has(fn(x)))]; - }; - const symmetricDifferenceWith = (arr, val, comp) => [ - ...arr.filter(a => val.findIndex(b => comp(a, b)) === -1), - ...val.filter(a => arr.findIndex(b => comp(a, b)) === -1) - ]; - const tail = arr => (arr.length > 1 ? arr.slice(1) : arr); - const take = (arr, n = 1) => arr.slice(0, n); - const takeRight = (arr, n = 1) => arr.slice(arr.length - n, arr.length); - const takeRightWhile = (arr, func) => - arr.reduceRight((acc, el) => (func(el) ? acc : [el, ...acc]), []); - const takeWhile = (arr, func) => { - for (const [i, val] of arr.entries()) if (func(val)) return arr.slice(0, i); - return arr; - }; - const throttle = (fn, wait) => { - let inThrottle, lastFn, lastTime; - return function() { - const context = this, - args = arguments; - if (!inThrottle) { - fn.apply(context, args); - lastTime = Date.now(); - inThrottle = true; - } else { - clearTimeout(lastFn); - lastFn = setTimeout(function() { - if (Date.now() - lastTime >= wait) { - fn.apply(context, args); - lastTime = Date.now(); - } - }, Math.max(wait - (Date.now() - lastTime), 0)); - } - }; - }; - const times = (n, fn, context = undefined) => { - let i = 0; - while (fn.call(context, i) !== false && ++i < n) {} - }; - const timeTaken = callback => { - console.time('timeTaken'); - const r = callback(); - console.timeEnd('timeTaken'); - return r; - }; - const toCamelCase = str => { - let s = - str && - str - .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) - .map(x => x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase()) - .join(''); - return s.slice(0, 1).toLowerCase() + s.slice(1); - }; - const toCurrency = (n, curr, LanguageFormat = undefined) => - Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n); - const toDecimalMark = num => num.toLocaleString('en-US'); - const toggleClass = (el, className) => el.classList.toggle(className); - const toHash = (object, key) => - Array.prototype.reduce.call( - object, - (acc, data, index) => ((acc[!key ? index : data[key]] = data), acc), - {} - ); - const toKebabCase = str => - str && - str - .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) - .map(x => x.toLowerCase()) - .join('-'); - const tomorrow = (long = false) => { - let t = new Date(); - t.setDate(t.getDate() + 1); - const ret = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String( - t.getDate() - ).padStart(2, '0')}`; - return !long ? ret : `${ret}T00:00:00`; - }; - const toOrdinalSuffix = num => { - const int = parseInt(num), - digits = [int % 10, int % 100], - ordinals = ['st', 'nd', 'rd', 'th'], - oPattern = [1, 2, 3, 4], - tPattern = [11, 12, 13, 14, 15, 16, 17, 18, 19]; - return oPattern.includes(digits[0]) && !tPattern.includes(digits[1]) - ? int + ordinals[digits[0] - 1] - : int + ordinals[3]; - }; - const toSafeInteger = num => - Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER)); - const toSnakeCase = str => - str && - str - .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) - .map(x => x.toLowerCase()) - .join('_'); - const toTitleCase = str => - str - .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) - .map(x => x.charAt(0).toUpperCase() + x.slice(1)) - .join(' '); - const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc); - const triggerEvent = (el, eventType, detail) => - el.dispatchEvent(new CustomEvent(eventType, { detail })); - const truncateString = (str, num) => - str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str; - const truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]); - const unary = fn => val => fn(val); - const uncurry = (fn, n = 1) => (...args) => { - const next = acc => args => args.reduce((x, y) => x(y), acc); - if (n > args.length) throw new RangeError('Arguments too few!'); - return next(fn)(args.slice(0, n)); - }; - const unescapeHTML = str => - str.replace( - /&|<|>|'|"/g, - tag => - ({ - '&': '&', - '<': '<', - '>': '>', - ''': "'", - '"': '"' - }[tag] || tag) - ); - const unflattenObject = obj => - Object.keys(obj).reduce((acc, k) => { - if (k.indexOf('.') !== -1) { - const keys = k.split('.'); - Object.assign( - acc, - JSON.parse( - '{' + - keys.map((v, i) => (i !== keys.length - 1 ? `"${v}":{` : `"${v}":`)).join('') + - obj[k] + - '}'.repeat(keys.length) - ) - ); - } else acc[k] = obj[k]; - return acc; - }, {}); - const unfold = (fn, seed) => { - let result = [], - val = [null, seed]; - while ((val = fn(val[1]))) result.push(val[0]); - return result; - }; - const union = (a, b) => Array.from(new Set([...a, ...b])); - const unionBy = (a, b, fn) => { - const s = new Set(a.map(fn)); - return Array.from(new Set([...a, ...b.filter(x => !s.has(fn(x)))])); - }; - const unionWith = (a, b, comp) => - Array.from(new Set([...a, ...b.filter(x => a.findIndex(y => comp(x, y)) === -1)])); - const uniqueElements = arr => [...new Set(arr)]; - const uniqueElementsBy = (arr, fn) => - arr.reduce((acc, v) => { - if (!acc.some(x => fn(v, x))) acc.push(v); - return acc; - }, []); - const uniqueElementsByRight = (arr, fn) => - arr.reduceRight((acc, v) => { - if (!acc.some(x => fn(v, x))) acc.push(v); - return acc; - }, []); - const uniqueSymmetricDifference = (a, b) => [ - ...new Set([...a.filter(v => !b.includes(v)), ...b.filter(v => !a.includes(v))]) - ]; - const untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`); - const unzip = arr => - arr.reduce( - (acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc), - Array.from({ - length: Math.max(...arr.map(x => x.length)) - }).map(x => []) - ); - const unzipWith = (arr, fn) => - arr - .reduce( - (acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc), - Array.from({ - length: Math.max(...arr.map(x => x.length)) - }).map(x => []) - ) - .map(val => fn(...val)); - const URLJoin = (...args) => - args - .join('/') - .replace(/[\/]+/g, '/') - .replace(/^(.+):\//, '$1://') - .replace(/^file:/, 'file:/') - .replace(/\/(\?|&|#[^!])/g, '$1') - .replace(/\?/g, '&') - .replace('&', '?'); - const UUIDGeneratorBrowser = () => - ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => - (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16) - ); - - const UUIDGeneratorNode = () => - ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => - (c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16) - ); - const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; - const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x); - const without = (arr, ...args) => arr.filter(v => !args.includes(v)); - const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); - const xProd = (a, b) => a.reduce((acc, x) => acc.concat(b.map(y => [x, y])), []); - const yesNo = (val, def = false) => - /^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def; - const zip = (...arrays) => { - const maxLength = Math.max(...arrays.map(x => x.length)); - return Array.from({ length: maxLength }).map((_, i) => { - return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]); - }); - }; - const zipObject = (props, values) => - props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {}); - const zipWith = (...array) => { - const fn = typeof array[array.length - 1] === 'function' ? array.pop() : undefined; - return Array.from( - { length: Math.max(...array.map(a => a.length)) }, - (_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i])) - ); - }; + const stableSort = (arr, compare) => + arr + .map((item, index) => ({ item, index })) + .sort((a, b) => compare(a.item, b.item) || a.index - b.index) + .map(({ item }) => item); + const standardDeviation = (arr, usePopulation = false) => { + const mean = arr.reduce((acc, val) => acc + val, 0) / arr.length; + return Math.sqrt( + arr.reduce((acc, val) => acc.concat((val - mean) ** 2), []).reduce((acc, val) => acc + val, 0) / + (arr.length - (usePopulation ? 0 : 1)) + ); + }; + const stringPermutations = str => { + if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str]; + return str + .split('') + .reduce( + (acc, letter, i) => + acc.concat(stringPermutations(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)), + [] + ); + }; + const stripHTMLTags = str => str.replace(/<[^>]*>/g, ''); + const sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0); + const sumBy = (arr, fn) => + arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0); + const sumPower = (end, power = 2, start = 1) => + Array(end + 1 - start) + .fill(0) + .map((x, i) => (i + start) ** power) + .reduce((a, b) => a + b, 0); + const symmetricDifference = (a, b) => { + const sA = new Set(a), + sB = new Set(b); + return [...a.filter(x => !sB.has(x)), ...b.filter(x => !sA.has(x))]; + }; + const symmetricDifferenceBy = (a, b, fn) => { + const sA = new Set(a.map(v => fn(v))), + sB = new Set(b.map(v => fn(v))); + return [...a.filter(x => !sB.has(fn(x))), ...b.filter(x => !sA.has(fn(x)))]; + }; + const symmetricDifferenceWith = (arr, val, comp) => [ + ...arr.filter(a => val.findIndex(b => comp(a, b)) === -1), + ...val.filter(a => arr.findIndex(b => comp(a, b)) === -1) + ]; + const tail = arr => (arr.length > 1 ? arr.slice(1) : arr); + const take = (arr, n = 1) => arr.slice(0, n); + const takeRight = (arr, n = 1) => arr.slice(arr.length - n, arr.length); + const takeRightWhile = (arr, func) => + arr.reduceRight((acc, el) => (func(el) ? acc : [el, ...acc]), []); + const takeWhile = (arr, func) => { + for (const [i, val] of arr.entries()) if (func(val)) return arr.slice(0, i); + return arr; + }; + const throttle = (fn, wait) => { + let inThrottle, lastFn, lastTime; + return function() { + const context = this, + args = arguments; + if (!inThrottle) { + fn.apply(context, args); + lastTime = Date.now(); + inThrottle = true; + } else { + clearTimeout(lastFn); + lastFn = setTimeout(function() { + if (Date.now() - lastTime >= wait) { + fn.apply(context, args); + lastTime = Date.now(); + } + }, Math.max(wait - (Date.now() - lastTime), 0)); + } + }; + }; + const timeTaken = callback => { + console.time('timeTaken'); + const r = callback(); + console.timeEnd('timeTaken'); + return r; + }; + const times = (n, fn, context = undefined) => { + let i = 0; + while (fn.call(context, i) !== false && ++i < n) {} + }; + const toCamelCase = str => { + let s = + str && + str + .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) + .map(x => x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase()) + .join(''); + return s.slice(0, 1).toLowerCase() + s.slice(1); + }; + const toCurrency = (n, curr, LanguageFormat = undefined) => + Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n); + const toDecimalMark = num => num.toLocaleString('en-US'); + const toHash = (object, key) => + Array.prototype.reduce.call( + object, + (acc, data, index) => ((acc[!key ? index : data[key]] = data), acc), + {} + ); + const toKebabCase = str => + str && + str + .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) + .map(x => x.toLowerCase()) + .join('-'); + const toOrdinalSuffix = num => { + const int = parseInt(num), + digits = [int % 10, int % 100], + ordinals = ['st', 'nd', 'rd', 'th'], + oPattern = [1, 2, 3, 4], + tPattern = [11, 12, 13, 14, 15, 16, 17, 18, 19]; + return oPattern.includes(digits[0]) && !tPattern.includes(digits[1]) + ? int + ordinals[digits[0] - 1] + : int + ordinals[3]; + }; + const toSafeInteger = num => + Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER)); + const toSnakeCase = str => + str && + str + .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) + .map(x => x.toLowerCase()) + .join('_'); + const toTitleCase = str => + str + .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) + .map(x => x.charAt(0).toUpperCase() + x.slice(1)) + .join(' '); + const toggleClass = (el, className) => el.classList.toggle(className); + const tomorrow = (long = false) => { + let t = new Date(); + t.setDate(t.getDate() + 1); + const ret = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String( + t.getDate() + ).padStart(2, '0')}`; + return !long ? ret : `${ret}T00:00:00`; + }; + const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc); + const triggerEvent = (el, eventType, detail) => + el.dispatchEvent(new CustomEvent(eventType, { detail })); + const truncateString = (str, num) => + str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str; + const truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]); + const unary = fn => val => fn(val); + const uncurry = (fn, n = 1) => (...args) => { + const next = acc => args => args.reduce((x, y) => x(y), acc); + if (n > args.length) throw new RangeError('Arguments too few!'); + return next(fn)(args.slice(0, n)); + }; + const unescapeHTML = str => + str.replace( + /&|<|>|'|"/g, + tag => + ({ + '&': '&', + '<': '<', + '>': '>', + ''': "'", + '"': '"' + }[tag] || tag) + ); + const unflattenObject = obj => + Object.keys(obj).reduce((acc, k) => { + if (k.indexOf('.') !== -1) { + const keys = k.split('.'); + Object.assign( + acc, + JSON.parse( + '{' + + keys.map((v, i) => (i !== keys.length - 1 ? `"${v}":{` : `"${v}":`)).join('') + + obj[k] + + '}'.repeat(keys.length) + ) + ); + } else acc[k] = obj[k]; + return acc; + }, {}); + const unfold = (fn, seed) => { + let result = [], + val = [null, seed]; + while ((val = fn(val[1]))) result.push(val[0]); + return result; + }; + const union = (a, b) => Array.from(new Set([...a, ...b])); + const unionBy = (a, b, fn) => { + const s = new Set(a.map(fn)); + return Array.from(new Set([...a, ...b.filter(x => !s.has(fn(x)))])); + }; + const unionWith = (a, b, comp) => + Array.from(new Set([...a, ...b.filter(x => a.findIndex(y => comp(x, y)) === -1)])); + const uniqueElements = arr => [...new Set(arr)]; + const uniqueElementsBy = (arr, fn) => + arr.reduce((acc, v) => { + if (!acc.some(x => fn(v, x))) acc.push(v); + return acc; + }, []); + const uniqueElementsByRight = (arr, fn) => + arr.reduceRight((acc, v) => { + if (!acc.some(x => fn(v, x))) acc.push(v); + return acc; + }, []); + const uniqueSymmetricDifference = (a, b) => [ + ...new Set([...a.filter(v => !b.includes(v)), ...b.filter(v => !a.includes(v))]) + ]; + const untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`); + const unzip = arr => + arr.reduce( + (acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc), + Array.from({ + length: Math.max(...arr.map(x => x.length)) + }).map(x => []) + ); + const unzipWith = (arr, fn) => + arr + .reduce( + (acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc), + Array.from({ + length: Math.max(...arr.map(x => x.length)) + }).map(x => []) + ) + .map(val => fn(...val)); + const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; + const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x); + const without = (arr, ...args) => arr.filter(v => !args.includes(v)); + const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); + const xProd = (a, b) => a.reduce((acc, x) => acc.concat(b.map(y => [x, y])), []); + const yesNo = (val, def = false) => + /^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def; + const zip = (...arrays) => { + const maxLength = Math.max(...arrays.map(x => x.length)); + return Array.from({ length: maxLength }).map((_, i) => { + return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]); + }); + }; + const zipObject = (props, values) => + props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {}); + const zipWith = (...array) => { + const fn = typeof array[array.length - 1] === 'function' ? array.pop() : undefined; + return Array.from( + { length: Math.max(...array.map(a => a.length)) }, + (_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i])) + ); + }; - module.exports = {all,allEqual,any,approximatelyEqual,arrayToCSV,arrayToHtmlList,ary,atob,attempt,average,averageBy,bifurcate,bifurcateBy,bind,bindAll,bindKey,binomialCoefficient,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,composeRight,converge,copyToClipboard,countBy,counter,countOccurrences,createElement,createEventHub,CSVToArray,CSVToJSON,currentURL,curry,dayOfYear,debounce,decapitalize,deepClone,deepFlatten,deepFreeze,defaults,defer,degreesToRads,delay,detectDeviceType,difference,differenceBy,differenceWith,dig,digitize,distance,drop,dropRight,dropRightWhile,dropWhile,elementContains,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,filterNonUniqueBy,findKey,findLast,findLastIndex,findLastKey,flatten,flattenObject,flip,forEachRight,formatDuration,forOwn,forOwnRight,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getColonTimeFromDate,getDaysDiffBetweenDates,getImages,getMeridiemSuffixOfInteger,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,hz,indentString,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,initializeNDArray,inRange,insertAfter,insertBefore,intersection,intersectionBy,intersectionWith,invertKeyValues,is,isAbsoluteURL,isAfterDate,isAnagram,isArrayLike,isBeforeDate,isBoolean,isBrowser,isBrowserTabFocused,isDivisible,isDuplexStream,isEmpty,isEven,isFunction,isLowerCase,isNil,isNull,isNumber,isObject,isObjectLike,isPlainObject,isPrime,isPrimitive,isPromiseLike,isReadableStream,isSameDate,isSorted,isStream,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,isWritableStream,join,JSONtoCSV,JSONToFile,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapString,mapValues,mask,matches,matchesWith,maxBy,maxDate,maxN,median,memoize,merge,minBy,minDate,minN,mostPerformant,negate,nest,nodeListToArray,none,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,offset,omit,omitBy,on,once,onUserInputChange,orderBy,over,overArgs,pad,palindrome,parseCookie,partial,partialRight,partition,percentile,permutations,pick,pickBy,pipeAsyncFunctions,pipeFunctions,pluralize,powerset,prefix,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,radsToDegrees,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,rearg,recordAnimationFrames,redirect,reducedFilter,reduceSuccessive,reduceWhich,reject,remove,removeNonASCII,renameKeys,reverseString,RGBToHex,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,setStyle,shallowClone,shank,show,shuffle,similarity,size,sleep,smoothScroll,sortCharactersInString,sortedIndex,sortedIndexBy,sortedLastIndex,sortedLastIndexBy,splitLines,spreadOver,stableSort,standardDeviation,stringPermutations,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,times,timeTaken,toCamelCase,toCurrency,toDecimalMark,toggleClass,toHash,toKebabCase,tomorrow,toOrdinalSuffix,toSafeInteger,toSnakeCase,toTitleCase,transform,triggerEvent,truncateString,truthCheckCollection,unary,uncurry,unescapeHTML,unflattenObject,unfold,union,unionBy,unionWith,uniqueElements,uniqueElementsBy,uniqueElementsByRight,uniqueSymmetricDifference,untildify,unzip,unzipWith,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,validateNumber,when,without,words,xProd,yesNo,zip,zipObject,zipWith}; + module.exports = {CSVToArray,CSVToJSON,JSONToFile,JSONtoCSV,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,all,allEqual,any,approximatelyEqual,arrayToCSV,arrayToHtmlList,ary,atob,attempt,average,averageBy,bifurcate,bifurcateBy,bind,bindAll,bindKey,binomialCoefficient,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,composeRight,converge,copyToClipboard,countBy,countOccurrences,counter,createElement,createEventHub,currentURL,curry,dayOfYear,debounce,decapitalize,deepClone,deepFlatten,deepFreeze,defaults,defer,degreesToRads,delay,detectDeviceType,difference,differenceBy,differenceWith,dig,digitize,distance,drop,dropRight,dropRightWhile,dropWhile,elementContains,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,filterNonUniqueBy,findKey,findLast,findLastIndex,findLastKey,flatten,flattenObject,flip,forEachRight,forOwn,forOwnRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getColonTimeFromDate,getDaysDiffBetweenDates,getImages,getMeridiemSuffixOfInteger,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,hz,inRange,indentString,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,initializeNDArray,insertAfter,insertBefore,intersection,intersectionBy,intersectionWith,invertKeyValues,is,isAbsoluteURL,isAfterDate,isAnagram,isArrayLike,isBeforeDate,isBoolean,isBrowser,isBrowserTabFocused,isDivisible,isDuplexStream,isEmpty,isEven,isFunction,isLowerCase,isNil,isNull,isNumber,isObject,isObjectLike,isPlainObject,isPrime,isPrimitive,isPromiseLike,isReadableStream,isSameDate,isSorted,isStream,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,isWritableStream,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapString,mapValues,mask,matches,matchesWith,maxBy,maxDate,maxN,median,memoize,merge,minBy,minDate,minN,mostPerformant,negate,nest,nodeListToArray,none,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,offset,omit,omitBy,on,onUserInputChange,once,orderBy,over,overArgs,pad,palindrome,parseCookie,partial,partialRight,partition,percentile,permutations,pick,pickBy,pipeAsyncFunctions,pipeFunctions,pluralize,powerset,prefix,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,radsToDegrees,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,rearg,recordAnimationFrames,redirect,reduceSuccessive,reduceWhich,reducedFilter,reject,remove,removeNonASCII,renameKeys,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,setStyle,shallowClone,shank,show,shuffle,similarity,size,sleep,smoothScroll,sortCharactersInString,sortedIndex,sortedIndexBy,sortedLastIndex,sortedLastIndexBy,splitLines,spreadOver,stableSort,standardDeviation,stringPermutations,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,timeTaken,times,toCamelCase,toCurrency,toDecimalMark,toHash,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toTitleCase,toggleClass,tomorrow,transform,triggerEvent,truncateString,truthCheckCollection,unary,uncurry,unescapeHTML,unflattenObject,unfold,union,unionBy,unionWith,uniqueElements,uniqueElementsBy,uniqueElementsByRight,uniqueSymmetricDifference,untildify,unzip,unzipWith,validateNumber,when,without,words,xProd,yesNo,zip,zipObject,zipWith}; }))); diff --git a/snippet_data/snippetList.json b/snippet_data/snippetList.json index 745e5f6b6aa..e46df3f5111 100644 --- a/snippet_data/snippetList.json +++ b/snippet_data/snippetList.json @@ -1664,7 +1664,7 @@ "archived": false }, "meta": { - "hash": "8b7b70809f93fd9392315a5c63aa4cbbf9b45eb1165a7d44db314186d407816b" + "hash": "40558410bed6e9e2866362dc86898fd28a97073f798d8dd5c566eea2ccec2f8f" } }, { @@ -4414,7 +4414,7 @@ "archived": false }, "meta": { - "hash": "c7a62b55b5a90661bf3f9c956f075906439a50151a3aee4023ad8fe878cae2e6" + "hash": "2fd449a2a993bdbc2b93d185ef09aea72af7845152de46d6050db82efe912130" } }, { diff --git a/snippet_data/snippets.json b/snippet_data/snippets.json index a3f1c384759..6cfb993e198 100644 --- a/snippet_data/snippets.json +++ b/snippet_data/snippets.json @@ -2443,8 +2443,8 @@ "fileName": "hide.md", "text": "Hides all the elements specified.\n\nUse `NodeList.prototype.forEach()` to apply `display: none` to each element specified.", "codeBlocks": { - "es6": "const hide = els => els.forEach(e => (e.style.display = 'none'));", - "es5": "var hide = function hide(els) {\n return els.forEach(function (e) {\n return e.style.display = 'none';\n });\n};", + "es6": "const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));", + "es5": "var hide = function hide() {\n for (var _len = arguments.length, el = new Array(_len), _key = 0; _key < _len; _key++) {\n el[_key] = arguments[_key];\n }\n\n return el.concat().forEach(function (e) {\n return e.style.display = 'none';\n });\n};", "example": "hide(document.querySelectorAll('img')); // Hides all elements on the page" }, "tags": [ @@ -2455,7 +2455,7 @@ }, "meta": { "archived": false, - "hash": "8b7b70809f93fd9392315a5c63aa4cbbf9b45eb1165a7d44db314186d407816b" + "hash": "40558410bed6e9e2866362dc86898fd28a97073f798d8dd5c566eea2ccec2f8f" } }, { @@ -6491,7 +6491,7 @@ "codeBlocks": { "es6": "const toHash = (object, key) =>\n Array.prototype.reduce.call(\n object,\n (acc, data, index) => ((acc[!key ? index : data[key]] = data), acc),\n {}\n );", "es5": "var toHash = function toHash(object, key) {\n return Array.prototype.reduce.call(object, function (acc, data, index) {\n return acc[!key ? index : data[key]] = data, acc;\n }, {});\n};", - "example": "toHash([4, 3, 2, 1]); // { 0: 4, 1: 3, 2: 2, 1: 1 }\ntoHash([{ a: 'label' }], 'a'); // { label: { a: 'label' } }\n// A more in depth example:\nlet users = [{ id: 1, first: 'Jon' }, { id: 2, first: 'Joe' }, { id: 3, first: 'Moe' }];\nlet managers = [{ manager: 1, employees: [2, 3] }];\n// We use function here because we want a bindable reference, but a closure referencing the hash would work, too.\nmanagers.forEach(\n manager =>\n (manager.employees = manager.employees.map(function(id) {\n return this[id];\n }, toHash(users, 'id')))\n);\nmanagers; // [ { manager:1, employees: [ { id: 2, first: \"Joe\" }, { id: 3, first: \"Moe\" } ] } ]" + "example": "toHash([4, 3, 2, 1]); // { 0: 4, 1: 3, 2: 2, 3: 1 }\ntoHash([{ a: 'label' }], 'a'); // { label: { a: 'label' } }\n// A more in depth example:\nlet users = [{ id: 1, first: 'Jon' }, { id: 2, first: 'Joe' }, { id: 3, first: 'Moe' }];\nlet managers = [{ manager: 1, employees: [2, 3] }];\n// We use function here because we want a bindable reference, but a closure referencing the hash would work, too.\nmanagers.forEach(\n manager =>\n (manager.employees = manager.employees.map(function(id) {\n return this[id];\n }, toHash(users, 'id')))\n);\nmanagers; // [ { manager:1, employees: [ { id: 2, first: \"Joe\" }, { id: 3, first: \"Moe\" } ] } ]" }, "tags": [ "array", @@ -6500,7 +6500,7 @@ }, "meta": { "archived": false, - "hash": "c7a62b55b5a90661bf3f9c956f075906439a50151a3aee4023ad8fe878cae2e6" + "hash": "2fd449a2a993bdbc2b93d185ef09aea72af7845152de46d6050db82efe912130" } }, { diff --git a/test/testlog b/test/testlog index a63029f3b33..1525afef541 100644 --- a/test/testlog +++ b/test/testlog @@ -404,1879 +404,1924 @@ ok 306 — Offset greater than the length of the array returns the same array. ok 307 — Offset less than the negative length of the array returns the same array. ok 308 — Offsetting empty array returns an empty array. -# PASS test/binomialCoefficient.test.js +# PASS test/off.test.js -ok 309 — binomialCoefficient is a Function -ok 310 — Returns the appropriate value -ok 311 — Returns the appropriate value -ok 312 — Returns the appropriate value -ok 313 — Returns the appropriate value -ok 314 — Returns the appropriate value -ok 315 — Returns NaN -ok 316 — Returns NaN +ok 309 — off is a Function +ok 310 — off removes an event listener +ok 311 — off removes an event listener # PASS test/pluralize.test.js -ok 317 — pluralize is a Function -ok 318 — Produces the plural of the word -ok 319 — Produces the singular of the word -ok 320 — Produces the plural of the word -ok 321 — Prodices the defined plural of the word -ok 322 — Works with a dictionary +ok 312 — pluralize is a Function +ok 313 — Produces the plural of the word +ok 314 — Produces the singular of the word +ok 315 — Produces the plural of the word +ok 316 — Produces the defined plural of the word +ok 317 — Produces the defined plural of the word +ok 318 — Works with a dictionary + +# PASS test/on.test.js + +ok 319 — on is a Function +ok 320 — on creates an event listener +ok 321 — on creates an event listener + +# PASS test/binomialCoefficient.test.js + +ok 322 — binomialCoefficient is a Function +ok 323 — Returns the appropriate value +ok 324 — Returns the appropriate value +ok 325 — Returns the appropriate value +ok 326 — Returns the appropriate value +ok 327 — Returns the appropriate value +ok 328 — Returns NaN +ok 329 — Returns NaN + +# PASS test/copyToClipboard.test.js + +ok 330 — copyToClipboard is a Function +ok 331 — copyToClipboard does not throw errors +ok 332 — copyToClipboard does not throw errors + +# PASS test/prettyBytes.test.js + +ok 333 — prettyBytes is a Function +ok 334 — Converts a number in bytes to a human-readable string. +ok 335 — Converts a number in bytes to a human-readable string. +ok 336 — Converts a number in bytes to a human-readable string. +ok 337 — Converts a number in bytes to a human-readable string. +ok 338 — Converts a number in bytes to a human-readable string. # PASS test/randomIntArrayInRange.test.js -ok 323 — randomIntArrayInRange is a Function -ok 324 — The returned array contains only integers -ok 325 — The returned array has the proper length -ok 326 — The returned array's values lie between provided lowerLimit and upperLimit (both inclusive). +ok 339 — randomIntArrayInRange is a Function +ok 340 — The returned array contains only integers +ok 341 — The returned array has the proper length +ok 342 — The returned array's values lie between provided lowerLimit and upperLimit (both inclusive). # PASS test/getMeridiemSuffixOfInteger.test.js -ok 327 — getMeridiemSuffixOfInteger is a Function -ok 328 — Gets the correct meridiem suffix. -ok 329 — Gets the correct meridiem suffix. -ok 330 — Gets the correct meridiem suffix. -ok 331 — Gets the correct meridiem suffix. -ok 332 — Gets the correct meridiem suffix. +ok 343 — getMeridiemSuffixOfInteger is a Function +ok 344 — Gets the correct meridiem suffix. +ok 345 — Gets the correct meridiem suffix. +ok 346 — Gets the correct meridiem suffix. +ok 347 — Gets the correct meridiem suffix. +ok 348 — Gets the correct meridiem suffix. # PASS test/getImages.test.js -ok 333 — getImages is a Function -ok 334 — getImages returns an Array -ok 335 — getImages removes duplicates from images Array +ok 349 — getImages is a Function +ok 350 — getImages returns an Array +ok 351 — getImages removes duplicates from images Array # PASS test/sampleSize.test.js -ok 336 — sampleSize is a Function -ok 337 — Returns a single element without n specified -ok 338 — Returns a random sample of specified size from an array -ok 339 — Returns all elements in an array if n >= length -ok 340 — Returns an empty array if original array is empty -ok 341 — Returns an empty array if n = 0 +ok 352 — sampleSize is a Function +ok 353 — Returns a single element without n specified +ok 354 — Returns a random sample of specified size from an array +ok 355 — Returns all elements in an array if n >= length +ok 356 — Returns an empty array if original array is empty +ok 357 — Returns an empty array if n = 0 # PASS test/orderBy.test.js -ok 342 — orderBy is a Function -ok 343 — Returns a sorted array of objects ordered by properties and orders. -ok 344 — Returns a sorted array of objects ordered by properties and orders. +ok 358 — orderBy is a Function +ok 359 — Returns a sorted array of objects ordered by properties and orders. +ok 360 — Returns a sorted array of objects ordered by properties and orders. # PASS test/deepFreeze.test.js -ok 345 — deepFreeze is a Function -ok 346 — modifying deeply freezed object prop throws an error in strict mode -ok 347 — should not modify deeply freezed object inside another object -ok 348 — should not add prop to deeply freezed empty object +ok 361 — deepFreeze is a Function +ok 362 — modifying deeply freezed object prop throws an error in strict mode +ok 363 — should not modify deeply freezed object inside another object +ok 364 — should not add prop to deeply freezed empty object # PASS test/CSVToArray.test.js -ok 349 — CSVToArray is a Function -ok 350 — CSVToArray works with default delimiter -ok 351 — CSVToArray works with custom delimiter -ok 352 — CSVToArray omits the first row -ok 353 — CSVToArray omits the first row and works with a custom delimiter +ok 365 — CSVToArray is a Function +ok 366 — CSVToArray works with default delimiter +ok 367 — CSVToArray works with custom delimiter +ok 368 — CSVToArray omits the first row +ok 369 — CSVToArray omits the first row and works with a custom delimiter # PASS test/initializeArrayWithRangeRight.test.js -ok 354 — initializeArrayWithRangeRight is a Function -ok 355 — Initializes an array containing the numbers in the specified range (witout start value) -ok 356 — Initializes an array containing the numbers in the specified range -ok 357 — Initializes an array containing the numbers in the specified range (with step) +ok 370 — initializeArrayWithRangeRight is a Function +ok 371 — Initializes an array containing the numbers in the specified range (witout start value) +ok 372 — Initializes an array containing the numbers in the specified range +ok 373 — Initializes an array containing the numbers in the specified range (with step) + +# PASS test/sortedLastIndexBy.test.js + +ok 374 — sortedLastIndexBy is a Function +ok 375 — Returns the highest index to insert the element without messing up the list order +ok 376 — Returns the highest index to insert the element without messing up the list order +ok 377 — Returns the highest index to insert the element without messing up the list order # PASS test/isWritableStream.test.js -ok 358 — isWritableStream is a Function -ok 359 — isWritableStream returns false for read streams -ok 360 — isWritableStream returns true for write streams -ok 361 — isWritableStream returns true for duplex streams -ok 362 — isWritableStream returns false for non-streams +ok 378 — isWritableStream is a Function +ok 379 — isWritableStream returns false for read streams +ok 380 — isWritableStream returns true for write streams +ok 381 — isWritableStream returns true for duplex streams +ok 382 — isWritableStream returns false for non-streams # PASS test/isReadableStream.test.js -ok 363 — isReadableStream is a Function -ok 364 — isReadableStream returns true for read streams -ok 365 — isReadableStream returns false for write streams -ok 366 — isReadableStream returns true for duplex streams -ok 367 — isReadableStream returns false for non-streams +ok 383 — isReadableStream is a Function +ok 384 — isReadableStream returns true for read streams +ok 385 — isReadableStream returns false for write streams +ok 386 — isReadableStream returns true for duplex streams +ok 387 — isReadableStream returns false for non-streams # PASS test/inRange.test.js -ok 368 — inRange is a Function -ok 369 — The given number falls within the given range -ok 370 — The given number falls within the given range (reverse) -ok 371 — The given number falls within the given range -ok 372 — The given number does not falls within the given range -ok 373 — The given number does not falls within the given range +ok 388 — inRange is a Function +ok 389 — The given number falls within the given range +ok 390 — The given number falls within the given range (reverse) +ok 391 — The given number falls within the given range +ok 392 — The given number does not falls within the given range +ok 393 — The given number does not falls within the given range # PASS test/any.test.js -ok 374 — any is a Function -ok 375 — Returns true for arrays with at least one truthy value -ok 376 — Returns false for arrays with no truthy values -ok 377 — Returns false for arrays with no truthy values -ok 378 — Returns true with predicate function -ok 379 — Returns false with a predicate function +ok 394 — any is a Function +ok 395 — Returns true for arrays with at least one truthy value +ok 396 — Returns false for arrays with no truthy values +ok 397 — Returns false for arrays with no truthy values +ok 398 — Returns true with predicate function +ok 399 — Returns false with a predicate function # PASS test/randomIntegerInRange.test.js -ok 380 — randomIntegerInRange is a Function -ok 381 — The returned value is an integer -ok 382 — The returned value lies between provided lowerLimit and upperLimit (both inclusive). +ok 400 — randomIntegerInRange is a Function +ok 401 — The returned value is an integer +ok 402 — The returned value lies between provided lowerLimit and upperLimit (both inclusive). # PASS test/initializeArrayWithRange.test.js -ok 383 — initializeArrayWithRange is a Function -ok 384 — Initializes an array containing the numbers in the specified range (witout start value) -ok 385 — Initializes an array containing the numbers in the specified range -ok 386 — Initializes an array containing the numbers in the specified range (with step) +ok 403 — initializeArrayWithRange is a Function +ok 404 — Initializes an array containing the numbers in the specified range (witout start value) +ok 405 — Initializes an array containing the numbers in the specified range +ok 406 — Initializes an array containing the numbers in the specified range (with step) # PASS test/fahrenheitToCelsius.test.js -ok 387 — fahrenheitToCelsius is a Function -ok 388 — 32 Fahrenheit is 0 Celsius -ok 389 — 212 Fahrenheit is 100 Celsius -ok 390 — 150 Fahrenheit is 65.55555555555556 Celsius -ok 391 — 1000 Fahrenheit is 537.7777777777778 -ok 392 — Not a number value is NaN +ok 407 — fahrenheitToCelsius is a Function +ok 408 — 32 Fahrenheit is 0 Celsius +ok 409 — 212 Fahrenheit is 100 Celsius +ok 410 — 150 Fahrenheit is 65.55555555555556 Celsius +ok 411 — 1000 Fahrenheit is 537.7777777777778 +ok 412 — Not a number value is NaN + +# PASS test/sortedIndexBy.test.js + +ok 413 — sortedIndexBy is a Function +ok 414 — Returns the lowest index to insert the element without messing up the list order +ok 415 — Returns the lowest index to insert the element without messing up the list order +ok 416 — Returns the lowest index to insert the element without messing up the list order # PASS test/formatDuration.test.js -ok 393 — formatDuration is a Function -ok 394 — Returns the human readable format of the given number of milliseconds -ok 395 — Returns the human readable format of the given number of milliseconds (negative) -ok 396 — Returns the human readable format of the given number of milliseconds +ok 417 — formatDuration is a Function +ok 418 — Returns the human readable format of the given number of milliseconds +ok 419 — Returns the human readable format of the given number of milliseconds (negative) +ok 420 — Returns the human readable format of the given number of milliseconds # PASS test/randomNumberInRange.test.js -ok 397 — randomNumberInRange is a Function -ok 398 — The returned value is a number -ok 399 — The returned value lies between provided lowerLimit and upperLimit (both inclusive). +ok 421 — randomNumberInRange is a Function +ok 422 — The returned value is a number +ok 423 — The returned value lies between provided lowerLimit and upperLimit (both inclusive). # PASS test/isDuplexStream.test.js -ok 400 — isDuplexStream is a Function -ok 401 — isDuplexStream returns false for read streams -ok 402 — isDuplexStream returns false for write streams -ok 403 — isDuplexStream returns true for duplex streams -ok 404 — isDuplexStream returns false for non-streams +ok 424 — isDuplexStream is a Function +ok 425 — isDuplexStream returns false for read streams +ok 426 — isDuplexStream returns false for write streams +ok 427 — isDuplexStream returns true for duplex streams +ok 428 — isDuplexStream returns false for non-streams # PASS test/join.test.js -ok 405 — join is a Function -ok 406 — Joins all elements of an array into a string and returns this string -ok 407 — Joins all elements of an array into a string and returns this string -ok 408 — Joins all elements of an array into a string and returns this string +ok 429 — join is a Function +ok 430 — Joins all elements of an array into a string and returns this string +ok 431 — Joins all elements of an array into a string and returns this string +ok 432 — Joins all elements of an array into a string and returns this string # PASS test/toCurrency.test.js -ok 409 — toCurrency is a Function -ok 410 — currency: Euro | currencyLangFormat: Local -ok 411 — currency: US Dollar | currencyLangFormat: English (United States) -ok 412 — currency: Japanese Yen | currencyLangFormat: Local +ok 433 — toCurrency is a Function +ok 434 — currency: Euro | currencyLangFormat: Local +ok 435 — currency: US Dollar | currencyLangFormat: English (United States) +ok 436 — currency: Japanese Yen | currencyLangFormat: Local # PASS test/mapObject.test.js -ok 413 — mapObject is a Function -ok 414 — mapObject([1, 2, 3], a => a * a) returns { 1: 1, 2: 4, 3: 9 } -ok 415 — mapObject([1, 2, 3, 4], (a, b) => b - a) returns { 1: -1, 2: -1, 3: -1, 4: -1 } -ok 416 — mapObject([1, 2, 3, 4], (a, b) => a - b) returns { 1: 1, 2: 1, 3: 1, 4: 1 } +ok 437 — mapObject is a Function +ok 438 — mapObject([1, 2, 3], a => a * a) returns { 1: 1, 2: 4, 3: 9 } +ok 439 — mapObject([1, 2, 3, 4], (a, b) => b - a) returns { 1: -1, 2: -1, 3: -1, 4: -1 } +ok 440 — mapObject([1, 2, 3, 4], (a, b) => a - b) returns { 1: 1, 2: 1, 3: 1, 4: 1 } # PASS test/factorial.test.js -ok 417 — factorial is a Function -ok 418 — Calculates the factorial of 720 -ok 419 — Calculates the factorial of 0 -ok 420 — Calculates the factorial of 1 -ok 421 — Calculates the factorial of 4 -ok 422 — Calculates the factorial of 10 -ok 423 — Throws TypeError if n < 0 +ok 441 — factorial is a Function +ok 442 — Calculates the factorial of 720 +ok 443 — Calculates the factorial of 0 +ok 444 — Calculates the factorial of 1 +ok 445 — Calculates the factorial of 4 +ok 446 — Calculates the factorial of 10 +ok 447 — Throws TypeError if n < 0 + +# PASS test/sortedIndex.test.js + +ok 448 — sortedIndex is a Function +ok 449 — Returns the lowest index at which value should be inserted into array in order to maintain its sort order. +ok 450 — Returns the lowest index at which value should be inserted into array in order to maintain its sort order. +ok 451 — Returns the lowest index at which value should be inserted into array in order to maintain its sort order. # PASS test/geometricProgression.test.js -ok 424 — geometricProgression is a Function -ok 425 — Initializes an array containing the numbers in the specified range -ok 426 — Initializes an array containing the numbers in the specified range -ok 427 — Initializes an array containing the numbers in the specified range +ok 452 — geometricProgression is a Function +ok 453 — Initializes an array containing the numbers in the specified range +ok 454 — Initializes an array containing the numbers in the specified range +ok 455 — Initializes an array containing the numbers in the specified range # PASS test/mapString.test.js -ok 428 — mapString is a Function -ok 429 — mapString returns a capitalized string -ok 430 — mapString can deal with indexes -ok 431 — mapString can deal with the full string +ok 456 — mapString is a Function +ok 457 — mapString returns a capitalized string +ok 458 — mapString can deal with indexes +ok 459 — mapString can deal with the full string # PASS test/dig.test.js -ok 432 — dig is a Function -ok 433 — Dig target success -ok 434 — Dig target with falsey value -ok 435 — Dig target with array -ok 436 — Unknown target return undefined +ok 460 — dig is a Function +ok 461 — Dig target success +ok 462 — Dig target with falsey value +ok 463 — Dig target with array +ok 464 — Unknown target return undefined # PASS test/levenshteinDistance.test.js -ok 437 — levenshteinDistance is a Function -ok 438 — levenshteinDistance returns the correct results -ok 439 — levenshteinDistance returns the correct result for 0-length string as first argument -ok 440 — levenshteinDistance returns the correct result for 0-length string as second argument +ok 465 — levenshteinDistance is a Function +ok 466 — levenshteinDistance returns the correct results +ok 467 — levenshteinDistance returns the correct result for 0-length string as first argument +ok 468 — levenshteinDistance returns the correct result for 0-length string as second argument + +# PASS test/sortedLastIndex.test.js + +ok 469 — sortedLastIndex is a Function +ok 470 — Returns the highest index to insert the element without messing up the list order +ok 471 — Returns the highest index to insert the element without messing up the list order +ok 472 — Returns the highest index to insert the element without messing up the list order # PASS test/celsiusToFahrenheit.test.js -ok 441 — celsiusToFahrenheit is a Function -ok 442 — 0 Celsius is 32 Fahrenheit -ok 443 — 100 Celsius is 212 Fahrenheit -ok 444 — -50 Celsius is -58 Fahrenheit -ok 445 — 1000 Celsius is 1832 Fahrenheit -ok 446 — Not a number value is NaN +ok 473 — celsiusToFahrenheit is a Function +ok 474 — 0 Celsius is 32 Fahrenheit +ok 475 — 100 Celsius is 212 Fahrenheit +ok 476 — -50 Celsius is -58 Fahrenheit +ok 477 — 1000 Celsius is 1832 Fahrenheit +ok 478 — Not a number value is NaN # PASS test/reduceWhich.test.js -ok 447 — reduceWhich is a Function -ok 448 — Returns the minimum of an array -ok 449 — Returns the maximum of an array -ok 450 — Returns the object with the minimum specified value in an array +ok 479 — reduceWhich is a Function +ok 480 — Returns the minimum of an array +ok 481 — Returns the maximum of an array +ok 482 — Returns the object with the minimum specified value in an array + +# PASS test/getScrollPosition.test.js + +ok 483 — getScrollPosition is a Function +ok 484 — getScrollPosition returns an object with x and y values +ok 485 — getScrollPosition returns an object with x and y values # PASS test/isStream.test.js -ok 451 — isStream is a Function -ok 452 — isStream returns true for read streams -ok 453 — isStream returns true for write streams -ok 454 — isStream returns true for duplex streams -ok 455 — isStream returns false for non-streams +ok 486 — isStream is a Function +ok 487 — isStream returns true for read streams +ok 488 — isStream returns true for write streams +ok 489 — isStream returns true for duplex streams +ok 490 — isStream returns false for non-streams # PASS test/factors.test.js -ok 456 — factors is a Function -ok 457 — factors returns the correct array -ok 458 — factors returns the correct array of primes -ok 459 — factors returns the correct array for negatives -ok 460 — factors returns the correct array of primes for negatives +ok 491 — factors is a Function +ok 492 — factors returns the correct array +ok 493 — factors returns the correct array of primes +ok 494 — factors returns the correct array for negatives +ok 495 — factors returns the correct array of primes for negatives + +# PASS test/uncurry.test.js + +ok 496 — uncurry is a Function +ok 497 — Works without a provided value for n +ok 498 — Works with n = 2 +ok 499 — Works with n = 3 +ok 500 — Throws RangeError if arguments are too few # PASS test/invertKeyValues.test.js -ok 461 — invertKeyValues is a Function -ok 462 — invertKeyValues({ a: 1, b: 2, c: 1 }) returns { 1: [ 'a', 'c' ], 2: [ 'b' ] } -ok 463 — invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value) returns { group1: [ 'a', 'c' ], group2: [ 'b' ] } +ok 501 — invertKeyValues is a Function +ok 502 — invertKeyValues({ a: 1, b: 2, c: 1 }) returns { 1: [ 'a', 'c' ], 2: [ 'b' ] } +ok 503 — invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value) returns { group1: [ 'a', 'c' ], group2: [ 'b' ] } # PASS test/fromCamelCase.test.js -ok 464 — fromCamelCase is a Function -ok 465 — Converts a string from camelcase -ok 466 — Converts a string from camelcase -ok 467 — Converts a string from camelcase +ok 504 — fromCamelCase is a Function +ok 505 — Converts a string from camelcase +ok 506 — Converts a string from camelcase +ok 507 — Converts a string from camelcase # PASS test/shank.test.js -ok 468 — shank is a Function -ok 469 — Returns an array with the added elements. -ok 470 — Returns an array with the removed elements. -ok 471 — Does not mutate the original array +ok 508 — shank is a Function +ok 509 — Returns an array with the added elements. +ok 510 — Returns an array with the removed elements. +ok 511 — Does not mutate the original array # PASS test/approximatelyEqual.test.js -ok 472 — approximatelyEqual is a Function -ok 473 — Works for PI / 2 -ok 474 — Works for 0.1 + 0.2 === 0.3 -ok 475 — Works for exactly equal values -ok 476 — Works for a custom epsilon +ok 512 — approximatelyEqual is a Function +ok 513 — Works for PI / 2 +ok 514 — Works for 0.1 + 0.2 === 0.3 +ok 515 — Works for exactly equal values +ok 516 — Works for a custom epsilon # PASS test/none.test.js -ok 477 — none is a Function -ok 478 — Returns true for arrays with no truthy values -ok 479 — Returns false for arrays with at least one truthy value -ok 480 — Returns true with a predicate function -ok 481 — Returns false with predicate function +ok 517 — none is a Function +ok 518 — Returns true for arrays with no truthy values +ok 519 — Returns false for arrays with at least one truthy value +ok 520 — Returns true with a predicate function +ok 521 — Returns false with predicate function # PASS test/nest.test.js -ok 482 — nest is a Function -ok 483 — Nests items +ok 522 — nest is a Function +ok 523 — Nests items # PASS test/castArray.test.js -ok 484 — castArray is a Function -ok 485 — Works for single values -ok 486 — Works for arrays with one value -ok 487 — Works for arrays with multiple value -ok 488 — Works for strings -ok 489 — Works for objects +ok 524 — castArray is a Function +ok 525 — Works for single values +ok 526 — Works for arrays with one value +ok 527 — Works for arrays with multiple value +ok 528 — Works for strings +ok 529 — Works for objects # PASS test/nthElement.test.js -ok 490 — nthElement is a Function -ok 491 — Returns the nth element of an array. -ok 492 — Returns the nth element of an array. -ok 493 — Returns the nth element of an array. -ok 494 — Returns the nth element of an array. +ok 530 — nthElement is a Function +ok 531 — Returns the nth element of an array. +ok 532 — Returns the nth element of an array. +ok 533 — Returns the nth element of an array. +ok 534 — Returns the nth element of an array. # PASS test/binarySearch.test.js -ok 495 — binarySearch is a Function -ok 496 — Finds item in array -ok 497 — Returns -1 when not found -ok 498 — Works with empty arrays -ok 499 — Works for one element arrays +ok 535 — binarySearch is a Function +ok 536 — Finds item in array +ok 537 — Returns -1 when not found +ok 538 — Works with empty arrays +ok 539 — Works for one element arrays # PASS test/mask.test.js -ok 500 — mask is a Function -ok 501 — Replaces all but the last num of characters with the specified mask character -ok 502 — Replaces all but the last num of characters with the specified mask character -ok 503 — Replaces all but the last num of characters with the specified mask character +ok 540 — mask is a Function +ok 541 — Replaces all but the last num of characters with the specified mask character +ok 542 — Replaces all but the last num of characters with the specified mask character +ok 543 — Replaces all but the last num of characters with the specified mask character # PASS test/randomHexColorCode.test.js -ok 504 — randomHexColorCode is a Function -ok 505 — randomHexColorCode has to proper length -ok 506 — The color code starts with "#" -ok 507 — The color code contains only valid hex-digits +ok 544 — randomHexColorCode is a Function +ok 545 — randomHexColorCode has to proper length +ok 546 — The color code starts with "#" +ok 547 — The color code contains only valid hex-digits + +# PASS test/createEventHub.test.js + +ok 548 — createEventHub is a Function +ok 549 — createEventHub returns an object # PASS test/howManyTimes.test.js -ok 508 — howManyTimes is a Function -ok 509 — howManyTimes returns the correct result -ok 510 — howManyTimes returns the correct result -ok 511 — howManyTimes returns the correct result -ok 512 — howManyTimes returns the correct result +ok 550 — howManyTimes is a Function +ok 551 — howManyTimes returns the correct result +ok 552 — howManyTimes returns the correct result +ok 553 — howManyTimes returns the correct result +ok 554 — howManyTimes returns the correct result # PASS test/JSONtoCSV.test.js -ok 513 — JSONtoCSV is a Function -ok 514 — JSONtoCSV works with default delimiter -ok 515 — JSONtoCSV works with custom delimiter +ok 555 — JSONtoCSV is a Function +ok 556 — JSONtoCSV works with default delimiter +ok 557 — JSONtoCSV works with custom delimiter # PASS test/converge.test.js -ok 516 — converge is a Function -ok 517 — Produces the average of the array -ok 518 — Produces the strange concatenation +ok 558 — converge is a Function +ok 559 — Produces the average of the array +ok 560 — Produces the strange concatenation # PASS test/capitalize.test.js -ok 519 — capitalize is a Function -ok 520 — Capitalizes the first letter of a string -ok 521 — Capitalizes the first letter of a string -ok 522 — Works with characters -ok 523 — "Works with single character words +ok 561 — capitalize is a Function +ok 562 — Capitalizes the first letter of a string +ok 563 — Capitalizes the first letter of a string +ok 564 — Works with characters +ok 565 — "Works with single character words # PASS test/toOrdinalSuffix.test.js -ok 524 — toOrdinalSuffix is a Function -ok 525 — Adds an ordinal suffix to a number -ok 526 — Adds an ordinal suffix to a number -ok 527 — Adds an ordinal suffix to a number -ok 528 — Adds an ordinal suffix to a number +ok 566 — toOrdinalSuffix is a Function +ok 567 — Adds an ordinal suffix to a number +ok 568 — Adds an ordinal suffix to a number +ok 569 — Adds an ordinal suffix to a number +ok 570 — Adds an ordinal suffix to a number # PASS test/deepClone.test.js -ok 529 — deepClone is a Function -ok 530 — Shallow cloning works -ok 531 — Deep cloning works -ok 532 — Array shallow cloning works -ok 533 — Array deep cloning works +ok 571 — deepClone is a Function +ok 572 — Shallow cloning works +ok 573 — Deep cloning works +ok 574 — Array shallow cloning works +ok 575 — Array deep cloning works # PASS test/isAnagram.test.js -ok 534 — isAnagram is a Function -ok 535 — Checks valid anagram -ok 536 — Works with spaces -ok 537 — Ignores case -ok 538 — Ignores special characters +ok 576 — isAnagram is a Function +ok 577 — Checks valid anagram +ok 578 — Works with spaces +ok 579 — Ignores case +ok 580 — Ignores special characters # PASS test/tomorrow.test.js -ok 539 — tomorrow is a Function -ok 540 — Returns the correct year -ok 541 — Returns the correct month -ok 542 — Returns the correct date +ok 581 — tomorrow is a Function +ok 582 — Returns the correct year +ok 583 — Returns the correct month +ok 584 — Returns the correct date + +# PASS test/elementIsVisibleInViewport.test.js + +ok 585 — elementIsVisibleInViewport is a Function +ok 586 — elementIsVisibleInViewport returns a boolean +ok 587 — elementIsVisibleInViewport returns a boolean # PASS test/shuffle.test.js -ok 543 — shuffle is a Function -ok 544 — Shuffles the array -ok 545 — New array contains all original elements -ok 546 — Works for empty arrays -ok 547 — Works for single-element arrays +ok 588 — shuffle is a Function +ok 589 — Shuffles the array +ok 590 — New array contains all original elements +ok 591 — Works for empty arrays +ok 592 — Works for single-element arrays -# PASS test/prettyBytes.test.js +# PASS test/memoize.test.js + +ok 593 — memoize is a Function +ok 594 — Function works properly +ok 595 — Function works properly +ok 596 — Function works properly, cache stores values (coverage) +ok 597 — Cache stores values + +# PASS test/elementContains.test.js -ok 548 — prettyBytes is a Function -ok 549 — Converts a number in bytes to a human-readable string. -ok 550 — Converts a number in bytes to a human-readable string. -ok 551 — Converts a number in bytes to a human-readable string. +ok 598 — elementContains is a Function +ok 599 — elementContains returns true +ok 600 — elementContains returns false # PASS test/isString.test.js -ok 552 — isString is a Function -ok 553 — foo is a string -ok 554 — "10" is a string -ok 555 — Empty string is a string -ok 556 — 10 is not a string -ok 557 — true is not string +ok 601 — isString is a Function +ok 602 — foo is a string +ok 603 — "10" is a string +ok 604 — Empty string is a string +ok 605 — 10 is not a string +ok 606 — true is not string # PASS test/dropRight.test.js -ok 558 — dropRight is a Function -ok 559 — Returns a new array with n elements removed from the right -ok 560 — Returns a new array with n elements removed from the right -ok 561 — Returns a new array with n elements removed from the right +ok 607 — dropRight is a Function +ok 608 — Returns a new array with n elements removed from the right +ok 609 — Returns a new array with n elements removed from the right +ok 610 — Returns a new array with n elements removed from the right # PASS test/hexToRGB.test.js -ok 562 — hexToRGB is a Function -ok 563 — Converts a color code to a rgb() or rgba() string -ok 564 — Converts a color code to a rgb() or rgba() string -ok 565 — Converts a color code to a rgb() or rgba() string +ok 611 — hexToRGB is a Function +ok 612 — Converts a color code to a rgb() or rgba() string +ok 613 — Converts a color code to a rgb() or rgba() string +ok 614 — Converts a color code to a rgb() or rgba() string # PASS test/partition.test.js -ok 566 — partition is a Function -ok 567 — Groups the elements into two arrays, depending on the provided function's truthiness for each element. +ok 615 — partition is a Function +ok 616 — Groups the elements into two arrays, depending on the provided function's truthiness for each element. # PASS test/isPromiseLike.test.js -ok 568 — isPromiseLike is a Function -ok 569 — Returns true for a promise-like object -ok 570 — Returns false for an empty object -ok 571 — Returns false for a normal function +ok 617 — isPromiseLike is a Function +ok 618 — Returns true for a promise-like object +ok 619 — Returns false for an empty object +ok 620 — Returns false for a normal function # PASS test/stringPermutations.test.js -ok 572 — stringPermutations is a Function -ok 573 — Generates all stringPermutations of a string -ok 574 — Works for single-letter strings -ok 575 — Works for empty strings +ok 621 — stringPermutations is a Function +ok 622 — Generates all stringPermutations of a string +ok 623 — Works for single-letter strings +ok 624 — Works for empty strings # PASS test/sumPower.test.js -ok 576 — sumPower is a Function -ok 577 — Returns the sum of the powers of all the numbers from start to end -ok 578 — Returns the sum of the powers of all the numbers from start to end -ok 579 — Returns the sum of the powers of all the numbers from start to end +ok 625 — sumPower is a Function +ok 626 — Returns the sum of the powers of all the numbers from start to end +ok 627 — Returns the sum of the powers of all the numbers from start to end +ok 628 — Returns the sum of the powers of all the numbers from start to end # PASS test/isObjectLike.test.js -ok 580 — isObjectLike is a Function -ok 581 — Returns true for an object -ok 582 — Returns true for an array -ok 583 — Returns false for a function -ok 584 — Returns false for null +ok 629 — isObjectLike is a Function +ok 630 — Returns true for an object +ok 631 — Returns true for an array +ok 632 — Returns false for a function +ok 633 — Returns false for null # PASS test/untildify.test.js -ok 585 — untildify is a Function -ok 586 — Contains no tildes -ok 587 — Does not alter the rest of the path -ok 588 — Does not alter paths without tildes +ok 634 — untildify is a Function +ok 635 — Contains no tildes +ok 636 — Does not alter the rest of the path +ok 637 — Does not alter paths without tildes # PASS test/isObject.test.js -ok 589 — isObject is a Function -ok 590 — isObject([1, 2, 3, 4]) is a object -ok 591 — isObject([]) is a object -ok 592 — isObject({ a:1 }) is a object -ok 593 — isObject(true) is not a object +ok 638 — isObject is a Function +ok 639 — isObject([1, 2, 3, 4]) is a object +ok 640 — isObject([]) is a object +ok 641 — isObject({ a:1 }) is a object +ok 642 — isObject(true) is not a object # PASS test/standardDeviation.test.js -ok 594 — standardDeviation is a Function -ok 595 — Returns the standard deviation of an array of numbers -ok 596 — Returns the standard deviation of an array of numbers +ok 643 — standardDeviation is a Function +ok 644 — Returns the standard deviation of an array of numbers +ok 645 — Returns the standard deviation of an array of numbers # PASS test/functionName.test.js -ok 597 — functionName is a Function -ok 598 — Works for native functions -ok 599 — Works for normal functions -ok 600 — Works for arrow functions +ok 646 — functionName is a Function +ok 647 — Works for native functions +ok 648 — Works for normal functions +ok 649 — Works for arrow functions # PASS test/capitalizeEveryWord.test.js -ok 601 — capitalizeEveryWord is a Function -ok 602 — Capitalizes the first letter of every word in a string -ok 603 — Works with characters -ok 604 — Works with one word string +ok 650 — capitalizeEveryWord is a Function +ok 651 — Capitalizes the first letter of every word in a string +ok 652 — Works with characters +ok 653 — Works with one word string # PASS test/unzip.test.js -ok 605 — unzip is a Function -ok 606 — unzip([['a', 1, true], ['b', 2, false]]) equals [['a','b'], [1, 2], [true, false]] -ok 607 — unzip([['a', 1, true], ['b', 2]]) equals [['a','b'], [1, 2], [true]] +ok 654 — unzip is a Function +ok 655 — unzip([['a', 1, true], ['b', 2, false]]) equals [['a','b'], [1, 2], [true, false]] +ok 656 — unzip([['a', 1, true], ['b', 2]]) equals [['a','b'], [1, 2], [true]] # PASS test/take.test.js -ok 608 — take is a Function -ok 609 — Returns an array with n elements removed from the beginning. -ok 610 — Returns an array with n elements removed from the beginning. -ok 611 — Returns an array with n elements removed from the beginning. +ok 657 — take is a Function +ok 658 — Returns an array with n elements removed from the beginning. +ok 659 — Returns an array with n elements removed from the beginning. +ok 660 — Returns an array with n elements removed from the beginning. # PASS test/URLJoin.test.js -ok 612 — URLJoin is a Function -ok 613 — Returns proper URL -ok 614 — Returns proper URL +ok 661 — URLJoin is a Function +ok 662 — Returns proper URL +ok 663 — Returns proper URL # PASS test/CSVToJSON.test.js -ok 615 — CSVToJSON is a Function -ok 616 — CSVToJSON works with default delimiter -ok 617 — CSVToJSON works with custom delimiter - -# PASS test/byteSize.test.js - -ok 618 — byteSize is a Function -ok 619 — Works for a single letter -ok 620 — Works for a common string -ok 621 — Works for emoji - -# PASS test/sortedIndex.test.js - -ok 622 — sortedIndex is a Function -ok 623 — Returns the lowest index at which value should be inserted into array in order to maintain its sort order. -ok 624 — Returns the lowest index at which value should be inserted into array in order to maintain its sort order. +ok 664 — CSVToJSON is a Function +ok 665 — CSVToJSON works with default delimiter +ok 666 — CSVToJSON works with custom delimiter # PASS test/reducedFilter.test.js -ok 625 — reducedFilter is a Function -ok 626 — Filter an array of objects based on a condition while also filtering out unspecified keys. +ok 667 — reducedFilter is a Function +ok 668 — Filter an array of objects based on a condition while also filtering out unspecified keys. -# PASS test/matches.test.js +# PASS test/byteSize.test.js -ok 627 — matches is a Function -ok 628 — Matches returns true for two similar objects -ok 629 — Matches returns false for two non-similar objects +ok 669 — byteSize is a Function +ok 670 — Works for a single letter +ok 671 — Works for a common string +ok 672 — Works for emoji -# PASS test/uncurry.test.js +# PASS test/matches.test.js -ok 630 — uncurry is a Function -ok 631 — Works without a provided value for n -ok 632 — Works with n = 2 -ok 633 — Works with n = 3 +ok 673 — matches is a Function +ok 674 — Matches returns true for two similar objects +ok 675 — Matches returns false for two non-similar objects # PASS test/pad.test.js -ok 634 — pad is a Function -ok 635 — cat is padded on both sides -ok 636 — length of string is 8 -ok 637 — pads 42 with "0" -ok 638 — does not truncates if string exceeds length +ok 676 — pad is a Function +ok 677 — cat is padded on both sides +ok 678 — length of string is 8 +ok 679 — pads 42 with "0" +ok 680 — does not truncates if string exceeds length # PASS test/initializeArrayWithValues.test.js -ok 639 — initializeArrayWithValues is a Function -ok 640 — Initializes and fills an array with the specified values -ok 641 — Initializes and fills an array with the specified values (no fill) +ok 681 — initializeArrayWithValues is a Function +ok 682 — Initializes and fills an array with the specified values +ok 683 — Initializes and fills an array with the specified values (no fill) # PASS test/isAbsoluteURL.test.js -ok 642 — isAbsoluteURL is a Function -ok 643 — Given string is an absolute URL -ok 644 — Given string is an absolute URL -ok 645 — Given string is not an absolute URL +ok 684 — isAbsoluteURL is a Function +ok 685 — Given string is an absolute URL +ok 686 — Given string is an absolute URL +ok 687 — Given string is not an absolute URL # PASS test/collectInto.test.js -ok 646 — collectInto is a Function -ok 647 — Works with multiple promises +ok 688 — collectInto is a Function +ok 689 — Works with multiple promises # PASS test/isValidJSON.test.js -ok 648 — isValidJSON is a Function -ok 649 — {"name":"Adam","age":20} is a valid JSON -ok 650 — {"name":"Adam",age:"20"} is not a valid JSON -ok 651 — null is a valid JSON +ok 690 — isValidJSON is a Function +ok 691 — {"name":"Adam","age":20} is a valid JSON +ok 692 — {"name":"Adam",age:"20"} is not a valid JSON +ok 693 — null is a valid JSON # PASS test/groupBy.test.js -ok 652 — groupBy is a Function -ok 653 — Groups the elements of an array based on the given function -ok 654 — Groups the elements of an array based on the given function +ok 694 — groupBy is a Function +ok 695 — Groups the elements of an array based on the given function +ok 696 — Groups the elements of an array based on the given function # PASS test/uniqueSymmetricDifference.test.js -ok 655 — uniqueSymmetricDifference is a Function -ok 656 — Returns the symmetric difference between two arrays. -ok 657 — Does not return duplicates from one array +ok 697 — uniqueSymmetricDifference is a Function +ok 698 — Returns the symmetric difference between two arrays. +ok 699 — Does not return duplicates from one array # PASS test/symmetricDifferenceWith.test.js -ok 658 — symmetricDifferenceWith is a Function -ok 659 — Returns the symmetric difference between two arrays, using a provided function as a comparator +ok 700 — symmetricDifferenceWith is a Function +ok 701 — Returns the symmetric difference between two arrays, using a provided function as a comparator # PASS test/initialize2DArray.test.js -ok 660 — initialize2DArray is a Function -ok 661 — Initializes a 2D array of given width and height and value -ok 662 — Initializes a 2D array of given width and height and value (no fill) +ok 702 — initialize2DArray is a Function +ok 703 — Initializes a 2D array of given width and height and value +ok 704 — Initializes a 2D array of given width and height and value (no fill) # PASS test/lowercaseKeys.test.js -ok 663 — lowercaseKeys is a Function -ok 664 — Lowercases object keys -ok 665 — Does not mutate original object +ok 705 — lowercaseKeys is a Function +ok 706 — Lowercases object keys +ok 707 — Does not mutate original object # PASS test/collatz.test.js -ok 666 — collatz is a Function -ok 667 — When n is even, divide by 2 -ok 668 — When n is odd, times by 3 and add 1 -ok 669 — Eventually reaches 1 +ok 708 — collatz is a Function +ok 709 — When n is even, divide by 2 +ok 710 — When n is odd, times by 3 and add 1 +ok 711 — Eventually reaches 1 # PASS test/reject.test.js -ok 670 — reject is a Function -ok 671 — Works with numbers -ok 672 — Works with strings +ok 712 — reject is a Function +ok 713 — Works with numbers +ok 714 — Works with strings # PASS test/matchesWith.test.js -ok 673 — matchesWith is a Function -ok 674 — Returns true for two objects with similar values, based on the provided function +ok 715 — matchesWith is a Function +ok 716 — Returns true for two objects with similar values, based on the provided function + +# PASS test/permutations.test.js + +ok 717 — permutations is a Function +ok 718 — Generates all permutations of an array +ok 719 — Generates all permutations of an array # PASS test/zipWith.test.js -ok 675 — zipWith is a Function -ok 676 — zipWith returns the correct results -ok 677 — zipWith returns the correct results if no function is passed +ok 720 — zipWith is a Function +ok 721 — zipWith returns the correct results +ok 722 — zipWith returns the correct results if no function is passed # PASS test/luhnCheck.test.js -ok 678 — luhnCheck is a Function -ok 679 — validates identification number -ok 680 — validates identification number -ok 681 — validates identification number +ok 723 — luhnCheck is a Function +ok 724 — validates identification number +ok 725 — validates identification number +ok 726 — validates identification number # PASS test/nthArg.test.js -ok 682 — nthArg is a Function -ok 683 — Returns the nth argument -ok 684 — Returns undefined if arguments too few -ok 685 — Works for negative values +ok 727 — nthArg is a Function +ok 728 — Returns the nth argument +ok 729 — Returns undefined if arguments too few +ok 730 — Works for negative values # PASS test/sample.test.js -ok 686 — sample is a Function -ok 687 — Returns a random element from the array -ok 688 — Works for single-element arrays -ok 689 — Returns undefined for empty array +ok 731 — sample is a Function +ok 732 — Returns a random element from the array +ok 733 — Works for single-element arrays +ok 734 — Returns undefined for empty array # PASS test/UUIDGeneratorNode.test.js -ok 690 — UUIDGeneratorNode is a Function -ok 691 — Contains dashes in the proper places -ok 692 — Only contains hexadecimal digits +ok 735 — UUIDGeneratorNode is a Function +ok 736 — Contains dashes in the proper places +ok 737 — Only contains hexadecimal digits # PASS test/drop.test.js -ok 693 — drop is a Function -ok 694 — Works without the last argument -ok 695 — Removes appropriate element count as specified -ok 696 — Empties array given a count greater than length +ok 738 — drop is a Function +ok 739 — Works without the last argument +ok 740 — Removes appropriate element count as specified +ok 741 — Empties array given a count greater than length # PASS test/isBeforeDate.test.js -ok 697 — isBeforeDate is a Function -ok 698 — isBeforeDate produces the correct result -ok 699 — isBeforeDate produces the correct result +ok 742 — isBeforeDate is a Function +ok 743 — isBeforeDate produces the correct result +ok 744 — isBeforeDate produces the correct result # PASS test/median.test.js -ok 700 — median is a Function -ok 701 — Returns the median of an array of numbers -ok 702 — Returns the median of an array of numbers -ok 703 — Returns the median of an array of numbers +ok 745 — median is a Function +ok 746 — Returns the median of an array of numbers +ok 747 — Returns the median of an array of numbers +ok 748 — Returns the median of an array of numbers # PASS test/symmetricDifference.test.js -ok 704 — symmetricDifference is a Function -ok 705 — Returns the symmetric difference between two arrays. -ok 706 — Returns duplicates from one array +ok 749 — symmetricDifference is a Function +ok 750 — Returns the symmetric difference between two arrays. +ok 751 — Returns duplicates from one array # PASS test/flattenObject.test.js -ok 707 — flattenObject is a Function -ok 708 — Flattens an object with the paths for keys -ok 709 — Works with arrays +ok 752 — flattenObject is a Function +ok 753 — Flattens an object with the paths for keys +ok 754 — Works with arrays # PASS test/intersectionWith.test.js -ok 710 — intersectionWith is a Function -ok 711 — Returns a list of elements that exist in both arrays, using a provided comparator function +ok 755 — intersectionWith is a Function +ok 756 — Returns a list of elements that exist in both arrays, using a provided comparator function # PASS test/elo.test.js -ok 712 — elo is a Function -ok 713 — Standard 1v1s -ok 714 — Standard 1v1s -ok 715 — 4 player FFA, all same rank +ok 757 — elo is a Function +ok 758 — Standard 1v1s +ok 759 — Standard 1v1s +ok 760 — 4 player FFA, all same rank # PASS test/functions.test.js -ok 716 — functions is a Function -ok 717 — Returns own methods -ok 718 — Returns own and inherited methods +ok 761 — functions is a Function +ok 762 — Returns own methods +ok 763 — Returns own and inherited methods # PASS test/isAfterDate.test.js -ok 719 — isAfterDate is a Function -ok 720 — isAfterDate produces the correct result -ok 721 — isBeforeDate produces the correct result +ok 764 — isAfterDate is a Function +ok 765 — isAfterDate produces the correct result +ok 766 — isBeforeDate produces the correct result # PASS test/differenceBy.test.js -ok 722 — differenceBy is a Function -ok 723 — Works using a native function and numbers -ok 724 — Works with arrow function and objects +ok 767 — differenceBy is a Function +ok 768 — Works using a native function and numbers +ok 769 — Works with arrow function and objects # PASS test/pipeAsyncFunctions.test.js -ok 725 — pipeAsyncFunctions is a Function -ok 726 — pipeAsyncFunctions result should be 15 - -# PASS test/memoize.test.js - -ok 727 — memoize is a Function -ok 728 — Function works properly -ok 729 — Function works properly -ok 730 — Cache stores values +ok 770 — pipeAsyncFunctions is a Function +ok 771 — pipeAsyncFunctions result should be 15 # PASS test/renameKeys.test.js -ok 731 — renameKeys is a Function -ok 732 — renameKeys is a Function +ok 772 — renameKeys is a Function +ok 773 — renameKeys is a Function # PASS test/isSameDate.test.js -ok 733 — isSameDate is a Function -ok 734 — isSameDate produces the correct result -ok 735 — isSameDate produces the correct result +ok 774 — isSameDate is a Function +ok 775 — isSameDate produces the correct result +ok 776 — isSameDate produces the correct result # PASS test/averageBy.test.js -ok 736 — averageBy is a Function -ok 737 — Produces the right result with a function -ok 738 — Produces the right result with a property name +ok 777 — averageBy is a Function +ok 778 — Produces the right result with a function +ok 779 — Produces the right result with a property name # PASS test/isLowerCase.test.js -ok 739 — isLowerCase is a Function -ok 740 — passed string is a lowercase -ok 741 — passed string is a lowercase -ok 742 — passed value is not a lowercase +ok 780 — isLowerCase is a Function +ok 781 — passed string is a lowercase +ok 782 — passed string is a lowercase +ok 783 — passed value is not a lowercase # PASS test/initializeNDArray.test.js -ok 743 — initializeNDArray is a Function -ok 744 — Initializes a n-D array with given data -ok 745 — Initializes a n-D array with given data +ok 784 — initializeNDArray is a Function +ok 785 — Initializes a n-D array with given data +ok 786 — Initializes a n-D array with given data # PASS test/bindKey.test.js -ok 746 — bindKey is a Function -ok 747 — Binds function to an object context +ok 787 — bindKey is a Function +ok 788 — Binds function to an object context # PASS test/getType.test.js -ok 748 — getType is a Function -ok 749 — Returns the native type of a value -ok 750 — Returns null for null -ok 751 — Returns undefined for undefined +ok 789 — getType is a Function +ok 790 — Returns the native type of a value +ok 791 — Returns null for null +ok 792 — Returns undefined for undefined # PASS test/findLastKey.test.js -ok 752 — findLastKey is a Function -ok 753 — eturns the appropriate key +ok 793 — findLastKey is a Function +ok 794 — eturns the appropriate key # PASS test/arrayToCSV.test.js -ok 754 — arrayToCSV is a Function -ok 755 — arrayToCSV works with default delimiter -ok 756 — arrayToCSV works with custom delimiter +ok 795 — arrayToCSV is a Function +ok 796 — arrayToCSV works with default delimiter +ok 797 — arrayToCSV works with custom delimiter # PASS test/promisify.test.js -ok 757 — promisify is a Function -ok 758 — Returns a promise -ok 759 — Runs the function provided +ok 798 — promisify is a Function +ok 799 — Returns a promise +ok 800 — Runs the function provided # PASS test/isArrayLike.test.js -ok 760 — isArrayLike is a Function -ok 761 — Returns true for a string -ok 762 — Returns true for an array -ok 763 — Returns false for null +ok 801 — isArrayLike is a Function +ok 802 — Returns true for a string +ok 803 — Returns true for an array +ok 804 — Returns false for null # PASS test/takeWhile.test.js -ok 764 — takeWhile is a Function -ok 765 — Removes elements until the function returns true -ok 766 — Removes elements until the function returns true +ok 805 — takeWhile is a Function +ok 806 — Removes elements until the function returns true +ok 807 — Removes elements until the function returns true # PASS test/maxBy.test.js -ok 767 — maxBy is a Function -ok 768 — Produces the right result with a function -ok 769 — Produces the right result with a property name +ok 808 — maxBy is a Function +ok 809 — Produces the right result with a function +ok 810 — Produces the right result with a property name # PASS test/minBy.test.js -ok 770 — minBy is a Function -ok 771 — Produces the right result with a function -ok 772 — Produces the right result with a property name +ok 811 — minBy is a Function +ok 812 — Produces the right result with a function +ok 813 — Produces the right result with a property name # PASS test/symmetricDifferenceBy.test.js -ok 773 — symmetricDifferenceBy is a Function -ok 774 — Returns the symmetric difference between two arrays, after applying the provided function to each array element of both +ok 814 — symmetricDifferenceBy is a Function +ok 815 — Returns the symmetric difference between two arrays, after applying the provided function to each array element of both # PASS test/isUpperCase.test.js -ok 775 — isUpperCase is a Function -ok 776 — ABC is all upper case -ok 777 — abc is not all upper case -ok 778 — A3@$ is all uppercase +ok 816 — isUpperCase is a Function +ok 817 — ABC is all upper case +ok 818 — abc is not all upper case +ok 819 — A3@$ is all uppercase # PASS test/mostPerformant.test.js -ok 779 — mostPerformant is a Function -ok 780 — mostPerformant returns a number -ok 781 — mostPerformant returns a number +ok 820 — mostPerformant is a Function +ok 821 — mostPerformant returns a number +ok 822 — mostPerformant returns a number # PASS test/unzipWith.test.js -ok 782 — unzipWith is a Function -ok 783 — unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)) equals [3, 30, 300] +ok 823 — unzipWith is a Function +ok 824 — unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)) equals [3, 30, 300] # PASS test/truthCheckCollection.test.js -ok 784 — truthCheckCollection is a Function -ok 785 — second argument is truthy on all elements of a collection +ok 825 — truthCheckCollection is a Function +ok 826 — second argument is truthy on all elements of a collection # PASS test/pullAtValue.test.js -ok 786 — pullAtValue is a Function -ok 787 — Pulls the specified values -ok 788 — Pulls the specified values +ok 827 — pullAtValue is a Function +ok 828 — Pulls the specified values +ok 829 — Pulls the specified values # PASS test/findKey.test.js -ok 789 — findKey is a Function -ok 790 — Returns the appropriate key +ok 830 — findKey is a Function +ok 831 — Returns the appropriate key + +# PASS test/counter.test.js + +ok 832 — counter is a Function +ok 833 — counter does not throw errors # PASS test/merge.test.js -ok 791 — merge is a Function -ok 792 — Merges two objects +ok 834 — merge is a Function +ok 835 — Merges two objects # PASS test/bind.test.js -ok 793 — bind is a Function -ok 794 — Binds to an object context +ok 836 — bind is a Function +ok 837 — Binds to an object context # PASS test/pullAtIndex.test.js -ok 795 — pullAtIndex is a Function -ok 796 — Pulls the given values -ok 797 — Pulls the given values +ok 838 — pullAtIndex is a Function +ok 839 — Pulls the given values +ok 840 — Pulls the given values + +# PASS test/triggerEvent.test.js + +ok 841 — triggerEvent is a Function +ok 842 — triggerEvent triggers an event # PASS test/indentString.test.js -ok 798 — indentString is a Function -ok 799 — indentString is a Function -ok 800 — indentString is a Function +ok 843 — indentString is a Function +ok 844 — indentString is a Function +ok 845 — indentString is a Function # PASS test/takeRight.test.js -ok 801 — takeRight is a Function -ok 802 — Returns an array with n elements removed from the end -ok 803 — Returns an array with n elements removed from the end +ok 846 — takeRight is a Function +ok 847 — Returns an array with n elements removed from the end +ok 848 — Returns an array with n elements removed from the end # PASS test/transform.test.js -ok 804 — transform is a Function -ok 805 — Transforms an object +ok 849 — transform is a Function +ok 850 — Transforms an object # PASS test/gcd.test.js -ok 806 — gcd is a Function -ok 807 — Calculates the greatest common divisor between two or more numbers/arrays -ok 808 — Calculates the greatest common divisor between two or more numbers/arrays +ok 851 — gcd is a Function +ok 852 — Calculates the greatest common divisor between two or more numbers/arrays +ok 853 — Calculates the greatest common divisor between two or more numbers/arrays + +# PASS test/toHash.test.js + +ok 854 — toHash is a Function +ok 855 — toHash works properly with indexes +ok 856 — toHash works properly with keys # PASS test/isNil.test.js -ok 809 — isNil is a Function -ok 810 — Returns true for null -ok 811 — Returns true for undefined -ok 812 — Returns false for an empty string +ok 857 — isNil is a Function +ok 858 — Returns true for null +ok 859 — Returns true for undefined +ok 860 — Returns false for an empty string # PASS test/coalesceFactory.test.js -ok 813 — coalesceFactory is a Function -ok 814 — Returns a customized coalesce function +ok 861 — coalesceFactory is a Function +ok 862 — Returns a customized coalesce function # PASS test/indexOfAll.test.js -ok 815 — indexOfAll is a Function -ok 816 — Returns all indices of val in an array -ok 817 — When val is not found, return an empty array +ok 863 — indexOfAll is a Function +ok 864 — Returns all indices of val in an array +ok 865 — When val is not found, return an empty array # PASS test/extendHex.test.js -ok 818 — extendHex is a Function -ok 819 — Extends a 3-digit color code to a 6-digit color code -ok 820 — Extends a 3-digit color code to a 6-digit color code +ok 866 — extendHex is a Function +ok 867 — Extends a 3-digit color code to a 6-digit color code +ok 868 — Extends a 3-digit color code to a 6-digit color code # PASS test/isPlainObject.test.js -ok 821 — isPlainObject is a Function -ok 822 — Returns true for a plain object -ok 823 — Returns false for a Map (example of non-plain object) +ok 869 — isPlainObject is a Function +ok 870 — Returns true for a plain object +ok 871 — Returns false for a Map (example of non-plain object) # PASS test/maxDate.test.js -ok 824 — maxDate is a Function -ok 825 — maxDate produces the maximum date +ok 872 — maxDate is a Function +ok 873 — maxDate produces the maximum date # PASS test/isTravisCI.test.js -ok 826 — isTravisCI is a Function -ok 827 — Running on Travis, correctly evaluates +ok 874 — isTravisCI is a Function +ok 875 — Running on Travis, correctly evaluates # PASS test/intersectionBy.test.js -ok 828 — intersectionBy is a Function -ok 829 — Returns a list of elements that exist in both arrays, after applying the provided function to each array element of both +ok 876 — intersectionBy is a Function +ok 877 — Returns a list of elements that exist in both arrays, after applying the provided function to each array element of both # PASS test/minDate.test.js -ok 830 — minDate is a Function -ok 831 — minDate produces the maximum date +ok 878 — minDate is a Function +ok 879 — minDate produces the maximum date # PASS test/getURLParameters.test.js -ok 832 — getURLParameters is a Function -ok 833 — Returns an object containing the parameters of the current URL +ok 880 — getURLParameters is a Function +ok 881 — Returns an object containing the parameters of the current URL # PASS test/pipeFunctions.test.js -ok 834 — pipeFunctions is a Function -ok 835 — Performs left-to-right function composition +ok 882 — pipeFunctions is a Function +ok 883 — Performs left-to-right function composition # PASS test/reduceSuccessive.test.js -ok 836 — reduceSuccessive is a Function -ok 837 — Returns the array of successively reduced values +ok 884 — reduceSuccessive is a Function +ok 885 — Returns the array of successively reduced values # PASS test/chainAsync.test.js -ok 838 — chainAsync is a Function -ok 839 — Calls all functions in an array +ok 886 — chainAsync is a Function +ok 887 — Calls all functions in an array # PASS test/sumBy.test.js -ok 840 — sumBy is a Function -ok 841 — Works with a callback. -ok 842 — Works with a property name. +ok 888 — sumBy is a Function +ok 889 — Works with a callback. +ok 890 — Works with a property name. # PASS test/countBy.test.js -ok 843 — countBy is a Function -ok 844 — Works for functions -ok 845 — Works for property names +ok 891 — countBy is a Function +ok 892 — Works for functions +ok 893 — Works for property names # PASS test/insertBefore.test.js -ok 846 — insertBefore is a Function -ok 847 — Does not throw error if the element exists +ok 894 — insertBefore is a Function +ok 895 — Does not throw error if the element exists # PASS test/cleanObj.test.js -ok 848 — cleanObj is a Function -ok 849 — Removes any properties except the ones specified from a JSON object +ok 896 — cleanObj is a Function +ok 897 — Removes any properties except the ones specified from a JSON object # PASS test/runPromisesInSeries.test.js -ok 850 — runPromisesInSeries is a Function -ok 851 — Runs promises in series +ok 898 — runPromisesInSeries is a Function +ok 899 — Runs promises in series # PASS test/overArgs.test.js -ok 852 — overArgs is a Function -ok 853 — Invokes the provided function with its arguments transformed +ok 900 — overArgs is a Function +ok 901 — Invokes the provided function with its arguments transformed # PASS test/insertAfter.test.js -ok 854 — insertAfter is a Function -ok 855 — Does not throw error if the element exists +ok 902 — insertAfter is a Function +ok 903 — Does not throw error if the element exists + +# PASS test/once.test.js + +ok 904 — once is a Function +ok 905 — once returns Function +ok 906 — once returns the result only once # PASS test/hashNode.test.js -ok 856 — hashNode is a Function -ok 857 — Produces the appropriate hash +ok 907 — hashNode is a Function +ok 908 — Produces the appropriate hash # PASS test/spreadOver.test.js -ok 858 — spreadOver is a Function -ok 859 — Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. +ok 909 — spreadOver is a Function +ok 910 — Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. # PASS test/decapitalize.test.js -ok 860 — decapitalize is a Function -ok 861 — Works with default parameter -ok 862 — Works with second parameter set to true +ok 911 — decapitalize is a Function +ok 912 — Works with default parameter +ok 913 — Works with second parameter set to true # PASS test/minN.test.js -ok 863 — minN is a Function -ok 864 — Returns the n minimum elements from the provided array -ok 865 — Returns the n minimum elements from the provided array +ok 914 — minN is a Function +ok 915 — Returns the n minimum elements from the provided array +ok 916 — Returns the n minimum elements from the provided array # PASS test/maxN.test.js -ok 866 — maxN is a Function -ok 867 — Returns the n maximum elements from the provided array -ok 868 — Returns the n maximum elements from the provided array +ok 917 — maxN is a Function +ok 918 — Returns the n maximum elements from the provided array +ok 919 — Returns the n maximum elements from the provided array # PASS test/shallowClone.test.js -ok 869 — shallowClone is a Function -ok 870 — Shallow cloning works -ok 871 — Does not clone deeply +ok 920 — shallowClone is a Function +ok 921 — Shallow cloning works +ok 922 — Does not clone deeply # PASS test/isArmstrongNumber.test.js -ok 872 — isArmstrongNumber is a Function -ok 873 — isArmstrongNumber returns true -ok 874 — isArmstrongNumber returns false +ok 923 — isArmstrongNumber is a Function +ok 924 — isArmstrongNumber returns true +ok 925 — isArmstrongNumber returns false # PASS test/when.test.js -ok 875 — when is a Function -ok 876 — Returns the proper result -ok 877 — Returns the proper result +ok 926 — when is a Function +ok 927 — Returns the proper result +ok 928 — Returns the proper result # PASS test/flatten.test.js -ok 878 — flatten is a Function -ok 879 — Flattens an array -ok 880 — Flattens an array +ok 929 — flatten is a Function +ok 930 — Flattens an array +ok 931 — Flattens an array # PASS test/partialRight.test.js -ok 881 — partialRight is a Function -ok 882 — Appends arguments +ok 932 — partialRight is a Function +ok 933 — Appends arguments -# PASS test/composeRight.test.js +# PASS test/toggleClass.test.js -ok 883 — composeRight is a Function -ok 884 — Performs left-to-right function composition +ok 934 — toggleClass is a Function +ok 935 — toggleClass toggles the class -# PASS test/permutations.test.js +# PASS test/composeRight.test.js -ok 885 — permutations is a Function -ok 886 — Generates all permutations of an array +ok 936 — composeRight is a Function +ok 937 — Performs left-to-right function composition # PASS test/compose.test.js -ok 887 — compose is a Function -ok 888 — Performs right-to-left function composition +ok 938 — compose is a Function +ok 939 — Performs right-to-left function composition # PASS test/lcm.test.js -ok 889 — lcm is a Function -ok 890 — Returns the least common multiple of two or more numbers. -ok 891 — Returns the least common multiple of two or more numbers. +ok 940 — lcm is a Function +ok 941 — Returns the least common multiple of two or more numbers. +ok 942 — Returns the least common multiple of two or more numbers. # PASS test/splitLines.test.js -ok 892 — splitLines is a Function -ok 893 — Splits a multiline string into an array of lines. +ok 943 — splitLines is a Function +ok 944 — Splits a multiline string into an array of lines. # PASS test/solveRPN.test.js -ok 894 — solveRPN is a Function -ok 895 — solveRPN returns the correct result -ok 896 — solveRPN returns the correct result +ok 945 — solveRPN is a Function +ok 946 — solveRPN returns the correct result +ok 947 — solveRPN returns the correct result # PASS test/bindAll.test.js -ok 897 — bindAll is a Function -ok 898 — Binds to an object context +ok 948 — bindAll is a Function +ok 949 — Binds to an object context -# PASS test/sortedLastIndexBy.test.js +# PASS test/percentile.test.js -ok 899 — sortedLastIndexBy is a Function -ok 900 — Returns the highest index to insert the element without messing up the list order +ok 950 — percentile is a Function +ok 951 — Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value. -# PASS test/percentile.test.js +# PASS test/httpDelete.test.js -ok 901 — percentile is a Function -ok 902 — Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value. +ok 952 — httpDelete is a Function +ok 953 — httpDelete does not throw errors # PASS test/getDaysDiffBetweenDates.test.js -ok 903 — getDaysDiffBetweenDates is a Function -ok 904 — Returns the difference in days between two dates +ok 954 — getDaysDiffBetweenDates is a Function +ok 955 — Returns the difference in days between two dates # PASS test/differenceWith.test.js -ok 905 — differenceWith is a Function -ok 906 — Filters out all values from an array +ok 956 — differenceWith is a Function +ok 957 — Filters out all values from an array # PASS test/countVowels.test.js -ok 907 — countVowels is a Function -ok 908 — countVowels returns the correct count -ok 909 — countVowels returns the correct count +ok 958 — countVowels is a Function +ok 959 — countVowels returns the correct count +ok 960 — countVowels returns the correct count # PASS test/partial.test.js -ok 910 — partial is a Function -ok 911 — Prepends arguments +ok 961 — partial is a Function +ok 962 — Prepends arguments # PASS test/size.test.js -ok 912 — size is a Function -ok 913 — Get size of arrays, objects or strings. -ok 914 — Get size of arrays, objects or strings. +ok 963 — size is a Function +ok 964 — Get size of arrays, objects or strings. +ok 965 — Get size of arrays, objects or strings. # PASS test/mapValues.test.js -ok 915 — mapValues is a Function -ok 916 — Maps values +ok 966 — mapValues is a Function +ok 967 — Maps values # PASS test/unionWith.test.js -ok 917 — unionWith is a Function -ok 918 — Produces the appropriate results +ok 968 — unionWith is a Function +ok 969 — Produces the appropriate results # PASS test/palindrome.test.js -ok 919 — palindrome is a Function -ok 920 — Given string is a palindrome -ok 921 — Given string is not a palindrome +ok 970 — palindrome is a Function +ok 971 — Given string is a palindrome +ok 972 — Given string is not a palindrome # PASS test/bifurcate.test.js -ok 922 — bifurcate is a Function -ok 923 — Splits the collection into two groups +ok 973 — bifurcate is a Function +ok 974 — Splits the collection into two groups # PASS test/bifurcateBy.test.js -ok 924 — bifurcateBy is a Function -ok 925 — Splits the collection into two groups +ok 975 — bifurcateBy is a Function +ok 976 — Splits the collection into two groups # PASS test/attempt.test.js -ok 926 — attempt is a Function -ok 927 — Returns a value -ok 928 — Returns an error +ok 977 — attempt is a Function +ok 978 — Returns a value +ok 979 — Returns an error # PASS test/getColonTimeFromDate.test.js -ok 929 — getColonTimeFromDate is a Function -ok 930 — Gets the time in the proper format. +ok 980 — getColonTimeFromDate is a Function +ok 981 — Gets the time in the proper format. # PASS test/degreesToRads.test.js -ok 931 — degreesToRads is a Function -ok 932 — Returns the appropriate value +ok 982 — degreesToRads is a Function +ok 983 — Returns the appropriate value # PASS test/rearg.test.js -ok 933 — rearg is a Function -ok 934 — Reorders arguments in invoked function +ok 984 — rearg is a Function +ok 985 — Reorders arguments in invoked function + +# PASS test/getStyle.test.js + +ok 986 — getStyle is a Function +ok 987 — getStyle returns the proper value + +# PASS test/httpPost.test.js + +ok 988 — httpPost is a Function +ok 989 — httpPost does not throw errors # PASS test/forOwnRight.test.js -ok 935 — forOwnRight is a Function -ok 936 — Iterates over an element's key-value pairs in reverse +ok 990 — forOwnRight is a Function +ok 991 — Iterates over an element's key-value pairs in reverse # PASS test/pickBy.test.js -ok 937 — pickBy is a Function -ok 938 — Creates an object composed of the properties the given function returns truthy for. +ok 992 — pickBy is a Function +ok 993 — Creates an object composed of the properties the given function returns truthy for. # PASS test/flip.test.js -ok 939 — flip is a Function -ok 940 — Flips argument order +ok 994 — flip is a Function +ok 995 — Flips argument order -# PASS test/sortedIndexBy.test.js +# PASS test/httpPut.test.js -ok 941 — sortedIndexBy is a Function -ok 942 — Returns the lowest index to insert the element without messing up the list order +ok 996 — httpPut is a Function +ok 997 — httpPut does not throw errors # PASS test/dropRightWhile.test.js -ok 943 — dropRightWhile is a Function -ok 944 — Removes elements from the end of an array until the passed function returns true. +ok 998 — dropRightWhile is a Function +ok 999 — Removes elements from the end of an array until the passed function returns true. # PASS test/isSimilar.test.js -ok 945 — isSimilar is a Function -ok 946 — isSimilar returns true -ok 947 — isSimilar returns false +ok 1000 — isSimilar is a Function +ok 1001 — isSimilar returns true +ok 1002 — isSimilar returns false # PASS test/get.test.js -ok 948 — get is a Function -ok 949 — Retrieve a property indicated by the selector from an object. +ok 1003 — get is a Function +ok 1004 — Retrieve a property indicated by the selector from an object. + +# PASS test/httpGet.test.js + +ok 1005 — httpGet is a Function +ok 1006 — httpGet does not throw errors # PASS test/omitBy.test.js -ok 950 — omitBy is a Function -ok 951 — Creates an object composed of the properties the given function returns falsey for +ok 1007 — omitBy is a Function +ok 1008 — Creates an object composed of the properties the given function returns falsey for # PASS test/compact.test.js -ok 952 — compact is a Function -ok 953 — Removes falsey values from an array +ok 1009 — compact is a Function +ok 1010 — Removes falsey values from an array # PASS test/unescapeHTML.test.js -ok 954 — unescapeHTML is a Function -ok 955 — Unescapes escaped HTML characters. +ok 1011 — unescapeHTML is a Function +ok 1012 — Unescapes escaped HTML characters. # PASS test/createElement.test.js -ok 956 — createElement is a Function -ok 957 — createElement creates an element +ok 1013 — createElement is a Function +ok 1014 — createElement creates an element # PASS test/isFunction.test.js -ok 958 — isFunction is a Function -ok 959 — passed value is a function -ok 960 — passed value is not a function +ok 1015 — isFunction is a Function +ok 1016 — passed value is a function +ok 1017 — passed value is not a function # PASS test/pullBy.test.js -ok 961 — pullBy is a Function -ok 962 — Pulls the specified values +ok 1018 — pullBy is a Function +ok 1019 — Pulls the specified values # PASS test/removeVowels.test.js -ok 963 — removeVowels is a Function -ok 964 — Removes vowels. -ok 965 — Replaces vowels. +ok 1020 — removeVowels is a Function +ok 1021 — Removes vowels. +ok 1022 — Replaces vowels. -# PASS test/sortedLastIndex.test.js +# PASS test/isBoolean.test.js -ok 966 — sortedLastIndex is a Function -ok 967 — Returns the highest index to insert the element without messing up the list order +ok 1023 — isBoolean is a Function +ok 1024 — passed value is not a boolean +ok 1025 — passed value is not a boolean -# PASS test/isBoolean.test.js +# PASS test/throttle.test.js -ok 968 — isBoolean is a Function -ok 969 — passed value is not a boolean -ok 970 — passed value is not a boolean +ok 1026 — throttle is a Function +ok 1027 — throttle returns a function # PASS test/escapeHTML.test.js -ok 971 — escapeHTML is a Function -ok 972 — Escapes a string for use in HTML +ok 1028 — escapeHTML is a Function +ok 1029 — Escapes a string for use in HTML + +# PASS test/show.test.js + +ok 1030 — show is a Function +ok 1031 — show shows an element + +# PASS test/hasClass.test.js + +ok 1032 — hasClass is a Function +ok 1033 — hasClass returns the proper value # PASS test/xProd.test.js -ok 973 — xProd is a Function -ok 974 — xProd([1, 2], ['a', 'b']) returns [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] +ok 1034 — xProd is a Function +ok 1035 — xProd([1, 2], ['a', 'b']) returns [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] # PASS test/unflattenObject.test.js -ok 975 — unflattenObject is a Function -ok 976 — Unflattens an object with the paths for keys +ok 1036 — unflattenObject is a Function +ok 1037 — Unflattens an object with the paths for keys # PASS test/isNumber.test.js -ok 977 — isNumber is a Function -ok 978 — passed argument is a number -ok 979 — passed argument is not a number +ok 1038 — isNumber is a Function +ok 1039 — passed argument is a number +ok 1040 — passed argument is not a number # PASS test/stableSort.test.js -ok 980 — stableSort is a Function -ok 981 — Array is properly sorted +ok 1041 — stableSort is a Function +ok 1042 — Array is properly sorted # PASS test/sortCharactersInString.test.js -ok 982 — sortCharactersInString is a Function -ok 983 — Alphabetically sorts the characters in a string. +ok 1043 — sortCharactersInString is a Function +ok 1044 — Alphabetically sorts the characters in a string. + +# PASS test/hide.test.js + +ok 1045 — hide is a Function +ok 1046 — hide hides an element # PASS test/unfold.test.js -ok 984 — unfold is a Function -ok 985 — Works with a given function, producing an array +ok 1047 — unfold is a Function +ok 1048 — Works with a given function, producing an array # PASS test/forEachRight.test.js -ok 986 — forEachRight is a Function -ok 987 — Iterates over the array in reverse +ok 1049 — forEachRight is a Function +ok 1050 — Iterates over the array in reverse # PASS test/ary.test.js -ok 988 — ary is a Function -ok 989 — Discards arguments with index >=n +ok 1051 — ary is a Function +ok 1052 — Discards arguments with index >=n # PASS test/stripHTMLTags.test.js -ok 990 — stripHTMLTags is a Function -ok 991 — Removes HTML tags +ok 1053 — stripHTMLTags is a Function +ok 1054 — Removes HTML tags # PASS test/objectToPairs.test.js -ok 992 — objectToPairs is a Function -ok 993 — Creates an array of key-value pair arrays from an object. +ok 1055 — objectToPairs is a Function +ok 1056 — Creates an array of key-value pair arrays from an object. # PASS test/objectFromPairs.test.js -ok 994 — objectFromPairs is a Function -ok 995 — Creates an object from the given key-value pairs. +ok 1057 — objectFromPairs is a Function +ok 1058 — Creates an object from the given key-value pairs. # PASS test/curry.test.js -ok 996 — curry is a Function -ok 997 — curries a Math.pow -ok 998 — curries a Math.min +ok 1059 — curry is a Function +ok 1060 — curries a Math.pow +ok 1061 — curries a Math.min # PASS test/toDecimalMark.test.js -ok 999 — toDecimalMark is a Function -ok 1000 — convert a float-point arithmetic to the Decimal mark form +ok 1062 — toDecimalMark is a Function +ok 1063 — convert a float-point arithmetic to the Decimal mark form # PASS test/forOwn.test.js -ok 1001 — forOwn is a Function -ok 1002 — Iterates over an element's key-value pairs +ok 1064 — forOwn is a Function +ok 1065 — Iterates over an element's key-value pairs + +# PASS test/isPrime.test.js + +ok 1066 — isPrime is a Function +ok 1067 — passed number is a prime +ok 1068 — passed number is not a prime # PASS test/findLastIndex.test.js -ok 1003 — findLastIndex is a Function -ok 1004 — Finds last index for which the given function returns true +ok 1069 — findLastIndex is a Function +ok 1070 — Finds last index for which the given function returns true # PASS test/pick.test.js -ok 1005 — pick is a Function -ok 1006 — Picks the key-value pairs corresponding to the given keys from an object. +ok 1071 — pick is a Function +ok 1072 — Picks the key-value pairs corresponding to the given keys from an object. # PASS test/isNull.test.js -ok 1007 — isNull is a Function -ok 1008 — passed argument is a null -ok 1009 — passed argument is a null +ok 1073 — isNull is a Function +ok 1074 — passed argument is a null +ok 1075 — passed argument is a null # PASS test/filterNonUnique.test.js -ok 1010 — filterNonUnique is a Function -ok 1011 — Filters out the non-unique values in an array +ok 1076 — filterNonUnique is a Function +ok 1077 — Filters out the non-unique values in an array # PASS test/dropWhile.test.js -ok 1012 — dropWhile is a Function -ok 1013 — Removes elements in an array until the passed function returns true. +ok 1078 — dropWhile is a Function +ok 1079 — Removes elements in an array until the passed function returns true. # PASS test/takeRightWhile.test.js -ok 1014 — takeRightWhile is a Function -ok 1015 — Removes elements until the function returns true +ok 1080 — takeRightWhile is a Function +ok 1081 — Removes elements until the function returns true # PASS test/atob.test.js -ok 1016 — atob is a Function -ok 1017 — atob("Zm9vYmFy") equals "foobar" -ok 1018 — atob("Z") returns "" +ok 1082 — atob is a Function +ok 1083 — atob("Zm9vYmFy") equals "foobar" +ok 1084 — atob("Z") returns "" # PASS test/removeNonASCII.test.js -ok 1019 — removeNonASCII is a Function -ok 1020 — Removes non-ASCII characters +ok 1085 — removeNonASCII is a Function +ok 1086 — Removes non-ASCII characters + +# PASS test/nodeListToArray.test.js + +ok 1087 — nodeListToArray is a Function +ok 1088 — nodeListToArray returns an array of proper length # PASS test/delay.test.js -ok 1021 — delay is a Function -ok 1022 — Works as expecting, passing arguments properly +ok 1089 — delay is a Function +ok 1090 — Works as expecting, passing arguments properly # PASS test/remove.test.js -ok 1023 — remove is a Function -ok 1024 — Removes elements from an array for which the given function returns false +ok 1091 — remove is a Function +ok 1092 — Removes elements from an array for which the given function returns false # PASS test/hz.test.js -ok 1025 — hz is a Function -ok 1026 — hz returns a number -ok 1027 — hz returns a number +ok 1093 — hz is a Function +ok 1094 — hz returns a number +ok 1095 — hz returns a number # PASS test/defaults.test.js -ok 1028 — defaults is a Function -ok 1029 — Assigns default values for undefined properties +ok 1096 — defaults is a Function +ok 1097 — Assigns default values for undefined properties # PASS test/countOccurrences.test.js -ok 1030 — countOccurrences is a Function -ok 1031 — Counts the occurrences of a value in an array +ok 1098 — countOccurrences is a Function +ok 1099 — Counts the occurrences of a value in an array # PASS test/omit.test.js -ok 1032 — omit is a Function -ok 1033 — Omits the key-value pairs corresponding to the given keys from an object +ok 1100 — omit is a Function +ok 1101 — Omits the key-value pairs corresponding to the given keys from an object # PASS test/clampNumber.test.js -ok 1034 — clampNumber is a Function -ok 1035 — Clamps num within the inclusive range specified by the boundary values a and b +ok 1102 — clampNumber is a Function +ok 1103 — Clamps num within the inclusive range specified by the boundary values a and b # PASS test/intersection.test.js -ok 1036 — intersection is a Function -ok 1037 — Returns a list of elements that exist in both arrays +ok 1104 — intersection is a Function +ok 1105 — Returns a list of elements that exist in both arrays # PASS test/over.test.js -ok 1038 — over is a Function -ok 1039 — Applies given functions over multiple arguments +ok 1106 — over is a Function +ok 1107 — Applies given functions over multiple arguments # PASS test/truncateString.test.js -ok 1040 — truncateString is a Function -ok 1041 — Truncates a "boomerang" up to a specified length. +ok 1108 — truncateString is a Function +ok 1109 — Truncates a "boomerang" up to a specified length. # PASS test/parseCookie.test.js -ok 1042 — parseCookie is a Function -ok 1043 — Parses the cookie +ok 1110 — parseCookie is a Function +ok 1111 — Parses the cookie # PASS test/pull.test.js -ok 1044 — pull is a Function -ok 1045 — Pulls the specified values +ok 1112 — pull is a Function +ok 1113 — Pulls the specified values # PASS test/isBrowserTabFocused.test.js -ok 1046 — isBrowserTabFocused is a Function -ok 1047 — isBrowserTabFocused is a Function +ok 1114 — isBrowserTabFocused is a Function +ok 1115 — isBrowserTabFocused is a Function # PASS test/similarity.test.js -ok 1048 — similarity is a Function -ok 1049 — Returns an array of elements that appear in both arrays. +ok 1116 — similarity is a Function +ok 1117 — Returns an array of elements that appear in both arrays. # PASS test/isEven.test.js -ok 1050 — isEven is a Function -ok 1051 — 4 is even number -ok 1052 — 5 is not an even number +ok 1118 — isEven is a Function +ok 1119 — 4 is even number +ok 1120 — 5 is not an even number # PASS test/findLast.test.js -ok 1053 — findLast is a Function -ok 1054 — Finds last element for which the given function returns true +ok 1121 — findLast is a Function +ok 1122 — Finds last element for which the given function returns true # PASS test/fibonacciUntilNum.test.js -ok 1055 — fibonacciUntilNum is a Function -ok 1056 — Returns the correct sequence +ok 1123 — fibonacciUntilNum is a Function +ok 1124 — Returns the correct sequence # PASS test/times.test.js -ok 1057 — times is a Function -ok 1058 — Runs a function the specified amount of times +ok 1125 — times is a Function +ok 1126 — Runs a function the specified amount of times # PASS test/fibonacciCountUntilNum.test.js -ok 1059 — fibonacciCountUntilNum is a Function -ok 1060 — Returns the correct number +ok 1127 — fibonacciCountUntilNum is a Function +ok 1128 — Returns the correct number # PASS test/cloneRegExp.test.js -ok 1061 — cloneRegExp is a Function -ok 1062 — Clones regular expressions properly +ok 1129 — cloneRegExp is a Function +ok 1130 — Clones regular expressions properly # PASS test/coalesce.test.js -ok 1063 — coalesce is a Function -ok 1064 — Returns the first non-null/undefined argument +ok 1131 — coalesce is a Function +ok 1132 — Returns the first non-null/undefined argument # PASS test/escapeRegExp.test.js -ok 1065 — escapeRegExp is a Function -ok 1066 — Escapes a string to use in a regular expression +ok 1133 — escapeRegExp is a Function +ok 1134 — Escapes a string to use in a regular expression # PASS test/JSONToDate.test.js -ok 1067 — JSONToDate is a Function -ok 1068 — JSONToDate returns the correct date string +ok 1135 — JSONToDate is a Function +ok 1136 — JSONToDate returns the correct date string # PASS test/tail.test.js -ok 1069 — tail is a Function -ok 1070 — Returns tail -ok 1071 — Returns tail +ok 1137 — tail is a Function +ok 1138 — Returns tail +ok 1139 — Returns tail # PASS test/primes.test.js -ok 1072 — primes is a Function -ok 1073 — Generates primes up to a given number, using the Sieve of Eratosthenes. +ok 1140 — primes is a Function +ok 1141 — Generates primes up to a given number, using the Sieve of Eratosthenes. # PASS test/powerset.test.js -ok 1074 — powerset is a Function -ok 1075 — Returns the powerset of a given array of numbers. +ok 1142 — powerset is a Function +ok 1143 — Returns the powerset of a given array of numbers. # PASS test/fibonacci.test.js -ok 1076 — fibonacci is a Function -ok 1077 — Generates an array, containing the Fibonacci sequence +ok 1144 — fibonacci is a Function +ok 1145 — Generates an array, containing the Fibonacci sequence # PASS test/distance.test.js -ok 1078 — distance is a Function -ok 1079 — Calculates the distance between two points +ok 1146 — distance is a Function +ok 1147 — Calculates the distance between two points # PASS test/difference.test.js -ok 1080 — difference is a Function -ok 1081 — Returns the difference between two arrays +ok 1148 — difference is a Function +ok 1149 — Returns the difference between two arrays # PASS test/negate.test.js -ok 1082 — negate is a Function -ok 1083 — Negates a predicate function +ok 1150 — negate is a Function +ok 1151 — Negates a predicate function # PASS test/deepFlatten.test.js -ok 1084 — deepFlatten is a Function -ok 1085 — Deep flattens an array +ok 1152 — deepFlatten is a Function +ok 1153 — Deep flattens an array # PASS test/RGBToHex.test.js -ok 1086 — RGBToHex is a Function -ok 1087 — Converts the values of RGB components to a color code. +ok 1154 — RGBToHex is a Function +ok 1155 — Converts the values of RGB components to a color code. # PASS test/hammingDistance.test.js -ok 1088 — hammingDistance is a Function -ok 1089 — retuns hamming disance between 2 values +ok 1156 — hammingDistance is a Function +ok 1157 — retuns hamming disance between 2 values # PASS test/currentURL.test.js -ok 1090 — currentURL is a Function -ok 1091 — currentURL returns the appropriate value +ok 1158 — currentURL is a Function +ok 1159 — currentURL returns the appropriate value # PASS test/everyNth.test.js -ok 1092 — everyNth is a Function -ok 1093 — Returns every nth element in an array +ok 1160 — everyNth is a Function +ok 1161 — Returns every nth element in an array # PASS test/initial.test.js -ok 1094 — initial is a Function -ok 1095 — Returns all the elements of an array except the last one +ok 1162 — initial is a Function +ok 1163 — Returns all the elements of an array except the last one # PASS test/unionBy.test.js -ok 1096 — unionBy is a Function -ok 1097 — Produces the appropriate results +ok 1164 — unionBy is a Function +ok 1165 — Produces the appropriate results # PASS test/serializeCookie.test.js -ok 1098 — serializeCookie is a Function -ok 1099 — Serializes the cookie +ok 1166 — serializeCookie is a Function +ok 1167 — Serializes the cookie # PASS test/sleep.test.js -ok 1100 — sleep is a Function -ok 1101 — Works as expected +ok 1168 — sleep is a Function +ok 1169 — Works as expected # PASS test/unary.test.js -ok 1102 — unary is a Function -ok 1103 — Discards arguments after the first one +ok 1170 — unary is a Function +ok 1171 — Discards arguments after the first one + +# PASS test/bottomVisible.test.js + +ok 1172 — bottomVisible is a Function +ok 1173 — bottomVisible returns a boolean # PASS test/mapKeys.test.js -ok 1104 — mapKeys is a Function -ok 1105 — Maps keys +ok 1174 — mapKeys is a Function +ok 1175 — Maps keys # PASS test/radsToDegrees.test.js -ok 1106 — radsToDegrees is a Function -ok 1107 — Returns the appropriate value +ok 1176 — radsToDegrees is a Function +ok 1177 — Returns the appropriate value # PASS test/isSymbol.test.js -ok 1108 — isSymbol is a Function -ok 1109 — Checks if the given argument is a symbol +ok 1178 — isSymbol is a Function +ok 1179 — Checks if the given argument is a symbol # PASS test/digitize.test.js -ok 1110 — digitize is a Function -ok 1111 — Converts a number to an array of digits +ok 1180 — digitize is a Function +ok 1181 — Converts a number to an array of digits # PASS test/call.test.js -ok 1112 — call is a Function -ok 1113 — Calls function on given object +ok 1182 — call is a Function +ok 1183 — Calls function on given object # PASS test/reverseString.test.js -ok 1114 — reverseString is a Function -ok 1115 — Reverses a string. +ok 1184 — reverseString is a Function +ok 1185 — Reverses a string. # PASS test/isUndefined.test.js -ok 1116 — isUndefined is a Function -ok 1117 — Returns true for undefined +ok 1186 — isUndefined is a Function +ok 1187 — Returns true for undefined # PASS test/isDivisible.test.js -ok 1118 — isDivisible is a Function -ok 1119 — The number 6 is divisible by 3 +ok 1188 — isDivisible is a Function +ok 1189 — The number 6 is divisible by 3 # PASS test/heronArea.test.js -ok 1120 — heronArea is a Function -ok 1121 — howManyTimes returns the correct result +ok 1190 — heronArea is a Function +ok 1191 — howManyTimes returns the correct result # PASS test/colorize.test.js -ok 1122 — colorize is a Function -ok 1123 — Returns the appropriate value +ok 1192 — colorize is a Function +ok 1193 — Returns the appropriate value + +# PASS test/squareSum.test.js + +ok 1194 — squareSum is a Function +ok 1195 — squareSum returns the proper result # PASS test/sdbm.test.js -ok 1124 — sdbm is a Function -ok 1125 — Hashes the input string into a whole number. +ok 1196 — sdbm is a Function +ok 1197 — Hashes the input string into a whole number. # PASS test/mphToKmph.test.js -ok 1126 — mphToKmph is a Function -ok 1127 — Returns kph from mph. +ok 1198 — mphToKmph is a Function +ok 1199 — Returns kph from mph. # PASS test/debounce.test.js -ok 1128 — debounce is a Function -ok 1129 — Works as expected +ok 1200 — debounce is a Function +ok 1201 — Works as expected # PASS test/sum.test.js -ok 1130 — sum is a Function -ok 1131 — Returns the sum of two or more numbers/arrays. +ok 1202 — sum is a Function +ok 1203 — Returns the sum of two or more numbers/arrays. # PASS test/isBrowser.test.js -ok 1132 — isBrowser is a Function -ok 1133 — isBrowser is a Function +ok 1204 — isBrowser is a Function +ok 1205 — isBrowser is a Function # PASS test/prefix.test.js -ok 1134 — prefix is a Function -ok 1135 — prefix is a Function +ok 1206 — prefix is a Function +ok 1207 — prefix is a Function # PASS test/timeTaken.test.js -ok 1136 — timeTaken is a Function -ok 1137 — timeTaken is a Function +ok 1208 — timeTaken is a Function +ok 1209 — timeTaken is a Function # PASS test/kmphToMph.test.js -ok 1138 — kmphToMph is a Function -ok 1139 — Returns mph from kph. +ok 1210 — kmphToMph is a Function +ok 1211 — Returns mph from kph. # PASS test/pipeLog.test.js -ok 1140 — pipeLog is a Function -ok 1141 — pipeLog returns the given value +ok 1212 — pipeLog is a Function +ok 1213 — pipeLog returns the given value # PASS test/btoa.test.js -ok 1142 — btoa is a Function -ok 1143 — btoa("foobar") equals "Zm9vYmFy" - -# PASS test/isPrime.test.js - -ok 1144 — isPrime is a Function -ok 1145 — passed number is a prime - -# PASS test/once.test.js - -ok 1146 — once is a Function -ok 1147 — once is a Function - -# PASS test/elementIsVisibleInViewport.test.js - -ok 1148 — elementIsVisibleInViewport is a Function +ok 1214 — btoa is a Function +ok 1215 — btoa("foobar") equals "Zm9vYmFy" # PASS test/recordAnimationFrames.test.js -ok 1149 — recordAnimationFrames is a Function +ok 1216 — recordAnimationFrames is a Function # PASS test/UUIDGeneratorBrowser.test.js -ok 1150 — UUIDGeneratorBrowser is a Function - -# PASS test/getScrollPosition.test.js - -ok 1151 — getScrollPosition is a Function +ok 1217 — UUIDGeneratorBrowser is a Function # PASS test/onUserInputChange.test.js -ok 1152 — onUserInputChange is a Function +ok 1218 — onUserInputChange is a Function # PASS test/detectDeviceType.test.js -ok 1153 — detectDeviceType is a Function +ok 1219 — detectDeviceType is a Function # PASS test/observeMutations.test.js -ok 1154 — observeMutations is a Function - -# PASS test/nodeListToArray.test.js - -ok 1155 — nodeListToArray is a Function +ok 1220 — observeMutations is a Function # PASS test/speechSynthesis.test.js -ok 1156 — speechSynthesis is a Function - -# PASS test/copyToClipboard.test.js - -ok 1157 — copyToClipboard is a Function +ok 1221 — speechSynthesis is a Function # PASS test/arrayToHtmlList.test.js -ok 1158 — arrayToHtmlList is a Function - -# PASS test/elementContains.test.js - -ok 1159 — elementContains is a Function - -# PASS test/createEventHub.test.js - -ok 1160 — createEventHub is a Function +ok 1222 — arrayToHtmlList is a Function # PASS test/readFileLines.test.js -ok 1161 — readFileLines is a Function +ok 1223 — readFileLines is a Function # PASS test/httpsRedirect.test.js -ok 1162 — httpsRedirect is a Function - -# PASS test/bottomVisible.test.js - -ok 1163 — bottomVisible is a Function +ok 1224 — httpsRedirect is a Function # PASS test/smoothScroll.test.js -ok 1164 — smoothScroll is a Function - -# PASS test/triggerEvent.test.js - -ok 1165 — triggerEvent is a Function +ok 1225 — smoothScroll is a Function # PASS test/hashBrowser.test.js -ok 1166 — hashBrowser is a Function - -# PASS test/toggleClass.test.js - -ok 1167 — toggleClass is a Function +ok 1226 — hashBrowser is a Function # PASS test/scrollToTop.test.js -ok 1168 — scrollToTop is a Function - -# PASS test/httpDelete.test.js - -ok 1169 — httpDelete is a Function +ok 1227 — scrollToTop is a Function # PASS test/JSONToFile.test.js -ok 1170 — JSONToFile is a Function +ok 1228 — JSONToFile is a Function # PASS test/dayOfYear.test.js -ok 1171 — dayOfYear is a Function - -# PASS test/squareSum.test.js - -ok 1172 — squareSum is a Function +ok 1229 — dayOfYear is a Function # PASS test/hasFlags.test.js -ok 1173 — hasFlags is a Function +ok 1230 — hasFlags is a Function # PASS test/setStyle.test.js -ok 1174 — setStyle is a Function - -# PASS test/getStyle.test.js - -ok 1175 — getStyle is a Function +ok 1231 — setStyle is a Function # PASS test/redirect.test.js -ok 1176 — redirect is a Function - -# PASS test/httpPost.test.js - -ok 1177 — httpPost is a Function +ok 1232 — redirect is a Function # PASS test/runAsync.test.js -ok 1178 — runAsync is a Function - -# PASS test/hasClass.test.js - -ok 1179 — hasClass is a Function - -# PASS test/throttle.test.js - -ok 1180 — throttle is a Function - -# PASS test/httpPut.test.js - -ok 1181 — httpPut is a Function - -# PASS test/httpGet.test.js - -ok 1182 — httpGet is a Function - -# PASS test/counter.test.js - -ok 1183 — counter is a Function - -# PASS test/toHash.test.js - -ok 1184 — toHash is a Function +ok 1233 — runAsync is a Function # PASS test/defer.test.js -ok 1185 — defer is a Function - -# PASS test/show.test.js - -ok 1186 — show is a Function - -# PASS test/hide.test.js - -ok 1187 — hide is a Function - -# PASS test/off.test.js - -ok 1188 — off is a Function - -# PASS test/on.test.js - -ok 1189 — on is a Function +ok 1234 — defer is a Function -1..1189 +1..1234 # Test Suites: 100% ██████████, 360 passed, 360 total -# Tests: 100% ██████████, 1189 passed, 1189 total -# Time: 28.805s +# Tests: 100% ██████████, 1234 passed, 1234 total +# Time: 29.405s # Ran all test suites. diff --git a/vscode_snippets/snippets.json b/vscode_snippets/snippets.json index b2eee7bfa08..ea5effec49c 100644 --- a/vscode_snippets/snippets.json +++ b/vscode_snippets/snippets.json @@ -1123,7 +1123,7 @@ "hide": { "prefix": "30s_hide", "body": [ - "const hide = els => els.forEach(e => (e.style.display = 'none'));" + "const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));" ], "description": "Hides all the elements specified.\n\nUse `NodeList.prototype.forEach()` to apply `display: none` to each element specified" },