diff --git a/dist/_30s.es5.js b/dist/_30s.es5.js index de2f6ad74..cbcbf9aa0 100644 --- a/dist/_30s.es5.js +++ b/dist/_30s.es5.js @@ -1,33 +1,8 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global._30s = {}))); -}(this, (function (exports) { 'use strict'; - - 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 fs = typeof require !== "undefined" && require('fs'); - - var JSONToFile = function JSONToFile(obj, filename) { - return fs.writeFile("".concat(filename, ".json"), JSON.stringify(obj, null, 2)); - }; + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { @@ -139,40 +114,9 @@ throw new TypeError("Invalid attempt to destructure non-iterable instance"); } - 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 crypto = typeof require !== "undefined" && require('crypto'); - 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 crypto$1 = typeof require !== "undefined" && require('crypto'); - - var UUIDGeneratorNode = function UUIDGeneratorNode() { - return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) { - return (c ^ crypto$1.randomBytes(1)[0] & 15 >> c / 4).toString(16); - }); - }; + var fs = typeof require !== "undefined" && require('fs'); var all = function all(arr) { var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Boolean; @@ -228,8 +172,8 @@ var attempt = function attempt(fn) { try { - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; } return fn.apply(void 0, args); @@ -239,8 +183,8 @@ }; var average = function average() { - for (var _len = arguments.length, nums = new Array(_len), _key = 0; _key < _len; _key++) { - nums[_key] = arguments[_key]; + for (var _len3 = arguments.length, nums = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + nums[_key3] = arguments[_key3]; } return nums.reduce(function (acc, val) { @@ -269,13 +213,13 @@ }; var bind = function bind(fn, context) { - for (var _len = arguments.length, boundArgs = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - boundArgs[_key - 2] = arguments[_key]; + for (var _len4 = arguments.length, boundArgs = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) { + boundArgs[_key4 - 2] = arguments[_key4]; } return function () { - for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; + for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { + args[_key5] = arguments[_key5]; } return fn.apply(context, boundArgs.concat(args)); @@ -283,8 +227,8 @@ }; var bindAll = function bindAll(obj) { - for (var _len = arguments.length, fns = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - fns[_key - 1] = arguments[_key]; + for (var _len6 = arguments.length, fns = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) { + fns[_key6 - 1] = arguments[_key6]; } return fns.forEach(function (fn) { @@ -295,13 +239,13 @@ }; var bindKey = function bindKey(context, fn) { - for (var _len = arguments.length, boundArgs = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - boundArgs[_key - 2] = arguments[_key]; + for (var _len7 = arguments.length, boundArgs = new Array(_len7 > 2 ? _len7 - 2 : 0), _key7 = 2; _key7 < _len7; _key7++) { + boundArgs[_key7 - 2] = arguments[_key7]; } return function () { - for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; + for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { + args[_key8] = arguments[_key8]; } return context[fn].apply(context, boundArgs.concat(args)); @@ -336,8 +280,8 @@ }; var call = function call(key) { - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + for (var _len9 = arguments.length, args = new Array(_len9 > 1 ? _len9 - 1 : 0), _key9 = 1; _key9 < _len9; _key9++) { + args[_key9 - 1] = arguments[_key9]; } return function (context) { @@ -391,8 +335,8 @@ }; var coalesce = function coalesce() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) { + args[_key10] = arguments[_key10]; } return args.find(function (_) { @@ -402,8 +346,8 @@ var coalesceFactory = function coalesceFactory(valid) { return function () { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) { + args[_key11] = arguments[_key11]; } return args.find(valid); @@ -412,8 +356,8 @@ var collectInto = function collectInto(fn) { return function () { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) { + args[_key12] = arguments[_key12]; } return fn(args); @@ -421,8 +365,8 @@ }; var colorize = function colorize() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) { + args[_key13] = arguments[_key13]; } return { @@ -450,8 +394,8 @@ }; var compose = function compose() { - for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) { - fns[_key] = arguments[_key]; + for (var _len14 = arguments.length, fns = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) { + fns[_key14] = arguments[_key14]; } return fns.reduce(function (f, g) { @@ -462,8 +406,8 @@ }; var composeRight = function composeRight() { - for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) { - fns[_key] = arguments[_key]; + for (var _len15 = arguments.length, fns = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) { + fns[_key15] = arguments[_key15]; } return fns.reduce(function (f, g) { @@ -475,8 +419,8 @@ var converge = function converge(converger, fns) { return function () { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) { + args[_key16] = arguments[_key16]; } return converger.apply(void 0, _toConsumableArray(fns.map(function (fn) { @@ -506,18 +450,12 @@ var countBy = function countBy(arr, fn) { return arr.map(typeof fn === 'function' ? fn : function (val) { return val[fn]; - }).reduce(function (acc, val, i) { + }).reduce(function (acc, val) { acc[val] = (acc[val] || 0) + 1; return acc; }, {}); }; - 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; @@ -534,6 +472,12 @@ 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; @@ -561,6 +505,25 @@ }; }; + 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; }; @@ -568,8 +531,8 @@ var curry = function curry(fn) { var arity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : fn.length; - for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - args[_key - 2] = arguments[_key]; + for (var _len17 = arguments.length, args = new Array(_len17 > 2 ? _len17 - 2 : 0), _key17 = 2; _key17 < _len17; _key17++) { + args[_key17 - 2] = arguments[_key17]; } return arity <= args.length ? fn.apply(void 0, args) : curry.bind.apply(curry, [null, fn, arity].concat(args)); @@ -585,8 +548,8 @@ return function () { var _this = this; - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) { + args[_key18] = arguments[_key18]; } clearTimeout(timeoutId); @@ -596,10 +559,10 @@ }; }; - var decapitalize = function decapitalize(_ref) { - var _ref2 = _toArray(_ref), - first = _ref2[0], - rest = _ref2.slice(1); + var decapitalize = function decapitalize(_ref3) { + var _ref4 = _toArray(_ref3), + first = _ref4[0], + rest = _ref4.slice(1); var upperRest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; return first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join('')); @@ -614,30 +577,30 @@ }; var deepFlatten = function deepFlatten(arr) { - var _ref; + var _ref5; - return (_ref = []).concat.apply(_ref, _toConsumableArray(arr.map(function (v) { + return (_ref5 = []).concat.apply(_ref5, _toConsumableArray(arr.map(function (v) { return Array.isArray(v) ? deepFlatten(v) : v; }))); }; var deepFreeze = function deepFreeze(obj) { return Object.keys(obj).forEach(function (prop) { - return !obj[prop] instanceof Object || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop]); + return !(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop]); }) || Object.freeze(obj); }; var defaults = function defaults(obj) { - for (var _len = arguments.length, defs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - defs[_key - 1] = arguments[_key]; + for (var _len19 = arguments.length, defs = new Array(_len19 > 1 ? _len19 - 1 : 0), _key19 = 1; _key19 < _len19; _key19++) { + defs[_key19 - 1] = arguments[_key19]; } return Object.assign.apply(Object, [{}, obj].concat(_toConsumableArray(defs.reverse()), [obj])); }; var defer = function defer(fn) { - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + for (var _len20 = arguments.length, args = new Array(_len20 > 1 ? _len20 - 1 : 0), _key20 = 1; _key20 < _len20; _key20++) { + args[_key20 - 1] = arguments[_key20]; } return setTimeout.apply(void 0, [fn, 1].concat(args)); @@ -648,8 +611,8 @@ }; var delay = function delay(fn, wait) { - for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - args[_key - 2] = arguments[_key]; + for (var _len21 = arguments.length, args = new Array(_len21 > 2 ? _len21 - 2 : 0), _key21 = 2; _key21 < _len21; _key21++) { + args[_key21 - 2] = arguments[_key21]; } return setTimeout.apply(void 0, [fn, wait].concat(args)); @@ -667,9 +630,7 @@ }; var differenceBy = function differenceBy(a, b, fn) { - var s = new Set(b.map(function (v) { - return fn(v); - })); + var s = new Set(b.map(fn)); return a.filter(function (x) { return !s.has(fn(x)); }); @@ -745,9 +706,9 @@ 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; }; - var elo = function elo(_ref) { - var _ref2 = _toArray(_ref), - ratings = _ref2.slice(0); + var elo = function elo(_ref6) { + var _ref7 = _toArray(_ref6), + ratings = _ref7.slice(0); var kFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 32; var selfRating = arguments.length > 2 ? arguments[2] : undefined; @@ -764,9 +725,7 @@ return (selfRating || rating) + kFactor * (i - expectedScore(i ? a : b, i ? b : a)); }; - if (ratings.length === 2) { - return [newRating(a, 1), newRating(b, 0)]; - } + if (ratings.length === 2) return [newRating(a, 1), newRating(b, 0)]; for (var i = 0, len = ratings.length; i < len; i++) { var j = i; @@ -868,10 +827,10 @@ var findLastIndex = function findLastIndex(arr, fn) { return arr.map(function (val, i) { return [i, val]; - }).filter(function (_ref) { - var _ref2 = _slicedToArray(_ref, 2), - i = _ref2[0], - val = _ref2[1]; + }).filter(function (_ref8) { + var _ref9 = _slicedToArray(_ref8, 2), + i = _ref9[0], + val = _ref9[1]; return fn(val, i, arr); }).pop()[0]; @@ -901,8 +860,8 @@ var flip = function flip(fn) { return function (first) { - for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - rest[_key - 1] = arguments[_key]; + for (var _len22 = arguments.length, rest = new Array(_len22 > 1 ? _len22 - 1 : 0), _key22 = 1; _key22 < _len22; _key22++) { + rest[_key22 - 1] = arguments[_key22]; } return fn.apply(void 0, rest.concat([first])); @@ -913,18 +872,6 @@ 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 = { @@ -936,15 +883,27 @@ }; return Object.entries(time).filter(function (val) { return val[1] !== 0; - }).map(function (_ref) { - var _ref2 = _slicedToArray(_ref, 2), - key = _ref2[0], - val = _ref2[1]; + }).map(function (_ref10) { + var _ref11 = _slicedToArray(_ref10, 2), + key = _ref11[0], + val = _ref11[1]; return "".concat(val, " ").concat(key).concat(val !== 1 ? 's' : ''); }).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(); @@ -966,8 +925,8 @@ return !y ? x : gcd(y, x % y); }; - for (var _len = arguments.length, arr = new Array(_len), _key = 0; _key < _len; _key++) { - arr[_key] = arguments[_key]; + for (var _len23 = arguments.length, arr = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) { + arr[_key23] = arguments[_key23]; } return arr.concat().reduce(function (a, b) { @@ -986,8 +945,8 @@ }; var get = function get(from) { - for (var _len = arguments.length, selectors = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - selectors[_key - 1] = arguments[_key]; + for (var _len24 = arguments.length, selectors = new Array(_len24 > 1 ? _len24 - 1 : 0), _key24 = 1; _key24 < _len24; _key24++) { + selectors[_key24 - 1] = arguments[_key24]; } return selectors.concat().map(function (s) { @@ -1061,8 +1020,8 @@ }; var hasFlags = function hasFlags() { - for (var _len = arguments.length, flags = new Array(_len), _key = 0; _key < _len; _key++) { - flags[_key] = arguments[_key]; + for (var _len25 = arguments.length, flags = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) { + flags[_key25] = arguments[_key25]; } return flags.every(function (flag) { @@ -1083,12 +1042,10 @@ }); }; - var crypto$2 = typeof require !== "undefined" && require('crypto'); - var hashNode = function hashNode(val) { return new Promise(function (resolve) { return setTimeout(function () { - return resolve(crypto$2.createHash('sha256').update(val).digest('hex')); + return resolve(crypto.createHash('sha256').update(val).digest('hex')); }, 0); }); }; @@ -1161,18 +1118,6 @@ 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 _ref = [start, end]; - end = _ref[0]; - start = _ref[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)); @@ -1225,8 +1170,8 @@ }; var initializeNDArray = function initializeNDArray(val) { - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + for (var _len26 = arguments.length, args = new Array(_len26 > 1 ? _len26 - 1 : 0), _key26 = 1; _key26 < _len26; _key26++) { + args[_key26 - 1] = arguments[_key26]; } return args.length === 0 ? val : Array.from({ @@ -1236,6 +1181,18 @@ }); }; + 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); }; @@ -1374,7 +1331,7 @@ }; var isPrimitive = function isPrimitive(val) { - return !['object', 'function'].includes(_typeof(val)) || val === null; + return Object(val) !== val; }; var isPromiseLike = function isPromiseLike(obj) { @@ -1396,10 +1353,10 @@ var _iteratorError = undefined; try { - for (var _iterator = arr.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var _step$value = _slicedToArray(_step.value, 2), - i = _step$value[0], - val = _step$value[1]; + for (var _iterator = arr.entries()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion = (_step2 = _iterator.next()).done); _iteratorNormalCompletion = true) { + var _step2$value = _slicedToArray(_step2.value, 2), + i = _step2$value[0], + val = _step2$value[1]; 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; @@ -1465,6 +1422,19 @@ }, ''); }; + 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]; }; @@ -1478,8 +1448,8 @@ return x * y / gcd(x, y); }; - for (var _len = arguments.length, arr = new Array(_len), _key = 0; _key < _len; _key++) { - arr[_key] = arguments[_key]; + for (var _len27 = arguments.length, arr = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) { + arr[_key27] = arguments[_key27]; } return arr.concat().reduce(function (a, b) { @@ -1488,8 +1458,8 @@ }; var longestItem = function longestItem(val) { - for (var _len = arguments.length, vals = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - vals[_key - 1] = arguments[_key]; + for (var _len28 = arguments.length, vals = new Array(_len28 > 1 ? _len28 - 1 : 0), _key28 = 1; _key28 < _len28; _key28++) { + vals[_key28 - 1] = arguments[_key28]; } return [val].concat(vals).reduce(function (a, x) { @@ -1571,8 +1541,8 @@ var maxDate = function maxDate() { var _Math$max; - for (var _len = arguments.length, dates = new Array(_len), _key = 0; _key < _len; _key++) { - dates[_key] = arguments[_key]; + for (var _len29 = arguments.length, dates = new Array(_len29), _key29 = 0; _key29 < _len29; _key29++) { + dates[_key29] = arguments[_key29]; } return new Date((_Math$max = Math.max).apply.apply(_Math$max, [null].concat(dates))); @@ -1606,8 +1576,8 @@ }; var merge = function merge() { - for (var _len = arguments.length, objs = new Array(_len), _key = 0; _key < _len; _key++) { - objs[_key] = arguments[_key]; + for (var _len30 = arguments.length, objs = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) { + objs[_key30] = arguments[_key30]; } return objs.concat().reduce(function (acc, obj) { @@ -1627,8 +1597,8 @@ var minDate = function minDate() { var _Math$min; - for (var _len = arguments.length, dates = new Array(_len), _key = 0; _key < _len; _key++) { - dates[_key] = arguments[_key]; + for (var _len31 = arguments.length, dates = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) { + dates[_key31] = arguments[_key31]; } return new Date((_Math$min = Math.min).apply.apply(_Math$min, [null].concat(dates))); @@ -1684,8 +1654,8 @@ var nthArg = function nthArg(n) { return function () { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len32 = arguments.length, args = new Array(_len32), _key32 = 0; _key32 < _len32; _key32++) { + args[_key32] = arguments[_key32]; } return args.slice(n)[0]; @@ -1698,10 +1668,10 @@ }; var objectFromPairs = function objectFromPairs(arr) { - return arr.reduce(function (a, _ref) { - var _ref2 = _slicedToArray(_ref, 2), - key = _ref2[0], - val = _ref2[1]; + return arr.reduce(function (a, _ref13) { + var _ref14 = _slicedToArray(_ref13, 2), + key = _ref14[0], + val = _ref14[1]; return a[key] = val, a; }, {}); @@ -1766,6 +1736,20 @@ if (opts.target) return delegatorFn; }; + var once = function once(fn) { + var called = false; + return function () { + if (called) return; + called = true; + + for (var _len33 = arguments.length, args = new Array(_len33), _key33 = 0; _key33 < _len33; _key33++) { + args[_key33] = arguments[_key33]; + } + + return fn.apply(this, args); + }; + }; + var onUserInputChange = function onUserInputChange(callback) { var type = 'mouse', lastTime = 0; @@ -1782,28 +1766,14 @@ }); }; - var once = function once(fn) { - var called = false; - return function () { - if (called) return; - called = true; - - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - 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) { if (acc === 0) { - var _ref = orders && orders[i] === 'desc' ? [b[prop], a[prop]] : [a[prop], b[prop]], - _ref2 = _slicedToArray(_ref, 2), - p1 = _ref2[0], - p2 = _ref2[1]; + var _ref15 = orders && orders[i] === 'desc' ? [b[prop], a[prop]] : [a[prop], b[prop]], + _ref16 = _slicedToArray(_ref15, 2), + p1 = _ref16[0], + p2 = _ref16[1]; acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0; } @@ -1814,13 +1784,13 @@ }; var over = function over() { - for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) { - fns[_key] = arguments[_key]; + for (var _len34 = arguments.length, fns = new Array(_len34), _key34 = 0; _key34 < _len34; _key34++) { + fns[_key34] = arguments[_key34]; } return function () { - for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; + for (var _len35 = arguments.length, args = new Array(_len35), _key35 = 0; _key35 < _len35; _key35++) { + args[_key35] = arguments[_key35]; } return fns.map(function (fn) { @@ -1831,8 +1801,8 @@ var overArgs = function overArgs(fn, transforms) { return function () { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len36 = arguments.length, args = new Array(_len36), _key36 = 0; _key36 < _len36; _key36++) { + args[_key36] = arguments[_key36]; } return fn.apply(void 0, _toConsumableArray(args.map(function (val, i) { @@ -1861,13 +1831,13 @@ }; var partial = function partial(fn) { - for (var _len = arguments.length, partials = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - partials[_key - 1] = arguments[_key]; + for (var _len37 = arguments.length, partials = new Array(_len37 > 1 ? _len37 - 1 : 0), _key37 = 1; _key37 < _len37; _key37++) { + partials[_key37 - 1] = arguments[_key37]; } return function () { - for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; + for (var _len38 = arguments.length, args = new Array(_len38), _key38 = 0; _key38 < _len38; _key38++) { + args[_key38] = arguments[_key38]; } return fn.apply(void 0, partials.concat(args)); @@ -1875,13 +1845,13 @@ }; var partialRight = function partialRight(fn) { - for (var _len = arguments.length, partials = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - partials[_key - 1] = arguments[_key]; + 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 _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; + for (var _len40 = arguments.length, args = new Array(_len40), _key40 = 0; _key40 < _len40; _key40++) { + args[_key40] = arguments[_key40]; } return fn.apply(void 0, args.concat(partials)); @@ -1925,8 +1895,8 @@ }; var pipeAsyncFunctions = function pipeAsyncFunctions() { - for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) { - fns[_key] = arguments[_key]; + for (var _len41 = arguments.length, fns = new Array(_len41), _key41 = 0; _key41 < _len41; _key41++) { + fns[_key41] = arguments[_key41]; } return function (arg) { @@ -1937,8 +1907,8 @@ }; var pipeFunctions = function pipeFunctions() { - for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) { - fns[_key] = arguments[_key]; + for (var _len42 = arguments.length, fns = new Array(_len42), _key42 = 0; _key42 < _len42; _key42++) { + fns[_key42] = arguments[_key42]; } return fns.reduce(function (f, g) { @@ -2011,8 +1981,8 @@ var promisify = function promisify(func) { return function () { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len43 = arguments.length, args = new Array(_len43), _key43 = 0; _key43 < _len43; _key43++) { + args[_key43] = arguments[_key43]; } return new Promise(function (resolve, reject) { @@ -2024,8 +1994,8 @@ }; var pull = function pull(arr) { - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + for (var _len44 = arguments.length, args = new Array(_len44 > 1 ? _len44 - 1 : 0), _key44 = 1; _key44 < _len44; _key44++) { + args[_key44 - 1] = arguments[_key44]; } var argState = Array.isArray(args[0]) ? args[0] : args; @@ -2068,8 +2038,8 @@ }; var pullBy = function pullBy(arr) { - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + for (var _len45 = arguments.length, args = new Array(_len45 > 1 ? _len45 - 1 : 0), _key45 = 1; _key45 < _len45; _key45++) { + args[_key45 - 1] = arguments[_key45]; } var length = args.length; @@ -2113,16 +2083,14 @@ return Math.random() * (max - min) + min; }; - var fs$1 = typeof require !== "undefined" && require('fs'); - var readFileLines = function readFileLines(filename) { - return fs$1.readFileSync(filename).toString('UTF8').split('\n'); + return fs.readFileSync(filename).toString('UTF8').split('\n'); }; var rearg = function rearg(fn, indexes) { return function () { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len46 = arguments.length, args = new Array(_len46), _key46 = 0; _key46 < _len46; _key46++) { + args[_key46] = arguments[_key46]; } return fn.apply(void 0, _toConsumableArray(indexes.map(function (i) { @@ -2165,6 +2133,15 @@ 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; @@ -2180,15 +2157,6 @@ }); }; - 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); @@ -2216,6 +2184,10 @@ 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)); @@ -2226,8 +2198,8 @@ type: 'application/javascript; charset=utf-8' })); return new Promise(function (res, rej) { - worker.onmessage = function (_ref) { - var data = _ref.data; + worker.onmessage = function (_ref17) { + var data = _ref17.data; res(data), worker.terminate(); }; @@ -2247,18 +2219,18 @@ return arr[Math.floor(Math.random() * arr.length)]; }; - var sampleSize = function sampleSize(_ref) { - var _ref2 = _toArray(_ref), - arr = _ref2.slice(0); + var sampleSize = function sampleSize(_ref18) { + var _ref19 = _toArray(_ref18), + arr = _ref19.slice(0); var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; var m = arr.length; while (m) { var i = Math.floor(Math.random() * m--); - var _ref3 = [arr[i], arr[m]]; - arr[m] = _ref3[0]; - arr[i] = _ref3[1]; + var _ref20 = [arr[i], arr[m]]; + arr[m] = _ref20[0]; + arr[i] = _ref20[1]; } return arr.slice(0, n); @@ -2296,16 +2268,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 _len = arguments.length, elements = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) { - elements[_key - 3] = arguments[_key]; + for (var _len47 = arguments.length, elements = new Array(_len47 > 3 ? _len47 - 3 : 0), _key47 = 3; _key47 < _len47; _key47++) { + elements[_key47 - 3] = arguments[_key47]; } return arr.slice(0, index).concat(elements).concat(arr.slice(index + delCount)); }; var show = function show() { - for (var _len = arguments.length, el = new Array(_len), _key = 0; _key < _len; _key++) { - el[_key] = arguments[_key]; + for (var _len48 = arguments.length, el = new Array(_len48), _key48 = 0; _key48 < _len48; _key48++) { + el[_key48] = arguments[_key48]; } return el.concat().forEach(function (e) { @@ -2313,17 +2285,17 @@ }); }; - var shuffle = function shuffle(_ref) { - var _ref2 = _toArray(_ref), - arr = _ref2.slice(0); + var shuffle = function shuffle(_ref21) { + var _ref22 = _toArray(_ref21), + arr = _ref22.slice(0); var m = arr.length; while (m) { var i = Math.floor(Math.random() * m--); - var _ref3 = [arr[i], arr[m]]; - arr[m] = _ref3[0]; - arr[i] = _ref3[1]; + var _ref23 = [arr[i], arr[m]]; + arr[m] = _ref23[0]; + arr[i] = _ref23[1]; } return arr; @@ -2409,8 +2381,8 @@ }; }).sort(function (a, b) { return compare(a.item, b.item) || a.index - b.index; - }).map(function (_ref) { - var item = _ref.item; + }).map(function (_ref24) { + var item = _ref24.item; return item; }); }; @@ -2441,8 +2413,8 @@ }; var sum = function sum() { - for (var _len = arguments.length, arr = new Array(_len), _key = 0; _key < _len; _key++) { - arr[_key] = arguments[_key]; + for (var _len49 = arguments.length, arr = new Array(_len49), _key49 = 0; _key49 < _len49; _key49++) { + arr[_key49] = arguments[_key49]; } return arr.concat().reduce(function (acc, val) { @@ -2525,29 +2497,29 @@ }; var takeWhile = function takeWhile(arr, func) { - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; try { - for (var _iterator = arr.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var _step$value = _slicedToArray(_step.value, 2), - i = _step$value[0], - val = _step$value[1]; + for (var _iterator2 = arr.entries()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion2 = (_step3 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var _step3$value = _slicedToArray(_step3.value, 2), + i = _step3$value[0], + val = _step3$value[1]; if (func(val)) return arr.slice(0, i); } } catch (err) { - _didIteratorError = true; - _iteratorError = err; + _didIteratorError2 = true; + _iteratorError2 = err; } finally { try { - if (!_iteratorNormalCompletion && _iterator.return != null) { - _iterator.return(); + if (!_iteratorNormalCompletion2 && _iterator2.return != null) { + _iterator2.return(); } } finally { - if (_didIteratorError) { - throw _iteratorError; + if (_didIteratorError2) { + throw _iteratorError2; } } } @@ -2572,18 +2544,11 @@ fn.apply(context, args); lastTime = Date.now(); } - }, wait - (Date.now() - lastTime)); + }, Math.max(wait - (Date.now() - lastTime), 0)); } }; }; - var timeTaken = function timeTaken(callback) { - console.time('timeTaken'); - var r = callback(); - console.timeEnd('timeTaken'); - return r; - }; - var times = function times(n, fn) { var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; var i = 0; @@ -2591,6 +2556,13 @@ while (fn.call(context, i) !== false && ++i < n) {} }; + var timeTaken = function timeTaken(callback) { + console.time('timeTaken'); + var r = callback(); + console.timeEnd('timeTaken'); + return r; + }; + 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(); @@ -2610,6 +2582,10 @@ 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; @@ -2622,6 +2598,14 @@ }).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], @@ -2641,18 +2625,6 @@ }).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); @@ -2692,8 +2664,8 @@ }; }; - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len50 = arguments.length, args = new Array(_len50), _key50 = 0; _key50 < _len50; _key50++) { + args[_key50] = arguments[_key50]; } if (n > args.length) throw new RangeError('Arguments too few!'); @@ -2742,9 +2714,7 @@ }; var unionBy = function unionBy(a, b, fn) { - var s = new Set(a.map(function (v) { - return fn(v); - })); + var s = new Set(a.map(fn)); return Array.from(new Set(_toConsumableArray(a).concat(_toConsumableArray(b.filter(function (x) { return !s.has(fn(x)); }))))); @@ -2789,7 +2759,7 @@ }; var untildify = function untildify(str) { - return str.replace(/^~($|\/|\\)/, "".concat(typeof require !== "undefined" && require('os').homedir(), "$1")); + return str.replace(/^~($|\/|\\)/, "".concat(require('os').homedir(), "$1")); }; var unzip = function unzip(arr) { @@ -2822,6 +2792,26 @@ }); }; + var URLJoin = function URLJoin() { + for (var _len51 = arguments.length, args = new Array(_len51), _key51 = 0; _key51 < _len51; _key51++) { + args[_key51] = arguments[_key51]; + } + + 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; }; @@ -2833,8 +2823,8 @@ }; var without = function without(arr) { - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + for (var _len52 = arguments.length, args = new Array(_len52 > 1 ? _len52 - 1 : 0), _key52 = 1; _key52 < _len52; _key52++) { + args[_key52 - 1] = arguments[_key52]; } return arr.filter(function (v) { @@ -2861,8 +2851,8 @@ }; var zip = function zip() { - for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) { - arrays[_key] = arguments[_key]; + for (var _len53 = arguments.length, arrays = new Array(_len53), _key53 = 0; _key53 < _len53; _key53++) { + arrays[_key53] = arguments[_key53]; } var maxLength = Math.max.apply(Math, _toConsumableArray(arrays.map(function (x) { @@ -2886,8 +2876,8 @@ }; var zipWith = function zipWith() { - for (var _len = arguments.length, array = new Array(_len), _key = 0; _key < _len; _key++) { - array[_key] = arguments[_key]; + for (var _len54 = arguments.length, array = new Array(_len54), _key54 = 0; _key54 < _len54; _key54++) { + array[_key54] = arguments[_key54]; } var fn = typeof array[array.length - 1] === 'function' ? array.pop() : undefined; @@ -2904,341 +2894,341 @@ }); }; - exports.CSVToArray = CSVToArray; - exports.CSVToJSON = CSVToJSON; - exports.JSONToFile = JSONToFile; - exports.JSONtoCSV = JSONtoCSV; - exports.RGBToHex = RGBToHex; - exports.URLJoin = URLJoin; - exports.UUIDGeneratorBrowser = UUIDGeneratorBrowser; - exports.UUIDGeneratorNode = UUIDGeneratorNode; - exports.all = all; - exports.allEqual = allEqual; - exports.any = any; - exports.approximatelyEqual = approximatelyEqual; - exports.arrayToCSV = arrayToCSV; - exports.arrayToHtmlList = arrayToHtmlList; - exports.ary = ary; - exports.atob = atob; - exports.attempt = attempt; - exports.average = average; - exports.averageBy = averageBy; - exports.bifurcate = bifurcate; - exports.bifurcateBy = bifurcateBy; - exports.bind = bind; - exports.bindAll = bindAll; - exports.bindKey = bindKey; - exports.binomialCoefficient = binomialCoefficient; - exports.bottomVisible = bottomVisible; - exports.btoa = btoa; - exports.byteSize = byteSize; - exports.call = call; - exports.capitalize = capitalize; - exports.capitalizeEveryWord = capitalizeEveryWord; - exports.castArray = castArray; - exports.chainAsync = chainAsync; - exports.chunk = chunk; - exports.clampNumber = clampNumber; - exports.cloneRegExp = cloneRegExp; - exports.coalesce = coalesce; - exports.coalesceFactory = coalesceFactory; - exports.collectInto = collectInto; - exports.colorize = colorize; - exports.compact = compact; - exports.compose = compose; - exports.composeRight = composeRight; - exports.converge = converge; - exports.copyToClipboard = copyToClipboard; - exports.countBy = countBy; - exports.countOccurrences = countOccurrences; - exports.counter = counter; - exports.createElement = createElement; - exports.createEventHub = createEventHub; - exports.currentURL = currentURL; - exports.curry = curry; - exports.dayOfYear = dayOfYear; - exports.debounce = debounce; - exports.decapitalize = decapitalize; - exports.deepClone = deepClone; - exports.deepFlatten = deepFlatten; - exports.deepFreeze = deepFreeze; - exports.defaults = defaults; - exports.defer = defer; - exports.degreesToRads = degreesToRads; - exports.delay = delay; - exports.detectDeviceType = detectDeviceType; - exports.difference = difference; - exports.differenceBy = differenceBy; - exports.differenceWith = differenceWith; - exports.dig = dig; - exports.digitize = digitize; - exports.distance = distance; - exports.drop = drop; - exports.dropRight = dropRight; - exports.dropRightWhile = dropRightWhile; - exports.dropWhile = dropWhile; - exports.elementContains = elementContains; - exports.elementIsVisibleInViewport = elementIsVisibleInViewport; - exports.elo = elo; - exports.equals = equals; - exports.escapeHTML = escapeHTML; - exports.escapeRegExp = escapeRegExp; - exports.everyNth = everyNth; - exports.extendHex = extendHex; - exports.factorial = factorial; - exports.fibonacci = fibonacci; - exports.filterNonUnique = filterNonUnique; - exports.filterNonUniqueBy = filterNonUniqueBy; - exports.findKey = findKey; - exports.findLast = findLast; - exports.findLastIndex = findLastIndex; - exports.findLastKey = findLastKey; - exports.flatten = flatten; - exports.flattenObject = flattenObject; - exports.flip = flip; - exports.forEachRight = forEachRight; - exports.forOwn = forOwn; - exports.forOwnRight = forOwnRight; - exports.formatDuration = formatDuration; - exports.fromCamelCase = fromCamelCase; - exports.functionName = functionName; - exports.functions = functions; - exports.gcd = gcd; - exports.geometricProgression = geometricProgression; - exports.get = get; - exports.getColonTimeFromDate = getColonTimeFromDate; - exports.getDaysDiffBetweenDates = getDaysDiffBetweenDates; - exports.getImages = getImages; - exports.getMeridiemSuffixOfInteger = getMeridiemSuffixOfInteger; - exports.getScrollPosition = getScrollPosition; - exports.getStyle = getStyle; - exports.getType = getType; - exports.getURLParameters = getURLParameters; - exports.groupBy = groupBy; - exports.hammingDistance = hammingDistance; - exports.hasClass = hasClass; - exports.hasFlags = hasFlags; - exports.hashBrowser = hashBrowser; - exports.hashNode = hashNode; - exports.head = head; - exports.hexToRGB = hexToRGB; - exports.hide = hide; - exports.httpGet = httpGet; - exports.httpPost = httpPost; - exports.httpsRedirect = httpsRedirect; - exports.hz = hz; - exports.inRange = inRange; - exports.indentString = indentString; - exports.indexOfAll = indexOfAll; - exports.initial = initial; - exports.initialize2DArray = initialize2DArray; - exports.initializeArrayWithRange = initializeArrayWithRange; - exports.initializeArrayWithRangeRight = initializeArrayWithRangeRight; - exports.initializeArrayWithValues = initializeArrayWithValues; - exports.initializeNDArray = initializeNDArray; - exports.insertAfter = insertAfter; - exports.insertBefore = insertBefore; - exports.intersection = intersection; - exports.intersectionBy = intersectionBy; - exports.intersectionWith = intersectionWith; - exports.invertKeyValues = invertKeyValues; - exports.is = is; - exports.isAbsoluteURL = isAbsoluteURL; - exports.isAfterDate = isAfterDate; - exports.isAnagram = isAnagram; - exports.isArrayLike = isArrayLike; - exports.isBeforeDate = isBeforeDate; - exports.isBoolean = isBoolean; - exports.isBrowser = isBrowser; - exports.isBrowserTabFocused = isBrowserTabFocused; - exports.isDivisible = isDivisible; - exports.isDuplexStream = isDuplexStream; - exports.isEmpty = isEmpty; - exports.isEven = isEven; - exports.isFunction = isFunction; - exports.isLowerCase = isLowerCase; - exports.isNil = isNil; - exports.isNull = isNull; - exports.isNumber = isNumber; - exports.isObject = isObject; - exports.isObjectLike = isObjectLike; - exports.isPlainObject = isPlainObject; - exports.isPrime = isPrime; - exports.isPrimitive = isPrimitive; - exports.isPromiseLike = isPromiseLike; - exports.isReadableStream = isReadableStream; - exports.isSameDate = isSameDate; - exports.isSorted = isSorted; - exports.isStream = isStream; - exports.isString = isString; - exports.isSymbol = isSymbol; - exports.isTravisCI = isTravisCI; - exports.isUndefined = isUndefined; - exports.isUpperCase = isUpperCase; - exports.isValidJSON = isValidJSON; - exports.isWritableStream = isWritableStream; - exports.join = join; - exports.last = last; - exports.lcm = lcm; - exports.longestItem = longestItem; - exports.lowercaseKeys = lowercaseKeys; - exports.luhnCheck = luhnCheck; - exports.mapKeys = mapKeys; - exports.mapObject = mapObject; - exports.mapString = mapString; - exports.mapValues = mapValues; - exports.mask = mask; - exports.matches = matches; - exports.matchesWith = matchesWith; - exports.maxBy = maxBy; - exports.maxDate = maxDate; - exports.maxN = maxN; - exports.median = median; - exports.memoize = memoize; - exports.merge = merge; - exports.minBy = minBy; - exports.minDate = minDate; - exports.minN = minN; - exports.mostPerformant = mostPerformant; - exports.negate = negate; - exports.nest = nest; - exports.nodeListToArray = nodeListToArray; - exports.none = none; - exports.nthArg = nthArg; - exports.nthElement = nthElement; - exports.objectFromPairs = objectFromPairs; - exports.objectToPairs = objectToPairs; - exports.observeMutations = observeMutations; - exports.off = off; - exports.offset = offset; - exports.omit = omit; - exports.omitBy = omitBy; - exports.on = on; - exports.onUserInputChange = onUserInputChange; - exports.once = once; - exports.orderBy = orderBy; - exports.over = over; - exports.overArgs = overArgs; - exports.pad = pad; - exports.palindrome = palindrome; - exports.parseCookie = parseCookie; - exports.partial = partial; - exports.partialRight = partialRight; - exports.partition = partition; - exports.percentile = percentile; - exports.permutations = permutations; - exports.pick = pick; - exports.pickBy = pickBy; - exports.pipeAsyncFunctions = pipeAsyncFunctions; - exports.pipeFunctions = pipeFunctions; - exports.pluralize = pluralize; - exports.powerset = powerset; - exports.prefix = prefix; - exports.prettyBytes = prettyBytes; - exports.primes = primes; - exports.promisify = promisify; - exports.pull = pull; - exports.pullAtIndex = pullAtIndex; - exports.pullAtValue = pullAtValue; - exports.pullBy = pullBy; - exports.radsToDegrees = radsToDegrees; - exports.randomHexColorCode = randomHexColorCode; - exports.randomIntArrayInRange = randomIntArrayInRange; - exports.randomIntegerInRange = randomIntegerInRange; - exports.randomNumberInRange = randomNumberInRange; - exports.readFileLines = readFileLines; - exports.rearg = rearg; - exports.recordAnimationFrames = recordAnimationFrames; - exports.redirect = redirect; - exports.reduceSuccessive = reduceSuccessive; - exports.reduceWhich = reduceWhich; - exports.reducedFilter = reducedFilter; - exports.reject = reject; - exports.remove = remove; - exports.removeNonASCII = removeNonASCII; - exports.renameKeys = renameKeys; - exports.reverseString = reverseString; - exports.round = round; - exports.runAsync = runAsync; - exports.runPromisesInSeries = runPromisesInSeries; - exports.sample = sample; - exports.sampleSize = sampleSize; - exports.scrollToTop = scrollToTop; - exports.sdbm = sdbm; - exports.serializeCookie = serializeCookie; - exports.setStyle = setStyle; - exports.shallowClone = shallowClone; - exports.shank = shank; - exports.show = show; - exports.shuffle = shuffle; - exports.similarity = similarity; - exports.size = size; - exports.sleep = sleep; - exports.smoothScroll = smoothScroll; - exports.sortCharactersInString = sortCharactersInString; - exports.sortedIndex = sortedIndex; - exports.sortedIndexBy = sortedIndexBy; - exports.sortedLastIndex = sortedLastIndex; - exports.sortedLastIndexBy = sortedLastIndexBy; - exports.splitLines = splitLines; - exports.spreadOver = spreadOver; - exports.stableSort = stableSort; - exports.standardDeviation = standardDeviation; - exports.stringPermutations = stringPermutations; - exports.stripHTMLTags = stripHTMLTags; - exports.sum = sum; - exports.sumBy = sumBy; - exports.sumPower = sumPower; - exports.symmetricDifference = symmetricDifference; - exports.symmetricDifferenceBy = symmetricDifferenceBy; - exports.symmetricDifferenceWith = symmetricDifferenceWith; - exports.tail = tail; - exports.take = take; - exports.takeRight = takeRight; - exports.takeRightWhile = takeRightWhile; - exports.takeWhile = takeWhile; - exports.throttle = throttle; - exports.timeTaken = timeTaken; - exports.times = times; - exports.toCamelCase = toCamelCase; - exports.toCurrency = toCurrency; - exports.toDecimalMark = toDecimalMark; - exports.toHash = toHash; - exports.toKebabCase = toKebabCase; - exports.toOrdinalSuffix = toOrdinalSuffix; - exports.toSafeInteger = toSafeInteger; - exports.toSnakeCase = toSnakeCase; - exports.toggleClass = toggleClass; - exports.tomorrow = tomorrow; - exports.transform = transform; - exports.triggerEvent = triggerEvent; - exports.truncateString = truncateString; - exports.truthCheckCollection = truthCheckCollection; - exports.unary = unary; - exports.uncurry = uncurry; - exports.unescapeHTML = unescapeHTML; - exports.unflattenObject = unflattenObject; - exports.unfold = unfold; - exports.union = union; - exports.unionBy = unionBy; - exports.unionWith = unionWith; - exports.uniqueElements = uniqueElements; - exports.uniqueElementsBy = uniqueElementsBy; - exports.uniqueElementsByRight = uniqueElementsByRight; - exports.uniqueSymmetricDifference = uniqueSymmetricDifference; - exports.untildify = untildify; - exports.unzip = unzip; - exports.unzipWith = unzipWith; - exports.validateNumber = validateNumber; - exports.when = when; - exports.without = without; - exports.words = words; - exports.xProd = xProd; - exports.yesNo = yesNo; - exports.zip = zip; - exports.zipObject = zipObject; - exports.zipWith = zipWith; - - Object.defineProperty(exports, '__esModule', { value: true }); + module.exports = { + all: all, + allEqual: allEqual, + any: any, + approximatelyEqual: approximatelyEqual, + arrayToCSV: arrayToCSV, + arrayToHtmlList: arrayToHtmlList, + ary: ary, + atob: atob, + attempt: attempt, + average: average, + averageBy: averageBy, + bifurcate: bifurcate, + bifurcateBy: bifurcateBy, + bind: bind, + bindAll: bindAll, + bindKey: bindKey, + binomialCoefficient: binomialCoefficient, + bottomVisible: bottomVisible, + btoa: btoa, + byteSize: byteSize, + call: call, + capitalize: capitalize, + capitalizeEveryWord: capitalizeEveryWord, + castArray: castArray, + chainAsync: chainAsync, + chunk: chunk, + clampNumber: clampNumber, + cloneRegExp: cloneRegExp, + coalesce: coalesce, + coalesceFactory: coalesceFactory, + collectInto: collectInto, + colorize: colorize, + compact: compact, + compose: compose, + composeRight: composeRight, + converge: converge, + copyToClipboard: copyToClipboard, + countBy: countBy, + counter: counter, + countOccurrences: countOccurrences, + createElement: createElement, + createEventHub: createEventHub, + CSVToArray: CSVToArray, + CSVToJSON: CSVToJSON, + currentURL: currentURL, + curry: curry, + dayOfYear: dayOfYear, + debounce: debounce, + decapitalize: decapitalize, + deepClone: deepClone, + deepFlatten: deepFlatten, + deepFreeze: deepFreeze, + defaults: defaults, + defer: defer, + degreesToRads: degreesToRads, + delay: delay, + detectDeviceType: detectDeviceType, + difference: difference, + differenceBy: differenceBy, + differenceWith: differenceWith, + dig: dig, + digitize: digitize, + distance: distance, + drop: drop, + dropRight: dropRight, + dropRightWhile: dropRightWhile, + dropWhile: dropWhile, + elementContains: elementContains, + elementIsVisibleInViewport: elementIsVisibleInViewport, + elo: elo, + equals: equals, + escapeHTML: escapeHTML, + escapeRegExp: escapeRegExp, + everyNth: everyNth, + extendHex: extendHex, + factorial: factorial, + fibonacci: fibonacci, + filterNonUnique: filterNonUnique, + filterNonUniqueBy: filterNonUniqueBy, + findKey: findKey, + findLast: findLast, + findLastIndex: findLastIndex, + findLastKey: findLastKey, + flatten: flatten, + flattenObject: flattenObject, + flip: flip, + forEachRight: forEachRight, + formatDuration: formatDuration, + forOwn: forOwn, + forOwnRight: forOwnRight, + fromCamelCase: fromCamelCase, + functionName: functionName, + functions: functions, + gcd: gcd, + geometricProgression: geometricProgression, + get: get, + getColonTimeFromDate: getColonTimeFromDate, + getDaysDiffBetweenDates: getDaysDiffBetweenDates, + getImages: getImages, + getMeridiemSuffixOfInteger: getMeridiemSuffixOfInteger, + getScrollPosition: getScrollPosition, + getStyle: getStyle, + getType: getType, + getURLParameters: getURLParameters, + groupBy: groupBy, + hammingDistance: hammingDistance, + hasClass: hasClass, + hasFlags: hasFlags, + hashBrowser: hashBrowser, + hashNode: hashNode, + head: head, + hexToRGB: hexToRGB, + hide: hide, + httpGet: httpGet, + httpPost: httpPost, + httpsRedirect: httpsRedirect, + hz: hz, + indentString: indentString, + indexOfAll: indexOfAll, + initial: initial, + initialize2DArray: initialize2DArray, + initializeArrayWithRange: initializeArrayWithRange, + initializeArrayWithRangeRight: initializeArrayWithRangeRight, + initializeArrayWithValues: initializeArrayWithValues, + initializeNDArray: initializeNDArray, + inRange: inRange, + insertAfter: insertAfter, + insertBefore: insertBefore, + intersection: intersection, + intersectionBy: intersectionBy, + intersectionWith: intersectionWith, + invertKeyValues: invertKeyValues, + is: is, + isAbsoluteURL: isAbsoluteURL, + isAfterDate: isAfterDate, + isAnagram: isAnagram, + isArrayLike: isArrayLike, + isBeforeDate: isBeforeDate, + isBoolean: isBoolean, + isBrowser: isBrowser, + isBrowserTabFocused: isBrowserTabFocused, + isDivisible: isDivisible, + isDuplexStream: isDuplexStream, + isEmpty: isEmpty, + isEven: isEven, + isFunction: isFunction, + isLowerCase: isLowerCase, + isNil: isNil, + isNull: isNull, + isNumber: isNumber, + isObject: isObject, + isObjectLike: isObjectLike, + isPlainObject: isPlainObject, + isPrime: isPrime, + isPrimitive: isPrimitive, + isPromiseLike: isPromiseLike, + isReadableStream: isReadableStream, + isSameDate: isSameDate, + isSorted: isSorted, + isStream: isStream, + isString: isString, + isSymbol: isSymbol, + isTravisCI: isTravisCI, + isUndefined: isUndefined, + isUpperCase: isUpperCase, + isValidJSON: isValidJSON, + isWritableStream: isWritableStream, + join: join, + JSONtoCSV: JSONtoCSV, + JSONToFile: JSONToFile, + last: last, + lcm: lcm, + longestItem: longestItem, + lowercaseKeys: lowercaseKeys, + luhnCheck: luhnCheck, + mapKeys: mapKeys, + mapObject: mapObject, + mapString: mapString, + mapValues: mapValues, + mask: mask, + matches: matches, + matchesWith: matchesWith, + maxBy: maxBy, + maxDate: maxDate, + maxN: maxN, + median: median, + memoize: memoize, + merge: merge, + minBy: minBy, + minDate: minDate, + minN: minN, + mostPerformant: mostPerformant, + negate: negate, + nest: nest, + nodeListToArray: nodeListToArray, + none: none, + nthArg: nthArg, + nthElement: nthElement, + objectFromPairs: objectFromPairs, + objectToPairs: objectToPairs, + observeMutations: observeMutations, + off: off, + offset: offset, + omit: omit, + omitBy: omitBy, + on: on, + once: once, + onUserInputChange: onUserInputChange, + orderBy: orderBy, + over: over, + overArgs: overArgs, + pad: pad, + palindrome: palindrome, + parseCookie: parseCookie, + partial: partial, + partialRight: partialRight, + partition: partition, + percentile: percentile, + permutations: permutations, + pick: pick, + pickBy: pickBy, + pipeAsyncFunctions: pipeAsyncFunctions, + pipeFunctions: pipeFunctions, + pluralize: pluralize, + powerset: powerset, + prefix: prefix, + prettyBytes: prettyBytes, + primes: primes, + promisify: promisify, + pull: pull, + pullAtIndex: pullAtIndex, + pullAtValue: pullAtValue, + pullBy: pullBy, + radsToDegrees: radsToDegrees, + randomHexColorCode: randomHexColorCode, + randomIntArrayInRange: randomIntArrayInRange, + randomIntegerInRange: randomIntegerInRange, + randomNumberInRange: randomNumberInRange, + readFileLines: readFileLines, + rearg: rearg, + recordAnimationFrames: recordAnimationFrames, + redirect: redirect, + reducedFilter: reducedFilter, + reduceSuccessive: reduceSuccessive, + reduceWhich: reduceWhich, + reject: reject, + remove: remove, + removeNonASCII: removeNonASCII, + renameKeys: renameKeys, + reverseString: reverseString, + RGBToHex: RGBToHex, + round: round, + runAsync: runAsync, + runPromisesInSeries: runPromisesInSeries, + sample: sample, + sampleSize: sampleSize, + scrollToTop: scrollToTop, + sdbm: sdbm, + serializeCookie: serializeCookie, + setStyle: setStyle, + shallowClone: shallowClone, + shank: shank, + show: show, + shuffle: shuffle, + similarity: similarity, + size: size, + sleep: sleep, + smoothScroll: smoothScroll, + sortCharactersInString: sortCharactersInString, + sortedIndex: sortedIndex, + sortedIndexBy: sortedIndexBy, + sortedLastIndex: sortedLastIndex, + sortedLastIndexBy: sortedLastIndexBy, + splitLines: splitLines, + spreadOver: spreadOver, + stableSort: stableSort, + standardDeviation: standardDeviation, + stringPermutations: stringPermutations, + stripHTMLTags: stripHTMLTags, + sum: sum, + sumBy: sumBy, + sumPower: sumPower, + symmetricDifference: symmetricDifference, + symmetricDifferenceBy: symmetricDifferenceBy, + symmetricDifferenceWith: symmetricDifferenceWith, + tail: tail, + take: take, + takeRight: takeRight, + takeRightWhile: takeRightWhile, + takeWhile: takeWhile, + throttle: throttle, + times: times, + timeTaken: timeTaken, + toCamelCase: toCamelCase, + toCurrency: toCurrency, + toDecimalMark: toDecimalMark, + toggleClass: toggleClass, + toHash: toHash, + toKebabCase: toKebabCase, + tomorrow: tomorrow, + toOrdinalSuffix: toOrdinalSuffix, + toSafeInteger: toSafeInteger, + toSnakeCase: toSnakeCase, + transform: transform, + triggerEvent: triggerEvent, + truncateString: truncateString, + truthCheckCollection: truthCheckCollection, + unary: unary, + uncurry: uncurry, + unescapeHTML: unescapeHTML, + unflattenObject: unflattenObject, + unfold: unfold, + union: union, + unionBy: unionBy, + unionWith: unionWith, + uniqueElements: uniqueElements, + uniqueElementsBy: uniqueElementsBy, + uniqueElementsByRight: uniqueElementsByRight, + uniqueSymmetricDifference: uniqueSymmetricDifference, + untildify: untildify, + unzip: unzip, + unzipWith: unzipWith, + URLJoin: URLJoin, + UUIDGeneratorBrowser: UUIDGeneratorBrowser, + UUIDGeneratorNode: UUIDGeneratorNode, + validateNumber: validateNumber, + when: when, + without: without, + words: words, + xProd: xProd, + yesNo: yesNo, + zip: zip, + zipObject: zipObject, + zipWith: zipWith + }; }))); diff --git a/dist/_30s.es5.min.js b/dist/_30s.es5.min.js index 8183db353..8b18cc1f8 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(exports):'function'==typeof define&&define.amd?define(['exports'],t):t(e._30s={})})(this,function(e){'use strict';function t(e){return t='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},t(e)}function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){for(var t=1;t>e/4).toString(16)})},e.UUIDGeneratorNode=function(){return'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,function(e){return(e^x.randomBytes(1)[0]&15>>e/4).toString(16)})},e.all=function(e){var t=1'.concat(e,'')}).join('')}()},e.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)},e.btoa=function(e){return Buffer.from(e,'binary').toString('base64')},e.byteSize=function(e){return new Blob([e]).size},e.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)},j(k(r/(n-t))));return o},e.createElement=function(e){var t=document.createElement('div');return t.innerHTML=e,t.firstElementChild},e.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})},e.escapeRegExp=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')},e.everyNth=function(e,t){return e.filter(function(n,e){return e%t==t-1})},e.extendHex=function(e){return'#'+e.slice(e.startsWith('#')?1:0).split('').map(function(e){return e+e}).join('')},e.factorial=function e(t){return 0>t?function(){throw new TypeError('Negative numbers are not allowed!')}():1>=t?1:t*e(t-1)},e.fibonacci=function(e){return Array.from({length:e}).reduce(function(e,t,n){return e.concat(1e&&(e=-e);var t={day:k(e/864e5),hour:k(e/36e5)%24,minute:k(e/6e4)%60,second:k(e/1e3)%60,millisecond:k(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(', ')},e.fromCamelCase=function(e){var t=1e?e%12+'am':e%12+'pm'},e.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):'')+')'},e.hide=function(e){return e.forEach(function(t){return t.style.display='none'})},e.httpGet=function(e,t){var n=2n){var i=[t,n];n=i[0],t=i[1]}return null==n?0<=e&&e=t&&et},e.isAnagram=function(e,t){var n=function(e){return e.toLowerCase().replace(/[^a-z0-9]/gi,'').split('').sort().join('')};return n(e)===n(t)},e.isArrayLike=function(e){return null!=e&&'function'==typeof e[Symbol.iterator]},e.isBeforeDate=function(e,t){return ee.length?t:e})},e.lowercaseKeys=function(e){return Object.keys(e).reduce(function(t,n){return t[n.toLowerCase()]=e[n],t},{})},e.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},e.mapKeys=function(e,t){return Object.keys(e).reduce(function(n,i){return n[t(e[i],i,e)]=e[i],n},{})},e.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},{})}()},e.mapString=function(e,t){return e.split('').map(function(n,r){return t(n,r,e)}).join('')},e.mapValues=function(e,t){return Object.keys(e).reduce(function(n,i){return n[i]=t(e[i],i,e),n},{})},e.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))})},e.once=function(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,i=Array(n),r=0;rd?1:sj(e))return e+(i?' ':'')+r[0];var a=m(k(Math.log10(0>e?-e:e)/3),r.length-1),l=+((0>e?-e:e)/u(1e3,a)).toPrecision(t);return(0>e?'-':'')+l+(i?' ':'')+r[a]},e.primes=function(e){var t=Array.from({length:e-1}).map(function(e,t){return t+2}),n=k(g(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},e.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},e.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},e.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},e.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},e.splitLines=function(e){return e.split(/\r?\n/)},e.spreadOver=function(e){return function(t){return e.apply(void 0,o(t))}},e.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})},e.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}))},[])},e.stripHTMLTags=function(e){return e.replace(/<[^>]*>/g,'')},e.sum=function(){for(var e=arguments.length,t=Array(e),n=0;n=t&&(e.apply(a,l),r=Date.now())},t-(Date.now()-r))):(e.apply(a,l),r=Date.now(),n=!0)}},e.timeTaken=function(e){console.time('timeTaken');var t=e();return console.timeEnd('timeTaken'),t},e.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))}},e.unescapeHTML=function(e){return e.replace(/&|<|>|'|"/g,function(e){return{"&":'&',"<":'<',">":'>',"'":'\'',""":'"'}[e]||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},{})},e.unfold=function(e,t){for(var n=[],i=[null,t];i=e(i[1]);)n.push(i[0]);return n},e.union=function(e,t){return Array.from(new Set(o(e).concat(o(t))))},e.unionBy=function(e,t,n){var i=new Set(e.map(function(e){return n(e)}));return Array.from(new Set(o(e).concat(o(t.filter(function(e){return!i.has(n(e))})))))},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)})})))))},e.uniqueElements=function(e){return o(new Set(e))},e.uniqueElementsBy=function(e,t){return e.reduce(function(e,n){return e.some(function(e){return t(n,e)})||e.push(n),e},[])},e.uniqueElementsByRight=function(e,t){return e.reduceRight(function(e,n){return e.some(function(e){return t(n,e)})||e.push(n),e},[])},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)})))))},e.untildify=function(e){return e.replace(/^~($|\/|\\)/,''.concat('undefined'!=typeof require&&require('os').homedir(),'$1'))},e.unzip=function(e){return e.reduce(function(e,t){return t.forEach(function(t,n){return e[n].push(t)}),e},Array.from({length:_.apply(Math,o(e.map(function(e){return e.length})))}).map(function(){return[]}))},e.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:_.apply(Math,o(e.map(function(e){return e.length})))}).map(function(){return[]})).map(function(e){return t.apply(void 0,o(e))})},e.validateNumber=function(e){return!isNaN(parseFloat(e))&&isFinite(e)&&+e==e},e.when=function(e,t){return function(n){return e(n)?t(n):n}},e.without=function(e){for(var t=arguments.length,n=Array(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},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(e){return e.forEach(function(t){return t.style.display='none'})},httpGet:function(e,t){var n=2n){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^S.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 - 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 crypto = typeof require !== "undefined" && require('crypto'); const fs = typeof require !== "undefined" && require('fs'); -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 crypto$1 = typeof require !== "undefined" && require('crypto'); -const UUIDGeneratorNode = () => - ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => - (c ^ (crypto$1.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 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, i) => { - 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(v => fn(v))); - 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 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 flip = fn => (first, ...rest) => fn(...rest, first); - -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 crypto$2 = typeof require !== "undefined" && require('crypto'); -const hashNode = val => - new Promise(resolve => - setTimeout( - () => - resolve( - crypto$2 - .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 = els => els.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', 'function'].includes(typeof val) || val === null; - -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 = (val, ...vals) => - [val, ...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 fs$1 = typeof require !== "undefined" && require('fs'); -const readFileLines = filename => - fs$1 - .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 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 = els => els.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 = (val, ...vals) => + [val, ...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 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 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(); - } - }, wait - (Date.now() - lastTime)); - } - }; -}; - -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 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(v => fn(v))); - 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(/^~($|\/|\\)/, `${typeof require !== "undefined" && 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])) - ); -}; - -export { 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, 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 }; +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,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}; diff --git a/dist/_30s.js b/dist/_30s.js index bfd04c12b..3af22678f 100644 --- a/dist/_30s.js +++ b/dist/_30s.js @@ -1,1997 +1,1332 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global._30s = {}))); -}(this, (function (exports) { 'use strict'; - - 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), {}); - }); - }; + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + const crypto = typeof require !== "undefined" && require('crypto'); const fs = typeof require !== "undefined" && require('fs'); - 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 crypto$1 = typeof require !== "undefined" && require('crypto'); - const UUIDGeneratorNode = () => - ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => - (c ^ (crypto$1.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 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, i) => { - 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(v => fn(v))); - 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 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 flip = fn => (first, ...rest) => fn(...rest, first); - - 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 crypto$2 = typeof require !== "undefined" && require('crypto'); - const hashNode = val => - new Promise(resolve => - setTimeout( - () => - resolve( - crypto$2 - .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 = els => els.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', 'function'].includes(typeof val) || val === null; - - 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 = (val, ...vals) => - [val, ...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 fs$1 = typeof require !== "undefined" && require('fs'); - const readFileLines = filename => - fs$1 - .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 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 = els => els.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 = (val, ...vals) => + [val, ...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 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 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(); - } - }, wait - (Date.now() - lastTime)); - } - }; - }; - - 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 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(v => fn(v))); - 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(/^~($|\/|\\)/, `${typeof require !== "undefined" && 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])) - ); - }; - - exports.CSVToArray = CSVToArray; - exports.CSVToJSON = CSVToJSON; - exports.JSONToFile = JSONToFile; - exports.JSONtoCSV = JSONtoCSV; - exports.RGBToHex = RGBToHex; - exports.URLJoin = URLJoin; - exports.UUIDGeneratorBrowser = UUIDGeneratorBrowser; - exports.UUIDGeneratorNode = UUIDGeneratorNode; - exports.all = all; - exports.allEqual = allEqual; - exports.any = any; - exports.approximatelyEqual = approximatelyEqual; - exports.arrayToCSV = arrayToCSV; - exports.arrayToHtmlList = arrayToHtmlList; - exports.ary = ary; - exports.atob = atob; - exports.attempt = attempt; - exports.average = average; - exports.averageBy = averageBy; - exports.bifurcate = bifurcate; - exports.bifurcateBy = bifurcateBy; - exports.bind = bind; - exports.bindAll = bindAll; - exports.bindKey = bindKey; - exports.binomialCoefficient = binomialCoefficient; - exports.bottomVisible = bottomVisible; - exports.btoa = btoa; - exports.byteSize = byteSize; - exports.call = call; - exports.capitalize = capitalize; - exports.capitalizeEveryWord = capitalizeEveryWord; - exports.castArray = castArray; - exports.chainAsync = chainAsync; - exports.chunk = chunk; - exports.clampNumber = clampNumber; - exports.cloneRegExp = cloneRegExp; - exports.coalesce = coalesce; - exports.coalesceFactory = coalesceFactory; - exports.collectInto = collectInto; - exports.colorize = colorize; - exports.compact = compact; - exports.compose = compose; - exports.composeRight = composeRight; - exports.converge = converge; - exports.copyToClipboard = copyToClipboard; - exports.countBy = countBy; - exports.countOccurrences = countOccurrences; - exports.counter = counter; - exports.createElement = createElement; - exports.createEventHub = createEventHub; - exports.currentURL = currentURL; - exports.curry = curry; - exports.dayOfYear = dayOfYear; - exports.debounce = debounce; - exports.decapitalize = decapitalize; - exports.deepClone = deepClone; - exports.deepFlatten = deepFlatten; - exports.deepFreeze = deepFreeze; - exports.defaults = defaults; - exports.defer = defer; - exports.degreesToRads = degreesToRads; - exports.delay = delay; - exports.detectDeviceType = detectDeviceType; - exports.difference = difference; - exports.differenceBy = differenceBy; - exports.differenceWith = differenceWith; - exports.dig = dig; - exports.digitize = digitize; - exports.distance = distance; - exports.drop = drop; - exports.dropRight = dropRight; - exports.dropRightWhile = dropRightWhile; - exports.dropWhile = dropWhile; - exports.elementContains = elementContains; - exports.elementIsVisibleInViewport = elementIsVisibleInViewport; - exports.elo = elo; - exports.equals = equals; - exports.escapeHTML = escapeHTML; - exports.escapeRegExp = escapeRegExp; - exports.everyNth = everyNth; - exports.extendHex = extendHex; - exports.factorial = factorial; - exports.fibonacci = fibonacci; - exports.filterNonUnique = filterNonUnique; - exports.filterNonUniqueBy = filterNonUniqueBy; - exports.findKey = findKey; - exports.findLast = findLast; - exports.findLastIndex = findLastIndex; - exports.findLastKey = findLastKey; - exports.flatten = flatten; - exports.flattenObject = flattenObject; - exports.flip = flip; - exports.forEachRight = forEachRight; - exports.forOwn = forOwn; - exports.forOwnRight = forOwnRight; - exports.formatDuration = formatDuration; - exports.fromCamelCase = fromCamelCase; - exports.functionName = functionName; - exports.functions = functions; - exports.gcd = gcd; - exports.geometricProgression = geometricProgression; - exports.get = get; - exports.getColonTimeFromDate = getColonTimeFromDate; - exports.getDaysDiffBetweenDates = getDaysDiffBetweenDates; - exports.getImages = getImages; - exports.getMeridiemSuffixOfInteger = getMeridiemSuffixOfInteger; - exports.getScrollPosition = getScrollPosition; - exports.getStyle = getStyle; - exports.getType = getType; - exports.getURLParameters = getURLParameters; - exports.groupBy = groupBy; - exports.hammingDistance = hammingDistance; - exports.hasClass = hasClass; - exports.hasFlags = hasFlags; - exports.hashBrowser = hashBrowser; - exports.hashNode = hashNode; - exports.head = head; - exports.hexToRGB = hexToRGB; - exports.hide = hide; - exports.httpGet = httpGet; - exports.httpPost = httpPost; - exports.httpsRedirect = httpsRedirect; - exports.hz = hz; - exports.inRange = inRange; - exports.indentString = indentString; - exports.indexOfAll = indexOfAll; - exports.initial = initial; - exports.initialize2DArray = initialize2DArray; - exports.initializeArrayWithRange = initializeArrayWithRange; - exports.initializeArrayWithRangeRight = initializeArrayWithRangeRight; - exports.initializeArrayWithValues = initializeArrayWithValues; - exports.initializeNDArray = initializeNDArray; - exports.insertAfter = insertAfter; - exports.insertBefore = insertBefore; - exports.intersection = intersection; - exports.intersectionBy = intersectionBy; - exports.intersectionWith = intersectionWith; - exports.invertKeyValues = invertKeyValues; - exports.is = is; - exports.isAbsoluteURL = isAbsoluteURL; - exports.isAfterDate = isAfterDate; - exports.isAnagram = isAnagram; - exports.isArrayLike = isArrayLike; - exports.isBeforeDate = isBeforeDate; - exports.isBoolean = isBoolean; - exports.isBrowser = isBrowser; - exports.isBrowserTabFocused = isBrowserTabFocused; - exports.isDivisible = isDivisible; - exports.isDuplexStream = isDuplexStream; - exports.isEmpty = isEmpty; - exports.isEven = isEven; - exports.isFunction = isFunction; - exports.isLowerCase = isLowerCase; - exports.isNil = isNil; - exports.isNull = isNull; - exports.isNumber = isNumber; - exports.isObject = isObject; - exports.isObjectLike = isObjectLike; - exports.isPlainObject = isPlainObject; - exports.isPrime = isPrime; - exports.isPrimitive = isPrimitive; - exports.isPromiseLike = isPromiseLike; - exports.isReadableStream = isReadableStream; - exports.isSameDate = isSameDate; - exports.isSorted = isSorted; - exports.isStream = isStream; - exports.isString = isString; - exports.isSymbol = isSymbol; - exports.isTravisCI = isTravisCI; - exports.isUndefined = isUndefined; - exports.isUpperCase = isUpperCase; - exports.isValidJSON = isValidJSON; - exports.isWritableStream = isWritableStream; - exports.join = join; - exports.last = last; - exports.lcm = lcm; - exports.longestItem = longestItem; - exports.lowercaseKeys = lowercaseKeys; - exports.luhnCheck = luhnCheck; - exports.mapKeys = mapKeys; - exports.mapObject = mapObject; - exports.mapString = mapString; - exports.mapValues = mapValues; - exports.mask = mask; - exports.matches = matches; - exports.matchesWith = matchesWith; - exports.maxBy = maxBy; - exports.maxDate = maxDate; - exports.maxN = maxN; - exports.median = median; - exports.memoize = memoize; - exports.merge = merge; - exports.minBy = minBy; - exports.minDate = minDate; - exports.minN = minN; - exports.mostPerformant = mostPerformant; - exports.negate = negate; - exports.nest = nest; - exports.nodeListToArray = nodeListToArray; - exports.none = none; - exports.nthArg = nthArg; - exports.nthElement = nthElement; - exports.objectFromPairs = objectFromPairs; - exports.objectToPairs = objectToPairs; - exports.observeMutations = observeMutations; - exports.off = off; - exports.offset = offset; - exports.omit = omit; - exports.omitBy = omitBy; - exports.on = on; - exports.onUserInputChange = onUserInputChange; - exports.once = once; - exports.orderBy = orderBy; - exports.over = over; - exports.overArgs = overArgs; - exports.pad = pad; - exports.palindrome = palindrome; - exports.parseCookie = parseCookie; - exports.partial = partial; - exports.partialRight = partialRight; - exports.partition = partition; - exports.percentile = percentile; - exports.permutations = permutations; - exports.pick = pick; - exports.pickBy = pickBy; - exports.pipeAsyncFunctions = pipeAsyncFunctions; - exports.pipeFunctions = pipeFunctions; - exports.pluralize = pluralize; - exports.powerset = powerset; - exports.prefix = prefix; - exports.prettyBytes = prettyBytes; - exports.primes = primes; - exports.promisify = promisify; - exports.pull = pull; - exports.pullAtIndex = pullAtIndex; - exports.pullAtValue = pullAtValue; - exports.pullBy = pullBy; - exports.radsToDegrees = radsToDegrees; - exports.randomHexColorCode = randomHexColorCode; - exports.randomIntArrayInRange = randomIntArrayInRange; - exports.randomIntegerInRange = randomIntegerInRange; - exports.randomNumberInRange = randomNumberInRange; - exports.readFileLines = readFileLines; - exports.rearg = rearg; - exports.recordAnimationFrames = recordAnimationFrames; - exports.redirect = redirect; - exports.reduceSuccessive = reduceSuccessive; - exports.reduceWhich = reduceWhich; - exports.reducedFilter = reducedFilter; - exports.reject = reject; - exports.remove = remove; - exports.removeNonASCII = removeNonASCII; - exports.renameKeys = renameKeys; - exports.reverseString = reverseString; - exports.round = round; - exports.runAsync = runAsync; - exports.runPromisesInSeries = runPromisesInSeries; - exports.sample = sample; - exports.sampleSize = sampleSize; - exports.scrollToTop = scrollToTop; - exports.sdbm = sdbm; - exports.serializeCookie = serializeCookie; - exports.setStyle = setStyle; - exports.shallowClone = shallowClone; - exports.shank = shank; - exports.show = show; - exports.shuffle = shuffle; - exports.similarity = similarity; - exports.size = size; - exports.sleep = sleep; - exports.smoothScroll = smoothScroll; - exports.sortCharactersInString = sortCharactersInString; - exports.sortedIndex = sortedIndex; - exports.sortedIndexBy = sortedIndexBy; - exports.sortedLastIndex = sortedLastIndex; - exports.sortedLastIndexBy = sortedLastIndexBy; - exports.splitLines = splitLines; - exports.spreadOver = spreadOver; - exports.stableSort = stableSort; - exports.standardDeviation = standardDeviation; - exports.stringPermutations = stringPermutations; - exports.stripHTMLTags = stripHTMLTags; - exports.sum = sum; - exports.sumBy = sumBy; - exports.sumPower = sumPower; - exports.symmetricDifference = symmetricDifference; - exports.symmetricDifferenceBy = symmetricDifferenceBy; - exports.symmetricDifferenceWith = symmetricDifferenceWith; - exports.tail = tail; - exports.take = take; - exports.takeRight = takeRight; - exports.takeRightWhile = takeRightWhile; - exports.takeWhile = takeWhile; - exports.throttle = throttle; - exports.timeTaken = timeTaken; - exports.times = times; - exports.toCamelCase = toCamelCase; - exports.toCurrency = toCurrency; - exports.toDecimalMark = toDecimalMark; - exports.toHash = toHash; - exports.toKebabCase = toKebabCase; - exports.toOrdinalSuffix = toOrdinalSuffix; - exports.toSafeInteger = toSafeInteger; - exports.toSnakeCase = toSnakeCase; - exports.toggleClass = toggleClass; - exports.tomorrow = tomorrow; - exports.transform = transform; - exports.triggerEvent = triggerEvent; - exports.truncateString = truncateString; - exports.truthCheckCollection = truthCheckCollection; - exports.unary = unary; - exports.uncurry = uncurry; - exports.unescapeHTML = unescapeHTML; - exports.unflattenObject = unflattenObject; - exports.unfold = unfold; - exports.union = union; - exports.unionBy = unionBy; - exports.unionWith = unionWith; - exports.uniqueElements = uniqueElements; - exports.uniqueElementsBy = uniqueElementsBy; - exports.uniqueElementsByRight = uniqueElementsByRight; - exports.uniqueSymmetricDifference = uniqueSymmetricDifference; - exports.untildify = untildify; - exports.unzip = unzip; - exports.unzipWith = unzipWith; - exports.validateNumber = validateNumber; - exports.when = when; - exports.without = without; - exports.words = words; - exports.xProd = xProd; - exports.yesNo = yesNo; - exports.zip = zip; - exports.zipObject = zipObject; - exports.zipWith = zipWith; - - Object.defineProperty(exports, '__esModule', { value: true }); + 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,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}; }))); diff --git a/package-lock.json b/package-lock.json index 9d1988e75..7bcccf607 100644 --- a/package-lock.json +++ b/package-lock.json @@ -933,23 +933,6 @@ "acorn": "5.5.3" } }, - "acorn-jsx": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", - "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", - "dev": true, - "requires": { - "acorn": "3.3.0" - }, - "dependencies": { - "acorn": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", - "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", - "dev": true - } - } - }, "ajv": { "version": "5.5.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", @@ -962,12 +945,6 @@ "json-schema-traverse": "0.3.1" } }, - "ajv-keywords": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", - "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=", - "dev": true - }, "amdefine": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", @@ -1357,16 +1334,6 @@ "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", "dev": true }, - "array-includes": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", - "integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=", - "dev": true, - "requires": { - "define-properties": "1.1.2", - "es-abstract": "1.11.0" - } - }, "array-union": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", @@ -1394,12 +1361,6 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, - "asap": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", - "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=", - "dev": true - }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", @@ -2291,12 +2252,6 @@ } } }, - "chardet": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", - "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", - "dev": true - }, "ci-info": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-1.5.1.tgz", @@ -2457,30 +2412,12 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "requires": { - "buffer-from": "1.1.0", - "inherits": "2.0.3", - "readable-stream": "2.3.3", - "typedarray": "0.0.6" - } - }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", "dev": true }, - "contains-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", - "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", - "dev": true - }, "convert-source-map": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.1.tgz", @@ -2605,12 +2542,6 @@ "ms": "2.0.0" } }, - "debug-log": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/debug-log/-/debug-log-1.0.1.tgz", - "integrity": "sha1-IwdjLUwEOCuN+KMvcLiVBG1SdF8=", - "dev": true - }, "decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", @@ -2712,20 +2643,6 @@ } } }, - "deglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/deglob/-/deglob-2.1.1.tgz", - "integrity": "sha512-2kjwuGGonL7gWE1XU4Fv79+vVzpoQCl0V+boMwWtOQJV2AGDabCwez++nB1Nli/8BabAfZQ/UuHPlp6AymKdWw==", - "dev": true, - "requires": { - "find-root": "1.1.0", - "glob": "7.1.2", - "ignore": "3.3.8", - "pkg-config": "1.1.1", - "run-parallel": "1.1.9", - "uniq": "1.0.1" - } - }, "del": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", @@ -2822,15 +2739,6 @@ "integrity": "sha512-h3zEBLdHvsKfaXv1SHAtykJyNtwYFEKkrWGSFyW1BzGgPQ4ykAzD5Hd8C5MZGTAEhkCKmtyIwYUrapsI0xfKww==", "dev": true }, - "encoding": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", - "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", - "dev": true, - "requires": { - "iconv-lite": "0.4.19" - } - }, "entities": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", @@ -3116,97 +3024,6 @@ } } }, - "eslint-config-semistandard": { - "version": "12.0.1", - "resolved": "https://registry.npmjs.org/eslint-config-semistandard/-/eslint-config-semistandard-12.0.1.tgz", - "integrity": "sha512-4zaPW5uRFasf2uRZkE19Y+W84KBV3q+oyWYOsgUN+5DQXE5HCsh7ZxeWDXxozk7NPycGm0kXcsJzLe5GZ1jCeg==", - "dev": true - }, - "eslint-config-standard-jsx": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/eslint-config-standard-jsx/-/eslint-config-standard-jsx-5.0.0.tgz", - "integrity": "sha512-rLToPAEqLMPBfWnYTu6xRhm2OWziS2n40QFqJ8jAM8NSVzeVKTa3nclhsU4DpPJQRY60F34Oo1wi/71PN/eITg==", - "dev": true - }, - "eslint-import-resolver-node": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz", - "integrity": "sha512-sfmTqJfPSizWu4aymbPr4Iidp5yKm8yDkHp+Ir3YiTHiiDfxh69mOUsmiqW6RZ9zRXFaF64GtYmN7e+8GHBv6Q==", - "dev": true, - "requires": { - "debug": "2.6.9", - "resolve": "1.5.0" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "eslint-module-utils": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.2.0.tgz", - "integrity": "sha1-snA2LNiLGkitMIl2zn+lTphBF0Y=", - "dev": true, - "requires": { - "debug": "2.6.9", - "pkg-dir": "1.0.0" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "pkg-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz", - "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", - "dev": true, - "requires": { - "find-up": "1.1.2" - } - } - } - }, - "eslint-plugin-async-await": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-async-await/-/eslint-plugin-async-await-0.0.0.tgz", - "integrity": "sha1-DyrhejgUeAY11I8kCd+eN4mMoJ8=", - "dev": true - }, - "eslint-plugin-react": { - "version": "7.6.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.6.1.tgz", - "integrity": "sha512-30aMOHWX/DOaaLJVBHz6RMvYM2qy5GH63+y2PLFdIrYe4YLtODFmT3N1YA7ZqUnaBweVbedr4K4cqxOlWAPjIw==", - "dev": true, - "requires": { - "doctrine": "2.1.0", - "has": "1.0.1", - "jsx-ast-utils": "2.0.1", - "prop-types": "15.6.1" - } - }, - "eslint-scope": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.1.tgz", - "integrity": "sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=", - "dev": true, - "requires": { - "esrecurse": "4.2.1", - "estraverse": "4.2.0" - } - }, "eslint-utils": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz", @@ -3219,16 +3036,6 @@ "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", "dev": true }, - "espree": { - "version": "3.5.4", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", - "dev": true, - "requires": { - "acorn": "5.5.3", - "acorn-jsx": "3.0.1" - } - }, "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", @@ -3360,17 +3167,6 @@ } } }, - "external-editor": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", - "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", - "dev": true, - "requires": { - "chardet": "0.4.2", - "iconv-lite": "0.4.19", - "tmp": "0.0.33" - } - }, "extglob": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", @@ -3413,29 +3209,6 @@ "bser": "2.0.0" } }, - "fbjs": { - "version": "0.8.17", - "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz", - "integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=", - "dev": true, - "requires": { - "core-js": "1.2.7", - "isomorphic-fetch": "2.2.1", - "loose-envify": "1.3.1", - "object-assign": "4.1.1", - "promise": "7.3.1", - "setimmediate": "1.0.5", - "ua-parser-js": "0.7.18" - }, - "dependencies": { - "core-js": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", - "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=", - "dev": true - } - } - }, "figures": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", @@ -3484,12 +3257,6 @@ "repeat-string": "1.6.1" } }, - "find-root": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", - "dev": true - }, "find-up": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", @@ -4661,18 +4428,6 @@ } } }, - "iconv-lite": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", - "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", - "dev": true - }, - "ignore": { - "version": "3.3.8", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.8.tgz", - "integrity": "sha512-pUh+xUQQhQzevjRHHFqqcTy0/dP/kS9I8HSrUydhihjuD09W6ldVWFtIrwhXdUJHis3i2rZNqEHpZH/cbinFbg==", - "dev": true - }, "import-local": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/import-local/-/import-local-1.0.0.tgz", @@ -4720,54 +4475,6 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "inquirer": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", - "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", - "dev": true, - "requires": { - "ansi-escapes": "3.1.0", - "chalk": "2.4.1", - "cli-cursor": "2.1.0", - "cli-width": "2.2.0", - "external-editor": "2.2.0", - "figures": "2.0.0", - "lodash": "4.17.11", - "mute-stream": "0.0.7", - "run-async": "2.3.0", - "rx-lite": "4.0.8", - "rx-lite-aggregates": "4.0.8", - "string-width": "2.1.1", - "strip-ansi": "4.0.0", - "through": "2.3.8" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", - "dev": true, - "requires": { - "escape-string-regexp": "1.0.5" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "3.0.0" - } - } - } - }, "invariant": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.2.tgz", @@ -5059,16 +4766,6 @@ "isarray": "1.0.0" } }, - "isomorphic-fetch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", - "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", - "dev": true, - "requires": { - "node-fetch": "1.7.3", - "whatwg-fetch": "2.0.4" - } - }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -5746,15 +5443,6 @@ "verror": "1.10.0" } }, - "jsx-ast-utils": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz", - "integrity": "sha1-6AGxs5mF4g//yHtA43SAgOLcrH8=", - "dev": true, - "requires": { - "array-includes": "3.0.3" - } - }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", @@ -5810,18 +5498,6 @@ "uc.micro": "1.0.5" } }, - "load-json-file": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", - "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "parse-json": "2.2.0", - "pify": "2.3.0", - "strip-bom": "3.0.0" - } - }, "locate-path": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", @@ -5858,12 +5534,6 @@ "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", "dev": true }, - "lodash.cond": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/lodash.cond/-/lodash.cond-4.5.2.tgz", - "integrity": "sha1-9HGh2khr5g9quVXRcRVSPdHSVdU=", - "dev": true - }, "lodash.isplainobject": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", @@ -6217,16 +5887,6 @@ "lower-case": "1.1.4" } }, - "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "dev": true, - "requires": { - "encoding": "0.1.12", - "is-stream": "1.1.0" - } - }, "node-gyp": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.8.0.tgz", @@ -6824,66 +6484,6 @@ "pinkie": "2.0.4" } }, - "pkg-conf": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/pkg-conf/-/pkg-conf-2.1.0.tgz", - "integrity": "sha1-ISZRTKbyq/69FoWW3xi6V4Z/AFg=", - "dev": true, - "requires": { - "find-up": "2.1.0", - "load-json-file": "4.0.0" - }, - "dependencies": { - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "requires": { - "locate-path": "2.0.0" - } - }, - "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "parse-json": "4.0.0", - "pify": "3.0.0", - "strip-bom": "3.0.0" - } - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "dev": true, - "requires": { - "error-ex": "1.3.1", - "json-parse-better-errors": "1.0.2" - } - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - } - } - }, - "pkg-config": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pkg-config/-/pkg-config-1.1.1.tgz", - "integrity": "sha1-VX7yLXPaPIg3EHdmxS6tq94pj+Q=", - "dev": true, - "requires": { - "debug-log": "1.0.1", - "find-root": "1.1.0", - "xtend": "4.0.1" - } - }, "pkg-dir": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", @@ -6986,15 +6586,6 @@ "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", "dev": true }, - "promise": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", - "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", - "dev": true, - "requires": { - "asap": "2.0.6" - } - }, "prompts": { "version": "0.1.14", "resolved": "https://registry.npmjs.org/prompts/-/prompts-0.1.14.tgz", @@ -7005,17 +6596,6 @@ "sisteransi": "0.1.1" } }, - "prop-types": { - "version": "15.6.1", - "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.6.1.tgz", - "integrity": "sha512-4ec7bY1Y66LymSUOH/zARVYObB23AT2h8cf6e/O6ZALB/N0sqZFEx7rq6EYPX2MkOdKORuooI/H5k9TlR4q7kQ==", - "dev": true, - "requires": { - "fbjs": "0.8.17", - "loose-envify": "1.3.1", - "object-assign": "4.1.1" - } - }, "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", @@ -7437,27 +7017,6 @@ "integrity": "sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A==", "dev": true }, - "run-parallel": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz", - "integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==", - "dev": true - }, - "rx-lite": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", - "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", - "dev": true - }, - "rx-lite-aggregates": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", - "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", - "dev": true, - "requires": { - "rx-lite": "4.0.8" - } - }, "rxjs": { "version": "6.3.3", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz", @@ -7935,185 +7494,6 @@ "dev": true, "optional": true }, - "semistandard": { - "version": "12.0.1", - "resolved": "https://registry.npmjs.org/semistandard/-/semistandard-12.0.1.tgz", - "integrity": "sha512-+FBRXBCi8GC1Nivc4ruw2KXER31bE1lrNyESo7prn2Sv9I9+H/Iqpt0NOtlV/GUxq34AgJwJViBUpA3/PUGqOw==", - "dev": true, - "requires": { - "eslint": "4.18.2", - "eslint-config-semistandard": "12.0.1", - "eslint-config-standard": "11.0.0", - "eslint-config-standard-jsx": "5.0.0", - "eslint-plugin-import": "2.8.0", - "eslint-plugin-node": "6.0.1", - "eslint-plugin-promise": "3.6.0", - "eslint-plugin-react": "7.6.1", - "eslint-plugin-standard": "3.0.1", - "standard-engine": "8.0.1" - }, - "dependencies": { - "eslint": { - "version": "4.18.2", - "resolved": "http://registry.npmjs.org/eslint/-/eslint-4.18.2.tgz", - "integrity": "sha512-qy4i3wODqKMYfz9LUI8N2qYDkHkoieTbiHpMrYUI/WbjhXJQr7lI4VngixTgaG+yHX+NBCv7nW4hA0ShbvaNKw==", - "dev": true, - "requires": { - "ajv": "5.5.2", - "babel-code-frame": "6.26.0", - "chalk": "2.4.1", - "concat-stream": "1.6.2", - "cross-spawn": "5.1.0", - "debug": "3.1.0", - "doctrine": "2.1.0", - "eslint-scope": "3.7.1", - "eslint-visitor-keys": "1.0.0", - "espree": "3.5.4", - "esquery": "1.0.1", - "esutils": "2.0.2", - "file-entry-cache": "2.0.0", - "functional-red-black-tree": "1.0.1", - "glob": "7.1.2", - "globals": "11.8.0", - "ignore": "3.3.8", - "imurmurhash": "0.1.4", - "inquirer": "3.3.0", - "is-resolvable": "1.1.0", - "js-yaml": "3.12.0", - "json-stable-stringify-without-jsonify": "1.0.1", - "levn": "0.3.0", - "lodash": "4.17.11", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "natural-compare": "1.4.0", - "optionator": "0.8.2", - "path-is-inside": "1.0.2", - "pluralize": "7.0.0", - "progress": "2.0.0", - "require-uncached": "1.0.3", - "semver": "5.4.1", - "strip-ansi": "4.0.0", - "strip-json-comments": "2.0.1", - "table": "4.0.2", - "text-table": "0.2.0" - } - }, - "eslint-config-standard": { - "version": "11.0.0", - "resolved": "http://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-11.0.0.tgz", - "integrity": "sha512-oDdENzpViEe5fwuRCWla7AXQd++/oyIp8zP+iP9jiUPG6NBj3SHgdgtl/kTn00AjeN+1HNvavTKmYbMo+xMOlw==", - "dev": true - }, - "eslint-plugin-import": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.8.0.tgz", - "integrity": "sha512-Rf7dfKJxZ16QuTgVv1OYNxkZcsu/hULFnC+e+w0Gzi6jMC3guQoWQgxYxc54IDRinlb6/0v5z/PxxIKmVctN+g==", - "dev": true, - "requires": { - "builtin-modules": "1.1.1", - "contains-path": "0.1.0", - "debug": "2.6.9", - "doctrine": "1.5.0", - "eslint-import-resolver-node": "0.3.2", - "eslint-module-utils": "2.2.0", - "has": "1.0.1", - "lodash.cond": "4.5.2", - "minimatch": "3.0.4", - "read-pkg-up": "2.0.0" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "doctrine": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", - "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", - "dev": true, - "requires": { - "esutils": "2.0.2", - "isarray": "1.0.0" - } - } - } - }, - "eslint-plugin-node": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-6.0.1.tgz", - "integrity": "sha512-Q/Cc2sW1OAISDS+Ji6lZS2KV4b7ueA/WydVWd1BECTQwVvfQy5JAi3glhINoKzoMnfnuRgNP+ZWKrGAbp3QDxw==", - "dev": true, - "requires": { - "ignore": "3.3.8", - "minimatch": "3.0.4", - "resolve": "1.5.0", - "semver": "5.4.1" - } - }, - "eslint-plugin-promise": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-3.6.0.tgz", - "integrity": "sha512-YQzM6TLTlApAr7Li8vWKR+K3WghjwKcYzY0d2roWap4SLK+kzuagJX/leTetIDWsFcTFnKNJXWupDCD6aZkP2Q==", - "dev": true - }, - "eslint-plugin-standard": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-3.0.1.tgz", - "integrity": "sha1-NNDJFbRe3G8BA5PH7vOCOwhWXPI=", - "dev": true - }, - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "requires": { - "locate-path": "2.0.0" - } - }, - "globals": { - "version": "11.8.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.8.0.tgz", - "integrity": "sha512-io6LkyPVuzCHBSQV9fmOwxZkUk6nIaGmxheLDgmuFv89j0fm2aqDbIXKAGfzCMHqz3HLF2Zf8WSG6VqMh2qFmA==", - "dev": true - }, - "path-type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", - "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", - "dev": true, - "requires": { - "pify": "2.3.0" - } - }, - "read-pkg": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", - "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", - "dev": true, - "requires": { - "load-json-file": "2.0.0", - "normalize-package-data": "2.4.0", - "path-type": "2.0.0" - } - }, - "read-pkg-up": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", - "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", - "dev": true, - "requires": { - "find-up": "2.1.0", - "read-pkg": "2.0.0" - } - } - } - }, "semver": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", @@ -8155,12 +7535,6 @@ } } }, - "setimmediate": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", - "dev": true - }, "shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", @@ -8430,18 +7804,6 @@ "integrity": "sha1-1PM6tU6OOHeLDKXP07OvsS22hiA=", "dev": true }, - "standard-engine": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/standard-engine/-/standard-engine-8.0.1.tgz", - "integrity": "sha512-LA531C3+nljom/XRvdW/hGPXwmilRkaRkENhO3FAGF1Vtq/WtCXzgmnc5S6vUHHsgv534MRy02C1ikMwZXC+tw==", - "dev": true, - "requires": { - "deglob": "2.1.1", - "get-stdin": "6.0.0", - "minimist": "1.2.0", - "pkg-conf": "2.1.0" - } - }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", @@ -8613,20 +7975,6 @@ "integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=", "dev": true }, - "table": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", - "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", - "dev": true, - "requires": { - "ajv": "5.5.2", - "ajv-keywords": "2.1.1", - "chalk": "2.4.1", - "lodash": "4.17.11", - "slice-ansi": "1.0.0", - "string-width": "2.1.1" - } - }, "tar": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", @@ -8818,18 +8166,6 @@ "prelude-ls": "1.1.2" } }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true - }, - "ua-parser-js": { - "version": "0.7.18", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.18.tgz", - "integrity": "sha512-LtzwHlVHwFGTptfNSgezHp7WUlwiqb0gA9AALRbKaERfxwJoiX0A73QbTToxteIAuIaFshhgIZfqK8s7clqgnA==", - "dev": true - }, "uc.micro": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.5.tgz", @@ -8917,12 +8253,6 @@ } } }, - "uniq": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", - "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=", - "dev": true - }, "universalify": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz", @@ -9111,12 +8441,6 @@ } } }, - "whatwg-fetch": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", - "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==", - "dev": true - }, "whatwg-mimetype": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.1.0.tgz", @@ -9252,12 +8576,6 @@ "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==", "dev": true }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - }, "y18n": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", diff --git a/scripts/module.js b/scripts/module.js index 87ab15fa4..901778a05 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -3,72 +3,116 @@ */ // Load modules const fs = require('fs-extra'); -const cp = require('child_process'); const path = require('path'); const chalk = require('chalk'); const util = require('./util'); -if (util.isTravisCI() && util.isNotTravisCronOrAPI()) { - console.log( - `${chalk.green('NOBUILD')} Module build terminated, not a cron job or a custom build!` - ); - process.exit(0); -} +const { rollup } = require('rollup'); +const babel = require('rollup-plugin-babel'); +const minify = require('rollup-plugin-babel-minify'); // Set variables for paths const SNIPPETS_PATH = './snippets'; -const TEMP_PATH = './temp'; +const SNIPPETS_ARCHIVE_PATH = './snippets_archive'; const IMPORTS = './imports.js'; +const TEST_PACKAGE = './test/_30s.js'; +const MODULE_NAME = '_30s'; +const DIST = './dist'; // Regex for selecting code blocks const codeRE = /```\s*js([\s\S]*?)```/; -// Start the timer of the script -console.time('Packager'); -// Load tag data from the database and snippets from their folder -try { - const tagDatabase = fs.readFileSync('tag_database', 'utf8'); - const snippets = fs.readdirSync(SNIPPETS_PATH); - // Create `temp` folder if it doesn't already exist. - if (!fs.existsSync(TEMP_PATH)) { - fs.mkdirSync(TEMP_PATH); +// Read snippets, build packages +(async () => { + // Start the timer of the script + console.time('Packager'); + try { + const tagDatabase = fs.readFileSync('tag_database', 'utf8'); + const nodeSnippets = tagDatabase.split('\n').filter(v => v.search(/:.*node/g) !== -1).map(v => v.slice(0,v.indexOf(':'))); + const snippets = fs.readdirSync(SNIPPETS_PATH); + const snippetExports = `module.exports = {${snippets.map(v => v.replace('.md', '')).join(',')}}`; + let requires = []; + let importData = ''; + const archivedSnippets = fs.readdirSync(SNIPPETS_ARCHIVE_PATH).filter(v => v !== 'README.md'); + const testExports = `module.exports = {${[...snippets,...archivedSnippets].map(v => v.replace('.md', '')).join(',')}}`; + // Create `temp` and `dist` folders if they don't already exist. + if (!fs.existsSync(DIST)) fs.mkdirSync(DIST); + // Write `imports.js` + fs.writeFileSync(IMPORTS, ''); + fs.writeFileSync(TEST_PACKAGE, ''); + + snippets.forEach(snippet => { + const snippetData = fs.readFileSync(path.join(SNIPPETS_PATH, snippet), 'utf8'); + const snippetName = snippet.replace('.md', ''); + let code = snippetData.match(codeRE)[1].replace('\n', ''); + if (nodeSnippets.includes(snippetName)) { + requires.push(code.match(/const.*=.*require\(([^\)]*)\);/g)); + code = code.replace(/const.*=.*require\(([^\)]*)\);/g,''); + } + importData += code; + }); + // Write the data to the imports file + requires = [...new Set(requires.filter(Boolean).map(v => v[0].replace('require(', 'typeof require !== "undefined" && require(')))].join('\n'); + fs.writeFileSync(IMPORTS, `${requires}\n\n${importData}\n\n${snippetExports}`); + + archivedSnippets.forEach(snippet => { + const snippetData = fs.readFileSync(path.join(SNIPPETS_ARCHIVE_PATH, snippet), 'utf8'); + let code = snippetData.match(codeRE)[1].replace('\n', ''); + importData += code; + }); + fs.writeFileSync(TEST_PACKAGE, `${requires}\n\n${importData}\n\n${testExports}`); + + // Check Travis builds - Will skip builds on Travis if not CRON/API + if (util.isTravisCI() && util.isNotTravisCronOrAPI()) { + fs.unlink(IMPORTS); + console.log( + `${chalk.green('NOBUILD')} Module build terminated, not a cron job or a custom build!` + ); + console.timeEnd('Packager'); + process.exit(0); + } + + // Write to the proper files and start the `rollup` script + const es5 = babel({ + presets: ['@babel/preset-env'] + }); + const min = minify({ comments: false }); + const bundle = await rollup({ input: IMPORTS }); + // UMD ES2018 + await bundle.write({ + file: `${DIST}/${MODULE_NAME}.js`, + name: MODULE_NAME, + format: 'umd' + }); + // ESM ES2018 + await bundle.write({ + file: `${DIST}/${MODULE_NAME}.esm.js`, + name: MODULE_NAME, + format: 'es' + }); + // UMD ES5 + const bundleES5 = await rollup({ input: IMPORTS, plugins: [es5] }); + await bundleES5.write({ + file: `${DIST}/${MODULE_NAME}.es5.js`, + name: MODULE_NAME, + format: 'umd' + }); + // UMD ES5 min + const bundleES5Min = await rollup({ + input: IMPORTS, + plugins: [es5, min] + }); + await bundleES5Min.write({ + file: `${DIST}/${MODULE_NAME}.es5.min.js`, + name: MODULE_NAME, + format: 'umd' + }); + + // Clean up temporary data + fs.unlink(IMPORTS); + // Log a success message + console.log(`${chalk.green('SUCCESS!')} Snippet module built!`); + // Log the time taken + console.timeEnd('Packager'); + } catch (err) { + // Handle errors (hopefully not!) + console.log(`${chalk.red('ERROR!')} During module creation: ${err}`); + process.exit(1); } - // Write `imports.js` - fs.writeFileSync(IMPORTS, ''); - // Read all snippets and store them appropriately - for (const snippet of snippets) { - const snippetData = fs.readFileSync(path.join(SNIPPETS_PATH, snippet), 'utf8'); - const snippetName = snippet.replace('.md', ''); - // Check if a snippet is Node-only - const isNodeSnippet = tagDatabase - .slice(tagDatabase.indexOf(snippetName) + snippetName.length + 1) - .split('\n')[0] - .includes('node'); - // Read `imports.js` and write the data - const importData = fs.readFileSync(IMPORTS, 'utf8'); - fs.writeFileSync( - IMPORTS, - importData + `\nexport { ${snippetName} } from './temp/${snippetName}.js'` - ); - // Find the code in each snippet - const code = snippetData.match(codeRE)[1].replace('\n', ''); - // Store the data to be written - const toWrite = isNodeSnippet - ? `${code - .replace(`const ${snippetName}`, `export const ${snippetName}`) - // Prevents errors from being thrown in browser environment - .replace('require(', 'typeof require !== "undefined" && require(')}` - : `export ${code}`; - // Write data to the proper file - fs.writeFileSync(`${TEMP_PATH}/${snippetName}.js`, toWrite); - } - // Write to the proper files and start the `rollup` script - cp.execSync('node ./scripts/rollup.js'); - // Clean up temporary data - fs.removeSync(TEMP_PATH); - fs.unlink(IMPORTS); - // Log a success message - console.log(`${chalk.green('SUCCESS!')} Snippet module built!`); - // Log the time taken - console.timeEnd('Packager'); -} catch (err) { - // Handle errors (hopefully not!) - console.log(`${chalk.red('ERROR!')} During module creation: ${err}`); - process.exit(1); -} +})(); \ No newline at end of file diff --git a/scripts/rollup.js b/scripts/rollup.js deleted file mode 100644 index f7a349165..000000000 --- a/scripts/rollup.js +++ /dev/null @@ -1,56 +0,0 @@ -/* - Part of the process for building the `_30s` module. -*/ -// Load modules -const fs = require('fs-extra'); -const { rollup } = require('rollup'); -const babel = require('rollup-plugin-babel'); -const minify = require('rollup-plugin-babel-minify'); -// Set variables for paths -const INPUT_FILE = './imports.js'; -const MODULE_NAME = '_30s'; -const DIST = './dist'; -// Create `dist` folder if not existing -if (!fs.existsSync(DIST)) fs.mkdirSync(DIST); -// Setup babel and minification -const es5 = babel({ - presets: ['@babel/preset-env'] -}); -const min = minify({ comments: false }); -// Create the bundles -(async () => { - const bundle = await rollup({ input: INPUT_FILE }); - const bundleES5 = await rollup({ input: INPUT_FILE, plugins: [es5] }); - const bundleES5Min = await rollup({ - input: INPUT_FILE, - plugins: [es5, min] - }); - - // UMD ES2018 - await bundle.write({ - file: `${DIST}/${MODULE_NAME}.js`, - name: MODULE_NAME, - format: 'umd' - }); - - // ESM ES2018 - await bundle.write({ - file: `${DIST}/${MODULE_NAME}.esm.js`, - name: MODULE_NAME, - format: 'es' - }); - - // UMD ES5 - await bundleES5.write({ - file: `${DIST}/${MODULE_NAME}.es5.js`, - name: MODULE_NAME, - format: 'umd' - }); - - // UMD ES5 min - await bundleES5Min.write({ - file: `${DIST}/${MODULE_NAME}.es5.min.js`, - name: MODULE_NAME, - format: 'umd' - }); -})(); diff --git a/scripts/tdd.js b/scripts/tdd.js index 64b18f078..46cf22799 100644 --- a/scripts/tdd.js +++ b/scripts/tdd.js @@ -14,79 +14,38 @@ if (util.isTravisCI() && util.isNotTravisCronOrAPI()) { process.exit(0); } // Declare paths -const SNIPPETS_ACTIVE = './snippets'; -const SNIPPETS_ARCHIVE = './snippets_archive'; +const SNIPPETS_PATH = './snippets'; +const SNIPPETS_ARCHIVE_PATH = './snippets_archive'; const TEST_PATH = './test'; -// Array of snippet names -const snippetFiles = []; - -const snippetFilesActive = fs - .readdirSync(SNIPPETS_ACTIVE, 'utf8') - .map(fileName => fileName.slice(0, -3)); -const snippetFilesArchive = fs - .readdirSync(SNIPPETS_ARCHIVE, 'utf8') - .filter(fileName => !fileName.includes('README')) // -> Filters out main README.md file in Archieve which isn't a snippet - .map(fileName => fileName.slice(0, -3)); - -snippetFiles.push(...snippetFilesActive); -snippetFiles.push(...snippetFilesArchive); - console.time('Tester'); -snippetFiles - .map(fileName => { - // Check if fileName for snippet exist in test/ dir, if doesnt create - fs.ensureDirSync(path.join(TEST_PATH, fileName)); - - // return fileName for later use - return fileName; +try { + // Read snippets, archive and tests, find which tests are not defined + const snippets = fs.readdirSync(SNIPPETS_PATH).map(v => v.replace('.md', '')); + const archivedSnippets = fs.readdirSync(SNIPPETS_ARCHIVE_PATH).filter(v => v !== 'README.md').map(v => v.replace('.md', '')); + const definedTests = fs.readdirSync(TEST_PATH).map(v => v.replace('.test.js', '')).filter(v => v !== '_30s.js' && v !== 'testlog'); + const undefinedTests = [...snippets, ...archivedSnippets].filter(v => !definedTests.includes(v)); + const orphanedTests = [...definedTests.filter(v => ![...snippets, ...archivedSnippets].includes(v))]; + orphanedTests.forEach(snippet => { + console.log(`${chalk.yellow('WARNING!')} Orphaned test: ${snippet}`); }) - .map(fileName => { - const activeOrArchive = snippetFilesActive.includes(fileName) - ? SNIPPETS_ACTIVE - : SNIPPETS_ARCHIVE; - // Grab snippetData - const fileData = fs.readFileSync(path.join(activeOrArchive, `${fileName}.md`), 'utf8'); - // Grab snippet Code blocks - const fileCode = fileData.slice(fileData.search(/```\s*js/i), fileData.lastIndexOf('```') + 3); - // Split code based on code markers - const blockMarkers = fileCode - .split('\n') - .map((line, lineIndex) => (line.slice(0, 3) === '```' ? lineIndex : '//CLEAR//')) - .filter(x => !(x === '//CLEAR//')); - // Grab snippet function based on code markers - const fileFunction = fileCode - .split('\n') - .map(line => line) - .filter((_, i) => blockMarkers[0] < i && i < blockMarkers[1]); - - // Export template for snippetName.js - const exportFile = `${fileFunction.join('\n')}\nmodule.exports = ${fileName};\n`; - - // Export template for snippetName.test.js which generates a example test & other information + // Create files for undefined tests + undefinedTests.forEach(snippet => { const exportTest = [ `const expect = require('expect');`, - `const ${fileName} = require('./${fileName}.js');`, - `\ntest('${fileName} is a Function', () => {`, - ` expect(${fileName}).toBeInstanceOf(Function);`, + `const {${snippet}} = require('._30s.js');`, + `\ntest('${snippet} is a Function', () => {`, + ` expect(${snippet}).toBeInstanceOf(Function);`, `});\n` ].join('\n'); - - // Write/Update exportFile which is snippetName.js in respective dir - fs.writeFileSync(path.join(TEST_PATH, fileName, `${fileName}.js`), exportFile); - - if (!fs.existsSync(path.join(TEST_PATH, fileName, `${fileName}.test.js`))) { - // if snippetName.test.js doesn't exist inrespective dir exportTest - fs.writeFileSync(`${TEST_PATH}/${fileName}/${fileName}.test.js`, exportTest); - } - - // return fileName for later use - return fileName; + fs.writeFileSync(path.join(TEST_PATH, `${snippet}.test.js`), exportTest); }); -try { + // Run tests fs.writeFileSync(path.join(TEST_PATH, 'testlog'), `Test log for: ${new Date().toString()}\n`); childProcess.execSync('npm test'); -} catch (e) { - fs.appendFileSync(path.join(TEST_PATH, 'testlog')); + console.log(`${chalk.green('SUCCESS!')} All tests ran successfully!`); +} catch (err) { + console.log(`${chalk.red('ERROR!')} During test runs: ${err}`); + process.exit(1); } -console.timeEnd('Tester'); +console.timeEnd('Tester'); \ No newline at end of file diff --git a/scripts/util.js b/scripts/util.js index 1be96e75a..ab74148e9 100644 --- a/scripts/util.js +++ b/scripts/util.js @@ -105,8 +105,9 @@ const capitalize = (str, lowerRest = false) => str.slice(0, 1).toUpperCase() + (lowerRest ? str.slice(1).toLowerCase() : str.slice(1)); // Checks if current environment is Travis CI const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; -const isNotTravisCronOrAPI = () => - process.env['TRAVIS_EVENT_TYPE'] !== 'cron' && process.env['TRAVIS_EVENT_TYPE'] !== 'api'; +const isTravisCronOrAPI = () => + process.env['TRAVIS_EVENT_TYPE'] === 'cron' && process.env['TRAVIS_EVENT_TYPE'] === 'api'; +const isNotTravisCronOrAPI = () => !isTravisCronOrAPI(); // Creates a hash for a value using the SHA-256 algorithm. const hashData = val => crypto @@ -167,6 +168,7 @@ module.exports = { shuffle, getCodeBlocks, getTextualContent, + isTravisCronOrAPI, isNotTravisCronOrAPI, prepTaggedData }; diff --git a/test/CSVToArray/CSVToArray.test.js b/test/CSVToArray.test.js similarity index 93% rename from test/CSVToArray/CSVToArray.test.js rename to test/CSVToArray.test.js index 868ad679e..b938fa4ea 100644 --- a/test/CSVToArray/CSVToArray.test.js +++ b/test/CSVToArray.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const CSVToArray = require('./CSVToArray.js'); +const {CSVToArray} = require('./_30s.js'); test('CSVToArray is a Function', () => { expect(CSVToArray).toBeInstanceOf(Function); diff --git a/test/CSVToArray/CSVToArray.js b/test/CSVToArray/CSVToArray.js deleted file mode 100644 index da9287894..000000000 --- a/test/CSVToArray/CSVToArray.js +++ /dev/null @@ -1,6 +0,0 @@ -const CSVToArray = (data, delimiter = ',', omitFirstRow = false) => - data - .slice(omitFirstRow ? data.indexOf('\n') + 1 : 0) - .split('\n') - .map(v => v.split(delimiter)); -module.exports = CSVToArray; diff --git a/test/CSVToJSON/CSVToJSON.test.js b/test/CSVToJSON.test.js similarity index 91% rename from test/CSVToJSON/CSVToJSON.test.js rename to test/CSVToJSON.test.js index 16c115bf2..b89986287 100644 --- a/test/CSVToJSON/CSVToJSON.test.js +++ b/test/CSVToJSON.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const CSVToJSON = require('./CSVToJSON.js'); +const {CSVToJSON} = require('./_30s.js'); test('CSVToJSON is a Function', () => { expect(CSVToJSON).toBeInstanceOf(Function); diff --git a/test/CSVToJSON/CSVToJSON.js b/test/CSVToJSON/CSVToJSON.js deleted file mode 100644 index d9504142c..000000000 --- a/test/CSVToJSON/CSVToJSON.js +++ /dev/null @@ -1,11 +0,0 @@ -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), {}); - }); -}; -module.exports = CSVToJSON; diff --git a/test/JSONToDate/JSONToDate.test.js b/test/JSONToDate.test.js similarity index 72% rename from test/JSONToDate/JSONToDate.test.js rename to test/JSONToDate.test.js index 8a9ca3412..d1c041a98 100644 --- a/test/JSONToDate/JSONToDate.test.js +++ b/test/JSONToDate.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const JSONToDate = require('./JSONToDate.js'); +const {JSONToDate} = require('./_30s.js'); test('JSONToDate is a Function', () => { expect(JSONToDate).toBeInstanceOf(Function); diff --git a/test/JSONToDate/JSONToDate.js b/test/JSONToDate/JSONToDate.js deleted file mode 100644 index 3111603c9..000000000 --- a/test/JSONToDate/JSONToDate.js +++ /dev/null @@ -1,5 +0,0 @@ -const JSONToDate = arr => { - const dt = new Date(parseInt(arr.toString().substr(6))); - return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`; -}; -module.exports = JSONToDate; diff --git a/test/JSONToFile/JSONToFile.test.js b/test/JSONToFile.test.js similarity index 72% rename from test/JSONToFile/JSONToFile.test.js rename to test/JSONToFile.test.js index 325eface8..165e47b4a 100644 --- a/test/JSONToFile/JSONToFile.test.js +++ b/test/JSONToFile.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const JSONToFile = require('./JSONToFile.js'); +const {JSONToFile} = require('./_30s.js'); test('JSONToFile is a Function', () => { expect(JSONToFile).toBeInstanceOf(Function); diff --git a/test/JSONToFile/JSONToFile.js b/test/JSONToFile/JSONToFile.js deleted file mode 100644 index 1111c55b2..000000000 --- a/test/JSONToFile/JSONToFile.js +++ /dev/null @@ -1,4 +0,0 @@ -const fs = require('fs'); -const JSONToFile = (obj, filename) => - fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2)); -module.exports = JSONToFile; diff --git a/test/JSONtoCSV/JSONtoCSV.test.js b/test/JSONtoCSV.test.js similarity index 92% rename from test/JSONtoCSV/JSONtoCSV.test.js rename to test/JSONtoCSV.test.js index aed050f58..294fc23c2 100644 --- a/test/JSONtoCSV/JSONtoCSV.test.js +++ b/test/JSONtoCSV.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const JSONtoCSV = require('./JSONtoCSV.js'); +const {JSONtoCSV} = require('./_30s.js'); test('JSONtoCSV is a Function', () => { expect(JSONtoCSV).toBeInstanceOf(Function); diff --git a/test/JSONtoCSV/JSONtoCSV.js b/test/JSONtoCSV/JSONtoCSV.js deleted file mode 100644 index 81cf14b43..000000000 --- a/test/JSONtoCSV/JSONtoCSV.js +++ /dev/null @@ -1,11 +0,0 @@ -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'); -module.exports = JSONtoCSV; diff --git a/test/RGBToHex/RGBToHex.test.js b/test/RGBToHex.test.js similarity index 85% rename from test/RGBToHex/RGBToHex.test.js rename to test/RGBToHex.test.js index 70892c498..49f723ee2 100644 --- a/test/RGBToHex/RGBToHex.test.js +++ b/test/RGBToHex.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const RGBToHex = require('./RGBToHex.js'); +const {RGBToHex} = require('./_30s.js'); test('RGBToHex is a Function', () => { expect(RGBToHex).toBeInstanceOf(Function); diff --git a/test/RGBToHex/RGBToHex.js b/test/RGBToHex/RGBToHex.js deleted file mode 100644 index 9f829a0f9..000000000 --- a/test/RGBToHex/RGBToHex.js +++ /dev/null @@ -1,2 +0,0 @@ -const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); -module.exports = RGBToHex; diff --git a/test/URLJoin/URLJoin.test.js b/test/URLJoin.test.js similarity index 92% rename from test/URLJoin/URLJoin.test.js rename to test/URLJoin.test.js index dbc0a511b..544bd65c0 100644 --- a/test/URLJoin/URLJoin.test.js +++ b/test/URLJoin.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const URLJoin = require('./URLJoin.js'); +const {URLJoin} = require('./_30s.js'); test('URLJoin is a Function', () => { expect(URLJoin).toBeInstanceOf(Function); diff --git a/test/URLJoin/URLJoin.js b/test/URLJoin/URLJoin.js deleted file mode 100644 index 52490a893..000000000 --- a/test/URLJoin/URLJoin.js +++ /dev/null @@ -1,10 +0,0 @@ -const URLJoin = (...args) => - args - .join('/') - .replace(/[\/]+/g, '/') - .replace(/^(.+):\//, '$1://') - .replace(/^file:/, 'file:/') - .replace(/\/(\?|&|#[^!])/g, '$1') - .replace(/\?/g, '&') - .replace('&', '?'); -module.exports = URLJoin; diff --git a/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.test.js b/test/UUIDGeneratorBrowser.test.js similarity index 68% rename from test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.test.js rename to test/UUIDGeneratorBrowser.test.js index 60033da0e..f0b4bb4ef 100644 --- a/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.test.js +++ b/test/UUIDGeneratorBrowser.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const UUIDGeneratorBrowser = require('./UUIDGeneratorBrowser.js'); +const {UUIDGeneratorBrowser} = require('./_30s.js'); test('UUIDGeneratorBrowser is a Function', () => { expect(UUIDGeneratorBrowser).toBeInstanceOf(Function); diff --git a/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js b/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js deleted file mode 100644 index 000ec1279..000000000 --- a/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js +++ /dev/null @@ -1,5 +0,0 @@ -const UUIDGeneratorBrowser = () => - ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => - (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16) - ); -module.exports = UUIDGeneratorBrowser; diff --git a/test/UUIDGeneratorNode/UUIDGeneratorNode.test.js b/test/UUIDGeneratorNode.test.js similarity index 87% rename from test/UUIDGeneratorNode/UUIDGeneratorNode.test.js rename to test/UUIDGeneratorNode.test.js index 8c3aa4356..a98eabcc5 100644 --- a/test/UUIDGeneratorNode/UUIDGeneratorNode.test.js +++ b/test/UUIDGeneratorNode.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const UUIDGeneratorNode = require('./UUIDGeneratorNode.js'); +const {UUIDGeneratorNode} = require('./_30s.js'); test('UUIDGeneratorNode is a Function', () => { expect(UUIDGeneratorNode).toBeInstanceOf(Function); diff --git a/test/UUIDGeneratorNode/UUIDGeneratorNode.js b/test/UUIDGeneratorNode/UUIDGeneratorNode.js deleted file mode 100644 index 6e314792e..000000000 --- a/test/UUIDGeneratorNode/UUIDGeneratorNode.js +++ /dev/null @@ -1,6 +0,0 @@ -const crypto = require('crypto'); -const UUIDGeneratorNode = () => - ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => - (c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16) - ); -module.exports = UUIDGeneratorNode; diff --git a/test/_30s.js b/test/_30s.js new file mode 100644 index 000000000..0da3161e4 --- /dev/null +++ b/test/_30s.js @@ -0,0 +1,1488 @@ +const crypto = typeof require !== "undefined" && require('crypto'); +const fs = typeof require !== "undefined" && require('fs'); + + 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 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 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 = els => els.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 = (val, ...vals) => + [val, ...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 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 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 binarySearch = (arr, val, start = 0, end = arr.length - 1) => { + if (start > end) return -1; + const mid = Math.floor((start + end) / 2); + if (arr[mid] > val) return binarySearch(arr, val, start, mid - 1); + if (arr[mid] < val) return binarySearch(arr, val, mid + 1, end); + return mid; +}; + const celsiusToFahrenheit = degrees => 1.8 * degrees + 32; + const cleanObj = (obj, keysToKeep = [], childIndicator) => { + Object.keys(obj).forEach(key => { + if (key === childIndicator) { + cleanObj(obj[key], keysToKeep, childIndicator); + } else if (!keysToKeep.includes(key)) { + delete obj[key]; + } + }); + return obj; +}; + const collatz = n => (n % 2 === 0 ? n / 2 : 3 * n + 1); + const countVowels = str => (str.match(/[aeiou]/gi) || []).length; + const factors = (num, primes = false) => { + 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 isNeg = num < 0; + num = isNeg ? -num : num; + let array = Array.from({ length: num - 1 }) + .map((val, i) => (num % (i + 2) === 0 ? i + 2 : false)) + .filter(val => val); + if (isNeg) + array = array.reduce((acc, val) => { + acc.push(val); + acc.push(-val); + return acc; + }, []); + return primes ? array.filter(isPrime) : array; +}; + const fahrenheitToCelsius = degrees => (degrees - 32) * 5/9; + const fibonacciCountUntilNum = num => + Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2)); + const fibonacciUntilNum = num => { + let n = Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2)); + return Array.from({ length: n }).reduce( + (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), + [] + ); +}; + const heronArea = (side_a, side_b, side_c) => { + const p = (side_a + side_b + side_c) / 2 + return Math.sqrt(p * (p-side_a) * (p-side_b) * (p-side_c)) + }; + const howManyTimes = (num, divisor) => { + if (divisor === 1 || divisor === -1) return Infinity; + if (divisor === 0) return 0; + let i = 0; + while (Number.isInteger(num / divisor)) { + i++; + num = num / divisor; + } + return i; +}; + const httpDelete = (url, callback, err = console.error) => { + const request = new XMLHttpRequest(); + request.open('DELETE', url, true); + request.onload = () => callback(request); + request.onerror = () => err(request); + request.send(); +}; + const httpPut = (url, data, callback, err = console.error) => { + const request = new XMLHttpRequest(); + request.open("PUT", url, true); + request.setRequestHeader('Content-type','application/json; charset=utf-8'); + request.onload = () => callback(request); + request.onerror = () => err(request); + request.send(data); +}; + const isArmstrongNumber = digits => + (arr => arr.reduce((a, d) => a + parseInt(d) ** arr.length, 0) == digits)( + (digits + '').split('') + ); + const isSimilar = (pattern, str) => + [...str].reduce( + (matchIndex, char) => + char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() + ? matchIndex + 1 + : matchIndex, + 0 + ) === pattern.length; + const JSONToDate = arr => { + const dt = new Date(parseInt(arr.toString().substr(6))); + return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`; +}; + const kmphToMph = (kmph) => 0.621371192 * kmph; + const levenshteinDistance = (string1, string2) => { + if (string1.length === 0) return string2.length; + if (string2.length === 0) return string1.length; + let matrix = Array(string2.length + 1) + .fill(0) + .map((x, i) => [i]); + matrix[0] = Array(string1.length + 1) + .fill(0) + .map((x, i) => i); + for (let i = 1; i <= string2.length; i++) { + for (let j = 1; j <= string1.length; j++) { + if (string2[i - 1] === string1[j - 1]) { + matrix[i][j] = matrix[i - 1][j - 1]; + } else { + matrix[i][j] = Math.min( + matrix[i - 1][j - 1] + 1, + matrix[i][j - 1] + 1, + matrix[i - 1][j] + 1 + ); + } + } + } + return matrix[string2.length][string1.length]; +}; + const mphToKmph = (mph) => 1.6093440006146922 * mph; + const pipeLog = data => console.log(data) || data; + const quickSort = ([n, ...nums], desc) => + isNaN(n) + ? [] + : [ + ...quickSort(nums.filter(v => (desc ? v > n : v <= n)), desc), + n, + ...quickSort(nums.filter(v => (!desc ? v > n : v <= n)), desc) + ]; + const removeVowels = (str, repl = '') => str.replace(/[aeiou]/gi, repl); + const solveRPN = rpn => { + const OPERATORS = { + '*': (a, b) => a * b, + '+': (a, b) => a + b, + '-': (a, b) => a - b, + '/': (a, b) => a / b, + '**': (a, b) => a ** b + }; + const [stack, solve] = [ + [], + rpn + .replace(/\^/g, '**') + .split(/\s+/g) + .filter(el => !/\s+/.test(el) && el !== '') + ]; + solve.forEach(symbol => { + if (!isNaN(parseFloat(symbol)) && isFinite(symbol)) { + stack.push(symbol); + } else if (Object.keys(OPERATORS).includes(symbol)) { + const [a, b] = [stack.pop(), stack.pop()]; + stack.push(OPERATORS[symbol](parseFloat(b), parseFloat(a))); + } else { + throw `${symbol} is not a recognized symbol`; + } + }); + if (stack.length === 1) return stack.pop(); + else throw `${rpn} is not a proper RPN. Please check it and try again`; +}; + const speechSynthesis = message => { + const msg = new SpeechSynthesisUtterance(message); + msg.voice = window.speechSynthesis.getVoices()[0]; + window.speechSynthesis.speak(msg); +}; + const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0); + + +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,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,binarySearch,celsiusToFahrenheit,cleanObj,collatz,countVowels,factors,fahrenheitToCelsius,fibonacciCountUntilNum,fibonacciUntilNum,heronArea,howManyTimes,httpDelete,httpPut,isArmstrongNumber,isSimilar,JSONToDate,kmphToMph,levenshteinDistance,mphToKmph,pipeLog,quickSort,removeVowels,solveRPN,speechSynthesis,squareSum} \ No newline at end of file diff --git a/test/all/all.test.js b/test/all.test.js similarity index 96% rename from test/all/all.test.js rename to test/all.test.js index 8e072acf6..f0fbf739d 100644 --- a/test/all/all.test.js +++ b/test/all.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const all = require('./all.js'); +const {all} = require('./_30s.js'); test('all is a Function', () => { expect(all).toBeInstanceOf(Function); diff --git a/test/all/all.js b/test/all/all.js deleted file mode 100644 index d07bb7f7a..000000000 --- a/test/all/all.js +++ /dev/null @@ -1,2 +0,0 @@ -const all = (arr, fn = Boolean) => arr.every(fn); -module.exports = all; diff --git a/test/allEqual/allEqual.test.js b/test/allEqual.test.js similarity index 95% rename from test/allEqual/allEqual.test.js rename to test/allEqual.test.js index 220b61cbf..ea1ac4629 100644 --- a/test/allEqual/allEqual.test.js +++ b/test/allEqual.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const allEqual = require('./allEqual.js'); +const {allEqual} = require('./_30s.js'); test('allEqual is a Function', () => { expect(allEqual).toBeInstanceOf(Function); diff --git a/test/allEqual/allEqual.js b/test/allEqual/allEqual.js deleted file mode 100644 index 79f392d3b..000000000 --- a/test/allEqual/allEqual.js +++ /dev/null @@ -1,2 +0,0 @@ -const allEqual = arr => arr.every(val => val === arr[0]); -module.exports = allEqual; diff --git a/test/any/any.test.js b/test/any.test.js similarity index 94% rename from test/any/any.test.js rename to test/any.test.js index 003b22654..89a38a29b 100644 --- a/test/any/any.test.js +++ b/test/any.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const any = require('./any.js'); +const {any} = require('./_30s.js'); test('any is a Function', () => { expect(any).toBeInstanceOf(Function); diff --git a/test/any/any.js b/test/any/any.js deleted file mode 100644 index 87a89d9e4..000000000 --- a/test/any/any.js +++ /dev/null @@ -1,2 +0,0 @@ -const any = (arr, fn = Boolean) => arr.some(fn); -module.exports = any; diff --git a/test/approximatelyEqual/approximatelyEqual.test.js b/test/approximatelyEqual.test.js similarity index 89% rename from test/approximatelyEqual/approximatelyEqual.test.js rename to test/approximatelyEqual.test.js index 462e9455f..c0bab6e2e 100644 --- a/test/approximatelyEqual/approximatelyEqual.test.js +++ b/test/approximatelyEqual.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const approximatelyEqual = require('./approximatelyEqual.js'); +const {approximatelyEqual} = require('./_30s.js'); test('approximatelyEqual is a Function', () => { expect(approximatelyEqual).toBeInstanceOf(Function); diff --git a/test/approximatelyEqual/approximatelyEqual.js b/test/approximatelyEqual/approximatelyEqual.js deleted file mode 100644 index d519097ed..000000000 --- a/test/approximatelyEqual/approximatelyEqual.js +++ /dev/null @@ -1,2 +0,0 @@ -const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon; -module.exports = approximatelyEqual; diff --git a/test/arrayToCSV/arrayToCSV.test.js b/test/arrayToCSV.test.js similarity index 89% rename from test/arrayToCSV/arrayToCSV.test.js rename to test/arrayToCSV.test.js index f45ce65b7..c9d36d114 100644 --- a/test/arrayToCSV/arrayToCSV.test.js +++ b/test/arrayToCSV.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const arrayToCSV = require('./arrayToCSV.js'); +const {arrayToCSV} = require('./_30s.js'); test('arrayToCSV is a Function', () => { expect(arrayToCSV).toBeInstanceOf(Function); diff --git a/test/arrayToCSV/arrayToCSV.js b/test/arrayToCSV/arrayToCSV.js deleted file mode 100644 index 561628034..000000000 --- a/test/arrayToCSV/arrayToCSV.js +++ /dev/null @@ -1,3 +0,0 @@ -const arrayToCSV = (arr, delimiter = ',') => - arr.map(v => v.map(x => `"${x}"`).join(delimiter)).join('\n'); -module.exports = arrayToCSV; diff --git a/test/arrayToHtmlList/arrayToHtmlList.test.js b/test/arrayToHtmlList.test.js similarity index 70% rename from test/arrayToHtmlList/arrayToHtmlList.test.js rename to test/arrayToHtmlList.test.js index 07a97dcf8..a751a7c87 100644 --- a/test/arrayToHtmlList/arrayToHtmlList.test.js +++ b/test/arrayToHtmlList.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const arrayToHtmlList = require('./arrayToHtmlList.js'); +const {arrayToHtmlList} = require('./_30s.js'); test('arrayToHtmlList is a Function', () => { expect(arrayToHtmlList).toBeInstanceOf(Function); diff --git a/test/arrayToHtmlList/arrayToHtmlList.js b/test/arrayToHtmlList/arrayToHtmlList.js deleted file mode 100644 index e669b1c81..000000000 --- a/test/arrayToHtmlList/arrayToHtmlList.js +++ /dev/null @@ -1,6 +0,0 @@ -const arrayToHtmlList = (arr, listID) => - (el => ( - (el = document.querySelector('#' + listID)), - (el.innerHTML += arr.map(item => `
  • ${item}
  • `).join('')) - ))(); -module.exports = arrayToHtmlList; diff --git a/test/ary/ary.test.js b/test/ary.test.js similarity index 89% rename from test/ary/ary.test.js rename to test/ary.test.js index e695ca124..dd9816d9e 100644 --- a/test/ary/ary.test.js +++ b/test/ary.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const ary = require('./ary.js'); +const {ary} = require('./_30s.js'); test('ary is a Function', () => { expect(ary).toBeInstanceOf(Function); diff --git a/test/ary/ary.js b/test/ary/ary.js deleted file mode 100644 index cde6753cd..000000000 --- a/test/ary/ary.js +++ /dev/null @@ -1,2 +0,0 @@ -const ary = (fn, n) => (...args) => fn(...args.slice(0, n)); -module.exports = ary; diff --git a/test/atob/atob.test.js b/test/atob.test.js similarity index 88% rename from test/atob/atob.test.js rename to test/atob.test.js index 43c4f1386..e33428f9c 100644 --- a/test/atob/atob.test.js +++ b/test/atob.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const atob = require('./atob.js'); +const {atob} = require('./_30s.js'); test('atob is a Function', () => { expect(atob).toBeInstanceOf(Function); diff --git a/test/atob/atob.js b/test/atob/atob.js deleted file mode 100644 index 6dc03b03b..000000000 --- a/test/atob/atob.js +++ /dev/null @@ -1,2 +0,0 @@ -const atob = str => Buffer.from(str, 'base64').toString('binary'); -module.exports = atob; diff --git a/test/attempt/attempt.test.js b/test/attempt.test.js similarity index 88% rename from test/attempt/attempt.test.js rename to test/attempt.test.js index 8d70bcba3..1dd0f1ce3 100644 --- a/test/attempt/attempt.test.js +++ b/test/attempt.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const attempt = require('./attempt.js'); +const {attempt} = require('./_30s.js'); test('attempt is a Function', () => { expect(attempt).toBeInstanceOf(Function); diff --git a/test/attempt/attempt.js b/test/attempt/attempt.js deleted file mode 100644 index e7ffd905f..000000000 --- a/test/attempt/attempt.js +++ /dev/null @@ -1,8 +0,0 @@ -const attempt = (fn, ...args) => { - try { - return fn(...args); - } catch (e) { - return e instanceof Error ? e : new Error(e); - } -}; -module.exports = attempt; diff --git a/test/average/average.test.js b/test/average.test.js similarity index 97% rename from test/average/average.test.js rename to test/average.test.js index ee2a971a0..47efaa0d8 100644 --- a/test/average/average.test.js +++ b/test/average.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const average = require('./average.js'); +const {average} = require('./_30s.js'); test('average is a Function', () => { expect(average).toBeInstanceOf(Function); diff --git a/test/average/average.js b/test/average/average.js deleted file mode 100644 index b1ddb1022..000000000 --- a/test/average/average.js +++ /dev/null @@ -1,2 +0,0 @@ -const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length; -module.exports = average; diff --git a/test/averageBy/averageBy.test.js b/test/averageBy.test.js similarity index 90% rename from test/averageBy/averageBy.test.js rename to test/averageBy.test.js index 044d407df..401413357 100644 --- a/test/averageBy/averageBy.test.js +++ b/test/averageBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const averageBy = require('./averageBy.js'); +const {averageBy} = require('./_30s.js'); test('averageBy is a Function', () => { expect(averageBy).toBeInstanceOf(Function); diff --git a/test/averageBy/averageBy.js b/test/averageBy/averageBy.js deleted file mode 100644 index dc9f07bc7..000000000 --- a/test/averageBy/averageBy.js +++ /dev/null @@ -1,4 +0,0 @@ -const averageBy = (arr, fn) => - arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) / - arr.length; -module.exports = averageBy; diff --git a/test/bifurcate/bifurcate.test.js b/test/bifurcate.test.js similarity index 87% rename from test/bifurcate/bifurcate.test.js rename to test/bifurcate.test.js index 3f00f268e..ea615b714 100644 --- a/test/bifurcate/bifurcate.test.js +++ b/test/bifurcate.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const bifurcate = require('./bifurcate.js'); +const {bifurcate} = require('./_30s.js'); test('bifurcate is a Function', () => { expect(bifurcate).toBeInstanceOf(Function); diff --git a/test/bifurcate/bifurcate.js b/test/bifurcate/bifurcate.js deleted file mode 100644 index ca677ab8c..000000000 --- a/test/bifurcate/bifurcate.js +++ /dev/null @@ -1,3 +0,0 @@ -const bifurcate = (arr, filter) => - arr.reduce((acc, val, i) => (acc[filter[i] ? 0 : 1].push(val), acc), [[], []]); -module.exports = bifurcate; diff --git a/test/bifurcateBy/bifurcateBy.test.js b/test/bifurcateBy.test.js similarity index 86% rename from test/bifurcateBy/bifurcateBy.test.js rename to test/bifurcateBy.test.js index 19206aaa9..561062f21 100644 --- a/test/bifurcateBy/bifurcateBy.test.js +++ b/test/bifurcateBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const bifurcateBy = require('./bifurcateBy.js'); +const {bifurcateBy} = require('./_30s.js'); test('bifurcateBy is a Function', () => { expect(bifurcateBy).toBeInstanceOf(Function); diff --git a/test/bifurcateBy/bifurcateBy.js b/test/bifurcateBy/bifurcateBy.js deleted file mode 100644 index 0bb0abff5..000000000 --- a/test/bifurcateBy/bifurcateBy.js +++ /dev/null @@ -1,3 +0,0 @@ -const bifurcateBy = (arr, fn) => - arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [[], []]); -module.exports = bifurcateBy; diff --git a/test/binarySearch/binarySearch.test.js b/test/binarySearch.test.js similarity index 91% rename from test/binarySearch/binarySearch.test.js rename to test/binarySearch.test.js index a00680bb6..c2213e791 100644 --- a/test/binarySearch/binarySearch.test.js +++ b/test/binarySearch.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const binarySearch = require('./binarySearch.js'); +const {binarySearch} = require('./_30s.js'); test('binarySearch is a Function', () => { expect(binarySearch).toBeInstanceOf(Function); diff --git a/test/binarySearch/binarySearch.js b/test/binarySearch/binarySearch.js deleted file mode 100644 index 9dc64a9a2..000000000 --- a/test/binarySearch/binarySearch.js +++ /dev/null @@ -1,8 +0,0 @@ -const binarySearch = (arr, val, start = 0, end = arr.length - 1) => { - if (start > end) return -1; - const mid = Math.floor((start + end) / 2); - if (arr[mid] > val) return binarySearch(arr, val, start, mid - 1); - if (arr[mid] < val) return binarySearch(arr, val, mid + 1, end); - return mid; -}; -module.exports = binarySearch; diff --git a/test/bind/bind.test.js b/test/bind.test.js similarity index 91% rename from test/bind/bind.test.js rename to test/bind.test.js index 423b2b8d9..eee002b11 100644 --- a/test/bind/bind.test.js +++ b/test/bind.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const bind = require('./bind.js'); +const {bind} = require('./_30s.js'); test('bind is a Function', () => { expect(bind).toBeInstanceOf(Function); diff --git a/test/bind/bind.js b/test/bind/bind.js deleted file mode 100644 index e764a4cc2..000000000 --- a/test/bind/bind.js +++ /dev/null @@ -1,2 +0,0 @@ -const bind = (fn, context, ...boundArgs) => (...args) => fn.apply(context, [...boundArgs, ...args]); -module.exports = bind; diff --git a/test/bindAll/bindAll.test.js b/test/bindAll.test.js similarity index 89% rename from test/bindAll/bindAll.test.js rename to test/bindAll.test.js index dbbeda4a5..193225167 100644 --- a/test/bindAll/bindAll.test.js +++ b/test/bindAll.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const bindAll = require('./bindAll.js'); +const {bindAll} = require('./_30s.js'); test('bindAll is a Function', () => { expect(bindAll).toBeInstanceOf(Function); diff --git a/test/bindAll/bindAll.js b/test/bindAll/bindAll.js deleted file mode 100644 index c96fd973c..000000000 --- a/test/bindAll/bindAll.js +++ /dev/null @@ -1,10 +0,0 @@ -const bindAll = (obj, ...fns) => - fns.forEach( - fn => ( - (f = obj[fn]), - (obj[fn] = function() { - return f.apply(obj); - }) - ) - ); -module.exports = bindAll; diff --git a/test/bindKey/bindKey.test.js b/test/bindKey.test.js similarity index 90% rename from test/bindKey/bindKey.test.js rename to test/bindKey.test.js index cce1b4c98..cf1586955 100644 --- a/test/bindKey/bindKey.test.js +++ b/test/bindKey.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const bindKey = require('./bindKey.js'); +const {bindKey} = require('./_30s.js'); test('bindKey is a Function', () => { expect(bindKey).toBeInstanceOf(Function); diff --git a/test/bindKey/bindKey.js b/test/bindKey/bindKey.js deleted file mode 100644 index e9abf1eb6..000000000 --- a/test/bindKey/bindKey.js +++ /dev/null @@ -1,3 +0,0 @@ -const bindKey = (context, fn, ...boundArgs) => (...args) => - context[fn].apply(context, [...boundArgs, ...args]); -module.exports = bindKey; diff --git a/test/binomialCoefficient/binomialCoefficient.test.js b/test/binomialCoefficient.test.js similarity index 90% rename from test/binomialCoefficient/binomialCoefficient.test.js rename to test/binomialCoefficient.test.js index e4ca4f3ce..894c006bd 100644 --- a/test/binomialCoefficient/binomialCoefficient.test.js +++ b/test/binomialCoefficient.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const binomialCoefficient = require('./binomialCoefficient.js'); +const {binomialCoefficient} = require('./_30s.js'); test('binomialCoefficient is a Function', () => { expect(binomialCoefficient).toBeInstanceOf(Function); diff --git a/test/binomialCoefficient/binomialCoefficient.js b/test/binomialCoefficient/binomialCoefficient.js deleted file mode 100644 index cab25b72e..000000000 --- a/test/binomialCoefficient/binomialCoefficient.js +++ /dev/null @@ -1,11 +0,0 @@ -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); -}; -module.exports = binomialCoefficient; diff --git a/test/bottomVisible/bottomVisible.test.js b/test/bottomVisible.test.js similarity index 71% rename from test/bottomVisible/bottomVisible.test.js rename to test/bottomVisible.test.js index 6769b3cbd..591d985b0 100644 --- a/test/bottomVisible/bottomVisible.test.js +++ b/test/bottomVisible.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const bottomVisible = require('./bottomVisible.js'); +const {bottomVisible} = require('./_30s.js'); test('bottomVisible is a Function', () => { expect(bottomVisible).toBeInstanceOf(Function); diff --git a/test/bottomVisible/bottomVisible.js b/test/bottomVisible/bottomVisible.js deleted file mode 100644 index 3dc6e2fae..000000000 --- a/test/bottomVisible/bottomVisible.js +++ /dev/null @@ -1,4 +0,0 @@ -const bottomVisible = () => - document.documentElement.clientHeight + window.scrollY >= - (document.documentElement.scrollHeight || document.documentElement.clientHeight); -module.exports = bottomVisible; diff --git a/test/btoa/btoa.test.js b/test/btoa.test.js similarity index 85% rename from test/btoa/btoa.test.js rename to test/btoa.test.js index 36b740293..0ff0fd28e 100644 --- a/test/btoa/btoa.test.js +++ b/test/btoa.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const btoa = require('./btoa.js'); +const {btoa} = require('./_30s.js'); test('btoa is a Function', () => { expect(btoa).toBeInstanceOf(Function); diff --git a/test/btoa/btoa.js b/test/btoa/btoa.js deleted file mode 100644 index 7d2ae5545..000000000 --- a/test/btoa/btoa.js +++ /dev/null @@ -1,2 +0,0 @@ -const btoa = str => Buffer.from(str, 'binary').toString('base64'); -module.exports = btoa; diff --git a/test/byteSize/byteSize.test.js b/test/byteSize.test.js similarity index 100% rename from test/byteSize/byteSize.test.js rename to test/byteSize.test.js diff --git a/test/byteSize/byteSize.js b/test/byteSize/byteSize.js deleted file mode 100644 index 485e03833..000000000 --- a/test/byteSize/byteSize.js +++ /dev/null @@ -1,2 +0,0 @@ -const byteSize = str => new Blob([str]).size; -module.exports = byteSize; diff --git a/test/call/call.test.js b/test/call.test.js similarity index 86% rename from test/call/call.test.js rename to test/call.test.js index a90669ddf..710982b12 100644 --- a/test/call/call.test.js +++ b/test/call.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const call = require('./call.js'); +const {call} = require('./_30s.js'); test('call is a Function', () => { expect(call).toBeInstanceOf(Function); diff --git a/test/call/call.js b/test/call/call.js deleted file mode 100644 index 1a92c2273..000000000 --- a/test/call/call.js +++ /dev/null @@ -1,2 +0,0 @@ -const call = (key, ...args) => context => context[key](...args); -module.exports = call; diff --git a/test/capitalize/capitalize.test.js b/test/capitalize.test.js similarity index 91% rename from test/capitalize/capitalize.test.js rename to test/capitalize.test.js index 68fe363e7..d8120ccda 100644 --- a/test/capitalize/capitalize.test.js +++ b/test/capitalize.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const capitalize = require('./capitalize.js'); +const {capitalize} = require('./_30s.js'); test('capitalize is a Function', () => { expect(capitalize).toBeInstanceOf(Function); diff --git a/test/capitalize/capitalize.js b/test/capitalize/capitalize.js deleted file mode 100644 index e773adfb7..000000000 --- a/test/capitalize/capitalize.js +++ /dev/null @@ -1,3 +0,0 @@ -const capitalize = ([first, ...rest], lowerRest = false) => - first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join('')); -module.exports = capitalize; diff --git a/test/capitalizeEveryWord/capitalizeEveryWord.test.js b/test/capitalizeEveryWord.test.js similarity index 88% rename from test/capitalizeEveryWord/capitalizeEveryWord.test.js rename to test/capitalizeEveryWord.test.js index a57e2619d..34eb92fd5 100644 --- a/test/capitalizeEveryWord/capitalizeEveryWord.test.js +++ b/test/capitalizeEveryWord.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const capitalizeEveryWord = require('./capitalizeEveryWord.js'); +const {capitalizeEveryWord} = require('./_30s.js'); test('capitalizeEveryWord is a Function', () => { expect(capitalizeEveryWord).toBeInstanceOf(Function); diff --git a/test/capitalizeEveryWord/capitalizeEveryWord.js b/test/capitalizeEveryWord/capitalizeEveryWord.js deleted file mode 100644 index 1f8cfa1cb..000000000 --- a/test/capitalizeEveryWord/capitalizeEveryWord.js +++ /dev/null @@ -1,2 +0,0 @@ -const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase()); -module.exports = capitalizeEveryWord; diff --git a/test/castArray/castArray.test.js b/test/castArray.test.js similarity index 92% rename from test/castArray/castArray.test.js rename to test/castArray.test.js index 8aa60ce18..ad741671c 100644 --- a/test/castArray/castArray.test.js +++ b/test/castArray.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const castArray = require('./castArray.js'); +const {castArray} = require('./_30s.js'); test('castArray is a Function', () => { expect(castArray).toBeInstanceOf(Function); diff --git a/test/castArray/castArray.js b/test/castArray/castArray.js deleted file mode 100644 index 13cc5f469..000000000 --- a/test/castArray/castArray.js +++ /dev/null @@ -1,2 +0,0 @@ -const castArray = val => (Array.isArray(val) ? val : [val]); -module.exports = castArray; diff --git a/test/celsiusToFahrenheit/celsiusToFahrenheit.test.js b/test/celsiusToFahrenheit.test.js similarity index 90% rename from test/celsiusToFahrenheit/celsiusToFahrenheit.test.js rename to test/celsiusToFahrenheit.test.js index 42f02c969..5735745c2 100644 --- a/test/celsiusToFahrenheit/celsiusToFahrenheit.test.js +++ b/test/celsiusToFahrenheit.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const celsiusToFahrenheit = require('./celsiusToFahrenheit.js'); +const {celsiusToFahrenheit} = require('./_30s.js'); test('celsiusToFahrenheit is a Function', () => { expect(celsiusToFahrenheit).toBeInstanceOf(Function); diff --git a/test/celsiusToFahrenheit/celsiusToFahrenheit.js b/test/celsiusToFahrenheit/celsiusToFahrenheit.js deleted file mode 100644 index 1dd2e7b7d..000000000 --- a/test/celsiusToFahrenheit/celsiusToFahrenheit.js +++ /dev/null @@ -1,2 +0,0 @@ -const celsiusToFahrenheit = degrees => 1.8 * degrees + 32; -module.exports = celsiusToFahrenheit; diff --git a/test/chainAsync/chainAsync.test.js b/test/chainAsync.test.js similarity index 88% rename from test/chainAsync/chainAsync.test.js rename to test/chainAsync.test.js index 9d69ef316..ba640c625 100644 --- a/test/chainAsync/chainAsync.test.js +++ b/test/chainAsync.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const chainAsync = require('./chainAsync.js'); +const {chainAsync} = require('./_30s.js'); test('chainAsync is a Function', () => { expect(chainAsync).toBeInstanceOf(Function); diff --git a/test/chainAsync/chainAsync.js b/test/chainAsync/chainAsync.js deleted file mode 100644 index 447f56893..000000000 --- a/test/chainAsync/chainAsync.js +++ /dev/null @@ -1,6 +0,0 @@ -const chainAsync = fns => { - let curr = 0; - const next = () => fns[curr++](next); - next(); -}; -module.exports = chainAsync; diff --git a/test/chunk/chunk.test.js b/test/chunk.test.js similarity index 96% rename from test/chunk/chunk.test.js rename to test/chunk.test.js index 4025cf4ed..2acb7a405 100644 --- a/test/chunk/chunk.test.js +++ b/test/chunk.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const chunk = require('./chunk.js'); +const {chunk} = require('./_30s.js'); test('chunk is a Function', () => { expect(chunk).toBeInstanceOf(Function); diff --git a/test/chunk/chunk.js b/test/chunk/chunk.js deleted file mode 100644 index 20cc304aa..000000000 --- a/test/chunk/chunk.js +++ /dev/null @@ -1,5 +0,0 @@ -const chunk = (arr, size) => - Array.from({ length: Math.ceil(arr.length / size) }, (v, i) => - arr.slice(i * size, i * size + size) - ); -module.exports = chunk; diff --git a/test/clampNumber/clampNumber.test.js b/test/clampNumber.test.js similarity index 84% rename from test/clampNumber/clampNumber.test.js rename to test/clampNumber.test.js index 828e82a05..a89dfc84a 100644 --- a/test/clampNumber/clampNumber.test.js +++ b/test/clampNumber.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const clampNumber = require('./clampNumber.js'); +const {clampNumber} = require('./_30s.js'); test('clampNumber is a Function', () => { expect(clampNumber).toBeInstanceOf(Function); diff --git a/test/clampNumber/clampNumber.js b/test/clampNumber/clampNumber.js deleted file mode 100644 index b448e319a..000000000 --- a/test/clampNumber/clampNumber.js +++ /dev/null @@ -1,2 +0,0 @@ -const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b)); -module.exports = clampNumber; diff --git a/test/cleanObj/cleanObj.test.js b/test/cleanObj.test.js similarity index 89% rename from test/cleanObj/cleanObj.test.js rename to test/cleanObj.test.js index 0a9c81c6d..ce1d5025f 100644 --- a/test/cleanObj/cleanObj.test.js +++ b/test/cleanObj.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const cleanObj = require('./cleanObj.js'); +const {cleanObj} = require('./_30s.js'); test('cleanObj is a Function', () => { expect(cleanObj).toBeInstanceOf(Function); diff --git a/test/cleanObj/cleanObj.js b/test/cleanObj/cleanObj.js deleted file mode 100644 index 5ab9f69e3..000000000 --- a/test/cleanObj/cleanObj.js +++ /dev/null @@ -1,11 +0,0 @@ -const cleanObj = (obj, keysToKeep = [], childIndicator) => { - Object.keys(obj).forEach(key => { - if (key === childIndicator) { - cleanObj(obj[key], keysToKeep, childIndicator); - } else if (!keysToKeep.includes(key)) { - delete obj[key]; - } - }); - return obj; -}; -module.exports = cleanObj; diff --git a/test/cloneRegExp/cloneRegExp.test.js b/test/cloneRegExp.test.js similarity index 83% rename from test/cloneRegExp/cloneRegExp.test.js rename to test/cloneRegExp.test.js index d16147c7a..1ad340a22 100644 --- a/test/cloneRegExp/cloneRegExp.test.js +++ b/test/cloneRegExp.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const cloneRegExp = require('./cloneRegExp.js'); +const {cloneRegExp} = require('./_30s.js'); test('cloneRegExp is a Function', () => { expect(cloneRegExp).toBeInstanceOf(Function); diff --git a/test/cloneRegExp/cloneRegExp.js b/test/cloneRegExp/cloneRegExp.js deleted file mode 100644 index e78c57bbe..000000000 --- a/test/cloneRegExp/cloneRegExp.js +++ /dev/null @@ -1,2 +0,0 @@ -const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags); -module.exports = cloneRegExp; diff --git a/test/coalesce/coalesce.test.js b/test/coalesce.test.js similarity index 85% rename from test/coalesce/coalesce.test.js rename to test/coalesce.test.js index 05a6a93c0..d10b812e1 100644 --- a/test/coalesce/coalesce.test.js +++ b/test/coalesce.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const coalesce = require('./coalesce.js'); +const {coalesce} = require('./_30s.js'); test('coalesce is a Function', () => { expect(coalesce).toBeInstanceOf(Function); diff --git a/test/coalesce/coalesce.js b/test/coalesce/coalesce.js deleted file mode 100644 index 8b94084f2..000000000 --- a/test/coalesce/coalesce.js +++ /dev/null @@ -1,2 +0,0 @@ -const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_)); -module.exports = coalesce; diff --git a/test/coalesceFactory/coalesceFactory.test.js b/test/coalesceFactory.test.js similarity index 86% rename from test/coalesceFactory/coalesceFactory.test.js rename to test/coalesceFactory.test.js index a2836a57f..960cb1673 100644 --- a/test/coalesceFactory/coalesceFactory.test.js +++ b/test/coalesceFactory.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const coalesceFactory = require('./coalesceFactory.js'); +const {coalesceFactory} = require('./_30s.js'); test('coalesceFactory is a Function', () => { expect(coalesceFactory).toBeInstanceOf(Function); diff --git a/test/coalesceFactory/coalesceFactory.js b/test/coalesceFactory/coalesceFactory.js deleted file mode 100644 index 66fd5148e..000000000 --- a/test/coalesceFactory/coalesceFactory.js +++ /dev/null @@ -1,2 +0,0 @@ -const coalesceFactory = valid => (...args) => args.find(valid); -module.exports = coalesceFactory; diff --git a/test/collatz/collatz.test.js b/test/collatz.test.js similarity index 91% rename from test/collatz/collatz.test.js rename to test/collatz.test.js index 73ceb7886..6bbe6205a 100644 --- a/test/collatz/collatz.test.js +++ b/test/collatz.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const collatz = require('./collatz.js'); +const {collatz} = require('./_30s.js'); test('collatz is a Function', () => { expect(collatz).toBeInstanceOf(Function); diff --git a/test/collatz/collatz.js b/test/collatz/collatz.js deleted file mode 100644 index fb2c8205e..000000000 --- a/test/collatz/collatz.js +++ /dev/null @@ -1,2 +0,0 @@ -const collatz = n => (n % 2 === 0 ? n / 2 : 3 * n + 1); -module.exports = collatz; diff --git a/test/collectInto/collectInto.test.js b/test/collectInto.test.js similarity index 90% rename from test/collectInto/collectInto.test.js rename to test/collectInto.test.js index a672e4515..a99890db9 100644 --- a/test/collectInto/collectInto.test.js +++ b/test/collectInto.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const collectInto = require('./collectInto.js'); +const {collectInto} = require('./_30s.js'); test('collectInto is a Function', () => { expect(collectInto).toBeInstanceOf(Function); diff --git a/test/collectInto/collectInto.js b/test/collectInto/collectInto.js deleted file mode 100644 index e891c6938..000000000 --- a/test/collectInto/collectInto.js +++ /dev/null @@ -1,2 +0,0 @@ -const collectInto = fn => (...args) => fn(args); -module.exports = collectInto; diff --git a/test/colorize/colorize.test.js b/test/colorize.test.js similarity index 74% rename from test/colorize/colorize.test.js rename to test/colorize.test.js index 73658ae79..8e147ef2e 100644 --- a/test/colorize/colorize.test.js +++ b/test/colorize.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const colorize = require('./colorize.js'); +const {colorize} = require('./_30s.js'); test('colorize is a Function', () => { expect(colorize).toBeInstanceOf(Function); diff --git a/test/colorize/colorize.js b/test/colorize/colorize.js deleted file mode 100644 index 032e6ab87..000000000 --- a/test/colorize/colorize.js +++ /dev/null @@ -1,19 +0,0 @@ -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` -}); -module.exports = colorize; diff --git a/test/compact/compact.test.js b/test/compact.test.js similarity index 88% rename from test/compact/compact.test.js rename to test/compact.test.js index 213bfa10c..e63c47b8e 100644 --- a/test/compact/compact.test.js +++ b/test/compact.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const compact = require('./compact.js'); +const {compact} = require('./_30s.js'); test('compact is a Function', () => { expect(compact).toBeInstanceOf(Function); diff --git a/test/compact/compact.js b/test/compact/compact.js deleted file mode 100644 index 636f804f2..000000000 --- a/test/compact/compact.js +++ /dev/null @@ -1,2 +0,0 @@ -const compact = arr => arr.filter(Boolean); -module.exports = compact; diff --git a/test/compose/compose.test.js b/test/compose.test.js similarity index 89% rename from test/compose/compose.test.js rename to test/compose.test.js index 33813a409..4d3119767 100644 --- a/test/compose/compose.test.js +++ b/test/compose.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const compose = require('./compose.js'); +const {compose} = require('./_30s.js'); test('compose is a Function', () => { expect(compose).toBeInstanceOf(Function); diff --git a/test/compose/compose.js b/test/compose/compose.js deleted file mode 100644 index 2d62bdd23..000000000 --- a/test/compose/compose.js +++ /dev/null @@ -1,2 +0,0 @@ -const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); -module.exports = compose; diff --git a/test/composeRight/composeRight.test.js b/test/composeRight.test.js similarity index 86% rename from test/composeRight/composeRight.test.js rename to test/composeRight.test.js index 02cddf187..92ec50047 100644 --- a/test/composeRight/composeRight.test.js +++ b/test/composeRight.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const composeRight = require('./composeRight.js'); +const {composeRight} = require('./_30s.js'); test('composeRight is a Function', () => { expect(composeRight).toBeInstanceOf(Function); diff --git a/test/composeRight/composeRight.js b/test/composeRight/composeRight.js deleted file mode 100644 index a0ac57749..000000000 --- a/test/composeRight/composeRight.js +++ /dev/null @@ -1,2 +0,0 @@ -const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); -module.exports = composeRight; diff --git a/test/converge/converge.test.js b/test/converge.test.js similarity index 92% rename from test/converge/converge.test.js rename to test/converge.test.js index 19e2b57f0..f2d6a3810 100644 --- a/test/converge/converge.test.js +++ b/test/converge.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const converge = require('./converge.js'); +const {converge} = require('./_30s.js'); test('converge is a Function', () => { expect(converge).toBeInstanceOf(Function); diff --git a/test/converge/converge.js b/test/converge/converge.js deleted file mode 100644 index 8dd708846..000000000 --- a/test/converge/converge.js +++ /dev/null @@ -1,2 +0,0 @@ -const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn.apply(null, args))); -module.exports = converge; diff --git a/test/copyToClipboard/copyToClipboard.test.js b/test/copyToClipboard.test.js similarity index 70% rename from test/copyToClipboard/copyToClipboard.test.js rename to test/copyToClipboard.test.js index 60c18bbb9..27bbd402e 100644 --- a/test/copyToClipboard/copyToClipboard.test.js +++ b/test/copyToClipboard.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const copyToClipboard = require('./copyToClipboard.js'); +const {copyToClipboard} = require('./_30s.js'); test('copyToClipboard is a Function', () => { expect(copyToClipboard).toBeInstanceOf(Function); diff --git a/test/copyToClipboard/copyToClipboard.js b/test/copyToClipboard/copyToClipboard.js deleted file mode 100644 index d1117d729..000000000 --- a/test/copyToClipboard/copyToClipboard.js +++ /dev/null @@ -1,18 +0,0 @@ -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); - } -}; -module.exports = copyToClipboard; diff --git a/test/countBy/countBy.test.js b/test/countBy.test.js similarity index 89% rename from test/countBy/countBy.test.js rename to test/countBy.test.js index 1f0c6efee..265034da0 100644 --- a/test/countBy/countBy.test.js +++ b/test/countBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const countBy = require('./countBy.js'); +const {countBy} = require('./_30s.js'); test('countBy is a Function', () => { expect(countBy).toBeInstanceOf(Function); diff --git a/test/countBy/countBy.js b/test/countBy/countBy.js deleted file mode 100644 index 83f16c1b7..000000000 --- a/test/countBy/countBy.js +++ /dev/null @@ -1,6 +0,0 @@ -const countBy = (arr, fn) => - arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => { - acc[val] = (acc[val] || 0) + 1; - return acc; - }, {}); -module.exports = countBy; diff --git a/test/countOccurrences/countOccurrences.test.js b/test/countOccurrences.test.js similarity index 81% rename from test/countOccurrences/countOccurrences.test.js rename to test/countOccurrences.test.js index a78b8b539..5ac6c1e1d 100644 --- a/test/countOccurrences/countOccurrences.test.js +++ b/test/countOccurrences.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const countOccurrences = require('./countOccurrences.js'); +const {countOccurrences} = require('./_30s.js'); test('countOccurrences is a Function', () => { expect(countOccurrences).toBeInstanceOf(Function); diff --git a/test/countOccurrences/countOccurrences.js b/test/countOccurrences/countOccurrences.js deleted file mode 100644 index 2de3440fd..000000000 --- a/test/countOccurrences/countOccurrences.js +++ /dev/null @@ -1,2 +0,0 @@ -const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0); -module.exports = countOccurrences; diff --git a/test/countVowels/countVowels.test.js b/test/countVowels.test.js similarity index 72% rename from test/countVowels/countVowels.test.js rename to test/countVowels.test.js index 64a1b0936..1b543bb8e 100644 --- a/test/countVowels/countVowels.test.js +++ b/test/countVowels.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const countVowels = require('./countVowels.js'); +const {countVowels} = require('./_30s.js'); test('countVowels is a Function', () => { expect(countVowels).toBeInstanceOf(Function); diff --git a/test/countVowels/countVowels.js b/test/countVowels/countVowels.js deleted file mode 100644 index 29c954056..000000000 --- a/test/countVowels/countVowels.js +++ /dev/null @@ -1,2 +0,0 @@ -const countVowels = str => (str.match(/[aeiou]/gi) || []).length; -module.exports = countVowels; diff --git a/test/counter/counter.test.js b/test/counter.test.js similarity index 74% rename from test/counter/counter.test.js rename to test/counter.test.js index a80d9c0f8..b6cc1648c 100644 --- a/test/counter/counter.test.js +++ b/test/counter.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const counter = require('./counter.js'); +const {counter} = require('./_30s.js'); test('counter is a Function', () => { expect(counter).toBeInstanceOf(Function); diff --git a/test/counter/counter.js b/test/counter/counter.js deleted file mode 100644 index 514551a0e..000000000 --- a/test/counter/counter.js +++ /dev/null @@ -1,12 +0,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; -}; -module.exports = counter; diff --git a/test/createElement/createElement.test.js b/test/createElement.test.js similarity index 71% rename from test/createElement/createElement.test.js rename to test/createElement.test.js index 096080d8d..8c253138f 100644 --- a/test/createElement/createElement.test.js +++ b/test/createElement.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const createElement = require('./createElement.js'); +const {createElement} = require('./_30s.js'); test('createElement is a Function', () => { expect(createElement).toBeInstanceOf(Function); diff --git a/test/createElement/createElement.js b/test/createElement/createElement.js deleted file mode 100644 index 533dd8012..000000000 --- a/test/createElement/createElement.js +++ /dev/null @@ -1,6 +0,0 @@ -const createElement = str => { - const el = document.createElement('div'); - el.innerHTML = str; - return el.firstElementChild; -}; -module.exports = createElement; diff --git a/test/createEventHub/createEventHub.test.js b/test/createEventHub.test.js similarity index 71% rename from test/createEventHub/createEventHub.test.js rename to test/createEventHub.test.js index 701572373..ca6ed2088 100644 --- a/test/createEventHub/createEventHub.test.js +++ b/test/createEventHub.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const createEventHub = require('./createEventHub.js'); +const {createEventHub} = require('./_30s.js'); test('createEventHub is a Function', () => { expect(createEventHub).toBeInstanceOf(Function); diff --git a/test/createEventHub/createEventHub.js b/test/createEventHub/createEventHub.js deleted file mode 100644 index a1ebc9a19..000000000 --- a/test/createEventHub/createEventHub.js +++ /dev/null @@ -1,15 +0,0 @@ -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); - } -}); -module.exports = createEventHub; diff --git a/test/currentURL/currentURL.test.js b/test/currentURL.test.js similarity index 72% rename from test/currentURL/currentURL.test.js rename to test/currentURL.test.js index 779470bde..8aa22f088 100644 --- a/test/currentURL/currentURL.test.js +++ b/test/currentURL.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const currentURL = require('./currentURL.js'); +const {currentURL} = require('./_30s.js'); test('currentURL is a Function', () => { expect(currentURL).toBeInstanceOf(Function); diff --git a/test/currentURL/currentURL.js b/test/currentURL/currentURL.js deleted file mode 100644 index a703769dd..000000000 --- a/test/currentURL/currentURL.js +++ /dev/null @@ -1,2 +0,0 @@ -const currentURL = () => window.location.href; -module.exports = currentURL; diff --git a/test/curry/curry.test.js b/test/curry.test.js similarity index 88% rename from test/curry/curry.test.js rename to test/curry.test.js index 9ae220a35..9fedae9da 100644 --- a/test/curry/curry.test.js +++ b/test/curry.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const curry = require('./curry.js'); +const {curry} = require('./_30s.js'); test('curry is a Function', () => { expect(curry).toBeInstanceOf(Function); diff --git a/test/curry/curry.js b/test/curry/curry.js deleted file mode 100644 index f6a788d90..000000000 --- a/test/curry/curry.js +++ /dev/null @@ -1,3 +0,0 @@ -const curry = (fn, arity = fn.length, ...args) => - arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args); -module.exports = curry; diff --git a/test/dayOfYear/dayOfYear.test.js b/test/dayOfYear.test.js similarity index 73% rename from test/dayOfYear/dayOfYear.test.js rename to test/dayOfYear.test.js index 2df870a58..b353d0106 100644 --- a/test/dayOfYear/dayOfYear.test.js +++ b/test/dayOfYear.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const dayOfYear = require('./dayOfYear.js'); +const {dayOfYear} = require('./_30s.js'); test('dayOfYear is a Function', () => { expect(dayOfYear).toBeInstanceOf(Function); diff --git a/test/dayOfYear/dayOfYear.js b/test/dayOfYear/dayOfYear.js deleted file mode 100644 index 8c6042edf..000000000 --- a/test/dayOfYear/dayOfYear.js +++ /dev/null @@ -1,3 +0,0 @@ -const dayOfYear = date => - Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24); -module.exports = dayOfYear; diff --git a/test/debounce/debounce.test.js b/test/debounce.test.js similarity index 83% rename from test/debounce/debounce.test.js rename to test/debounce.test.js index e26209900..67aac32f3 100644 --- a/test/debounce/debounce.test.js +++ b/test/debounce.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const debounce = require('./debounce.js'); +const {debounce} = require('./_30s.js'); test('debounce is a Function', () => { expect(debounce).toBeInstanceOf(Function); diff --git a/test/debounce/debounce.js b/test/debounce/debounce.js deleted file mode 100644 index 313428d57..000000000 --- a/test/debounce/debounce.js +++ /dev/null @@ -1,8 +0,0 @@ -const debounce = (fn, ms = 0) => { - let timeoutId; - return function(...args) { - clearTimeout(timeoutId); - timeoutId = setTimeout(() => fn.apply(this, args), ms); - }; -}; -module.exports = debounce; diff --git a/test/decapitalize/decapitalize.test.js b/test/decapitalize.test.js similarity index 87% rename from test/decapitalize/decapitalize.test.js rename to test/decapitalize.test.js index 14ca0fa7a..30783ab14 100644 --- a/test/decapitalize/decapitalize.test.js +++ b/test/decapitalize.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const decapitalize = require('./decapitalize.js'); +const {decapitalize} = require('./_30s.js'); test('decapitalize is a Function', () => { expect(decapitalize).toBeInstanceOf(Function); diff --git a/test/decapitalize/decapitalize.js b/test/decapitalize/decapitalize.js deleted file mode 100644 index 987929c01..000000000 --- a/test/decapitalize/decapitalize.js +++ /dev/null @@ -1,3 +0,0 @@ -const decapitalize = ([first, ...rest], upperRest = false) => - first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join('')); -module.exports = decapitalize; diff --git a/test/deepClone/deepClone.test.js b/test/deepClone.test.js similarity index 92% rename from test/deepClone/deepClone.test.js rename to test/deepClone.test.js index 6983de5fc..9e73c19d1 100644 --- a/test/deepClone/deepClone.test.js +++ b/test/deepClone.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const deepClone = require('./deepClone.js'); +const {deepClone} = require('./_30s.js'); test('deepClone is a Function', () => { expect(deepClone).toBeInstanceOf(Function); diff --git a/test/deepClone/deepClone.js b/test/deepClone/deepClone.js deleted file mode 100644 index 538f37d3d..000000000 --- a/test/deepClone/deepClone.js +++ /dev/null @@ -1,8 +0,0 @@ -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; -}; -module.exports = deepClone; diff --git a/test/deepFlatten/deepFlatten.test.js b/test/deepFlatten.test.js similarity index 83% rename from test/deepFlatten/deepFlatten.test.js rename to test/deepFlatten.test.js index 6489d26ab..a99b67c4b 100644 --- a/test/deepFlatten/deepFlatten.test.js +++ b/test/deepFlatten.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const deepFlatten = require('./deepFlatten.js'); +const {deepFlatten} = require('./_30s.js'); test('deepFlatten is a Function', () => { expect(deepFlatten).toBeInstanceOf(Function); diff --git a/test/deepFlatten/deepFlatten.js b/test/deepFlatten/deepFlatten.js deleted file mode 100644 index 6d344be80..000000000 --- a/test/deepFlatten/deepFlatten.js +++ /dev/null @@ -1,2 +0,0 @@ -const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v))); -module.exports = deepFlatten; diff --git a/test/deepFreeze/deepFreeze.test.js b/test/deepFreeze.test.js similarity index 93% rename from test/deepFreeze/deepFreeze.test.js rename to test/deepFreeze.test.js index 12097d525..3a95c7049 100644 --- a/test/deepFreeze/deepFreeze.test.js +++ b/test/deepFreeze.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const deepFreeze = require('./deepFreeze.js'); +const {deepFreeze} = require('./_30s.js'); test('deepFreeze is a Function', () => { expect(deepFreeze).toBeInstanceOf(Function); diff --git a/test/deepFreeze/deepFreeze.js b/test/deepFreeze/deepFreeze.js deleted file mode 100644 index 9d6447812..000000000 --- a/test/deepFreeze/deepFreeze.js +++ /dev/null @@ -1,6 +0,0 @@ -const deepFreeze = obj => - Object.keys(obj).forEach( - prop => - !(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop]) - ) || Object.freeze(obj); -module.exports = deepFreeze; diff --git a/test/defaults/defaults.test.js b/test/defaults.test.js similarity index 86% rename from test/defaults/defaults.test.js rename to test/defaults.test.js index 6a98064cd..6d7de0f2a 100644 --- a/test/defaults/defaults.test.js +++ b/test/defaults.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const defaults = require('./defaults.js'); +const {defaults} = require('./_30s.js'); test('defaults is a Function', () => { expect(defaults).toBeInstanceOf(Function); diff --git a/test/defaults/defaults.js b/test/defaults/defaults.js deleted file mode 100644 index e369fff7c..000000000 --- a/test/defaults/defaults.js +++ /dev/null @@ -1,2 +0,0 @@ -const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj); -module.exports = defaults; diff --git a/test/defer/defer.test.js b/test/defer.test.js similarity index 75% rename from test/defer/defer.test.js rename to test/defer.test.js index 61f3665f1..f27d98e1d 100644 --- a/test/defer/defer.test.js +++ b/test/defer.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const defer = require('./defer.js'); +const {defer} = require('./_30s.js'); test('defer is a Function', () => { expect(defer).toBeInstanceOf(Function); diff --git a/test/defer/defer.js b/test/defer/defer.js deleted file mode 100644 index f8e069b65..000000000 --- a/test/defer/defer.js +++ /dev/null @@ -1,2 +0,0 @@ -const defer = (fn, ...args) => setTimeout(fn, 1, ...args); -module.exports = defer; diff --git a/test/degreesToRads/degreesToRads.test.js b/test/degreesToRads.test.js similarity index 85% rename from test/degreesToRads/degreesToRads.test.js rename to test/degreesToRads.test.js index 634140d76..a1827c426 100644 --- a/test/degreesToRads/degreesToRads.test.js +++ b/test/degreesToRads.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const degreesToRads = require('./degreesToRads.js'); +const {degreesToRads} = require('./_30s.js'); // const approxeq = (v1,v2, diff = 0.001) => Math.abs(v1 - v2) < diff; test('degreesToRads is a Function', () => { diff --git a/test/degreesToRads/degreesToRads.js b/test/degreesToRads/degreesToRads.js deleted file mode 100644 index ffc04f7fd..000000000 --- a/test/degreesToRads/degreesToRads.js +++ /dev/null @@ -1,2 +0,0 @@ -const degreesToRads = deg => (deg * Math.PI) / 180.0; -module.exports = degreesToRads; diff --git a/test/delay/delay.test.js b/test/delay.test.js similarity index 88% rename from test/delay/delay.test.js rename to test/delay.test.js index b43e12552..e06326766 100644 --- a/test/delay/delay.test.js +++ b/test/delay.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const delay = require('./delay.js'); +const {delay} = require('./_30s.js'); test('delay is a Function', () => { expect(delay).toBeInstanceOf(Function); diff --git a/test/delay/delay.js b/test/delay/delay.js deleted file mode 100644 index a05563960..000000000 --- a/test/delay/delay.js +++ /dev/null @@ -1,2 +0,0 @@ -const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args); -module.exports = delay; diff --git a/test/detectDeviceType/detectDeviceType.test.js b/test/detectDeviceType.test.js similarity index 70% rename from test/detectDeviceType/detectDeviceType.test.js rename to test/detectDeviceType.test.js index 695593771..943864b0c 100644 --- a/test/detectDeviceType/detectDeviceType.test.js +++ b/test/detectDeviceType.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const detectDeviceType = require('./detectDeviceType.js'); +const {detectDeviceType} = require('./_30s.js'); test('detectDeviceType is a Function', () => { expect(detectDeviceType).toBeInstanceOf(Function); diff --git a/test/detectDeviceType/detectDeviceType.js b/test/detectDeviceType/detectDeviceType.js deleted file mode 100644 index 2cb23d550..000000000 --- a/test/detectDeviceType/detectDeviceType.js +++ /dev/null @@ -1,5 +0,0 @@ -const detectDeviceType = () => - /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) - ? 'Mobile' - : 'Desktop'; -module.exports = detectDeviceType; diff --git a/test/difference/difference.test.js b/test/difference.test.js similarity index 83% rename from test/difference/difference.test.js rename to test/difference.test.js index 4d0f316f0..564713181 100644 --- a/test/difference/difference.test.js +++ b/test/difference.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const difference = require('./difference.js'); +const {difference} = require('./_30s.js'); test('difference is a Function', () => { expect(difference).toBeInstanceOf(Function); diff --git a/test/difference/difference.js b/test/difference/difference.js deleted file mode 100644 index 186ee847d..000000000 --- a/test/difference/difference.js +++ /dev/null @@ -1,5 +0,0 @@ -const difference = (a, b) => { - const s = new Set(b); - return a.filter(x => !s.has(x)); -}; -module.exports = difference; diff --git a/test/differenceBy/differenceBy.test.js b/test/differenceBy.test.js similarity index 89% rename from test/differenceBy/differenceBy.test.js rename to test/differenceBy.test.js index cb3499833..719f0df6b 100644 --- a/test/differenceBy/differenceBy.test.js +++ b/test/differenceBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const differenceBy = require('./differenceBy.js'); +const {differenceBy} = require('./_30s.js'); test('differenceBy is a Function', () => { expect(differenceBy).toBeInstanceOf(Function); diff --git a/test/differenceBy/differenceBy.js b/test/differenceBy/differenceBy.js deleted file mode 100644 index 30f251e50..000000000 --- a/test/differenceBy/differenceBy.js +++ /dev/null @@ -1,5 +0,0 @@ -const differenceBy = (a, b, fn) => { - const s = new Set(b.map(fn)); - return a.filter(x => !s.has(fn(x))); -}; -module.exports = differenceBy; diff --git a/test/differenceWith/differenceWith.test.js b/test/differenceWith.test.js similarity index 85% rename from test/differenceWith/differenceWith.test.js rename to test/differenceWith.test.js index 14b4dcff3..f2b608afd 100644 --- a/test/differenceWith/differenceWith.test.js +++ b/test/differenceWith.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const differenceWith = require('./differenceWith.js'); +const {differenceWith} = require('./_30s.js'); test('differenceWith is a Function', () => { expect(differenceWith).toBeInstanceOf(Function); diff --git a/test/differenceWith/differenceWith.js b/test/differenceWith/differenceWith.js deleted file mode 100644 index bb4c127a0..000000000 --- a/test/differenceWith/differenceWith.js +++ /dev/null @@ -1,2 +0,0 @@ -const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1); -module.exports = differenceWith; diff --git a/test/dig/dig.test.js b/test/dig.test.js similarity index 94% rename from test/dig/dig.test.js rename to test/dig.test.js index d47d0edf7..8af2e3cc3 100644 --- a/test/dig/dig.test.js +++ b/test/dig.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const dig = require('./dig.js'); +const {dig} = require('./_30s.js'); const data = { level1: { diff --git a/test/dig/dig.js b/test/dig/dig.js deleted file mode 100644 index 3b9d33393..000000000 --- a/test/dig/dig.js +++ /dev/null @@ -1,8 +0,0 @@ -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); -module.exports = dig; diff --git a/test/digitize/digitize.test.js b/test/digitize.test.js similarity index 84% rename from test/digitize/digitize.test.js rename to test/digitize.test.js index 2feb29282..1f197322e 100644 --- a/test/digitize/digitize.test.js +++ b/test/digitize.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const digitize = require('./digitize.js'); +const {digitize} = require('./_30s.js'); test('digitize is a Function', () => { expect(digitize).toBeInstanceOf(Function); diff --git a/test/digitize/digitize.js b/test/digitize/digitize.js deleted file mode 100644 index 6b85884be..000000000 --- a/test/digitize/digitize.js +++ /dev/null @@ -1,2 +0,0 @@ -const digitize = n => [...`${n}`].map(i => parseInt(i)); -module.exports = digitize; diff --git a/test/distance/distance.test.js b/test/distance.test.js similarity index 85% rename from test/distance/distance.test.js rename to test/distance.test.js index 7831be85d..f636df601 100644 --- a/test/distance/distance.test.js +++ b/test/distance.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const distance = require('./distance.js'); +const {distance} = require('./_30s.js'); test('distance is a Function', () => { expect(distance).toBeInstanceOf(Function); diff --git a/test/distance/distance.js b/test/distance/distance.js deleted file mode 100644 index 2c5735858..000000000 --- a/test/distance/distance.js +++ /dev/null @@ -1,2 +0,0 @@ -const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); -module.exports = distance; diff --git a/test/drop/drop.test.js b/test/drop.test.js similarity index 92% rename from test/drop/drop.test.js rename to test/drop.test.js index 87afd1070..7a08170b7 100644 --- a/test/drop/drop.test.js +++ b/test/drop.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const drop = require('./drop.js'); +const {drop} = require('./_30s.js'); test('drop is a Function', () => { expect(drop).toBeInstanceOf(Function); diff --git a/test/drop/drop.js b/test/drop/drop.js deleted file mode 100644 index bc2c9b76b..000000000 --- a/test/drop/drop.js +++ /dev/null @@ -1,2 +0,0 @@ -const drop = (arr, n = 1) => arr.slice(n); -module.exports = drop; diff --git a/test/dropRight/dropRight.test.js b/test/dropRight.test.js similarity index 91% rename from test/dropRight/dropRight.test.js rename to test/dropRight.test.js index 5f36ec265..95a574f75 100644 --- a/test/dropRight/dropRight.test.js +++ b/test/dropRight.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const dropRight = require('./dropRight.js'); +const {dropRight} = require('./_30s.js'); test('dropRight is a Function', () => { expect(dropRight).toBeInstanceOf(Function); diff --git a/test/dropRight/dropRight.js b/test/dropRight/dropRight.js deleted file mode 100644 index 635c86880..000000000 --- a/test/dropRight/dropRight.js +++ /dev/null @@ -1,2 +0,0 @@ -const dropRight = (arr, n = 1) => arr.slice(0, -n); -module.exports = dropRight; diff --git a/test/dropRightWhile/dropRightWhile.test.js b/test/dropRightWhile.test.js similarity index 84% rename from test/dropRightWhile/dropRightWhile.test.js rename to test/dropRightWhile.test.js index 76cf162d9..24ea544d7 100644 --- a/test/dropRightWhile/dropRightWhile.test.js +++ b/test/dropRightWhile.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const dropRightWhile = require('./dropRightWhile.js'); +const {dropRightWhile} = require('./_30s.js'); test('dropRightWhile is a Function', () => { expect(dropRightWhile).toBeInstanceOf(Function); diff --git a/test/dropRightWhile/dropRightWhile.js b/test/dropRightWhile/dropRightWhile.js deleted file mode 100644 index 35a373c08..000000000 --- a/test/dropRightWhile/dropRightWhile.js +++ /dev/null @@ -1,5 +0,0 @@ -const dropRightWhile = (arr, func) => { - while (arr.length > 0 && !func(arr[arr.length - 1])) arr = arr.slice(0, -1); - return arr; -}; -module.exports = dropRightWhile; diff --git a/test/dropWhile/dropWhile.test.js b/test/dropWhile.test.js similarity index 86% rename from test/dropWhile/dropWhile.test.js rename to test/dropWhile.test.js index 40c0f0987..88373d34f 100644 --- a/test/dropWhile/dropWhile.test.js +++ b/test/dropWhile.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const dropWhile = require('./dropWhile.js'); +const {dropWhile} = require('./_30s.js'); test('dropWhile is a Function', () => { expect(dropWhile).toBeInstanceOf(Function); diff --git a/test/dropWhile/dropWhile.js b/test/dropWhile/dropWhile.js deleted file mode 100644 index bcb01ebc0..000000000 --- a/test/dropWhile/dropWhile.js +++ /dev/null @@ -1,5 +0,0 @@ -const dropWhile = (arr, func) => { - while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1); - return arr; -}; -module.exports = dropWhile; diff --git a/test/elementContains/elementContains.test.js b/test/elementContains.test.js similarity index 70% rename from test/elementContains/elementContains.test.js rename to test/elementContains.test.js index ef9019c76..2a46c2d49 100644 --- a/test/elementContains/elementContains.test.js +++ b/test/elementContains.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const elementContains = require('./elementContains.js'); +const {elementContains} = require('./_30s.js'); test('elementContains is a Function', () => { expect(elementContains).toBeInstanceOf(Function); diff --git a/test/elementContains/elementContains.js b/test/elementContains/elementContains.js deleted file mode 100644 index d80f015fa..000000000 --- a/test/elementContains/elementContains.js +++ /dev/null @@ -1,2 +0,0 @@ -const elementContains = (parent, child) => parent !== child && parent.contains(child); -module.exports = elementContains; diff --git a/test/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js b/test/elementIsVisibleInViewport.test.js similarity index 66% rename from test/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js rename to test/elementIsVisibleInViewport.test.js index f3d70a2fd..68f0fa1d2 100644 --- a/test/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js +++ b/test/elementIsVisibleInViewport.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const elementIsVisibleInViewport = require('./elementIsVisibleInViewport.js'); +const {elementIsVisibleInViewport} = require('./_30s.js'); test('elementIsVisibleInViewport is a Function', () => { expect(elementIsVisibleInViewport).toBeInstanceOf(Function); diff --git a/test/elementIsVisibleInViewport/elementIsVisibleInViewport.js b/test/elementIsVisibleInViewport/elementIsVisibleInViewport.js deleted file mode 100644 index f695904eb..000000000 --- a/test/elementIsVisibleInViewport/elementIsVisibleInViewport.js +++ /dev/null @@ -1,9 +0,0 @@ -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; -}; -module.exports = elementIsVisibleInViewport; diff --git a/test/elo/elo.test.js b/test/elo.test.js similarity index 92% rename from test/elo/elo.test.js rename to test/elo.test.js index 042dad3d4..7210d3ebf 100644 --- a/test/elo/elo.test.js +++ b/test/elo.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const elo = require('./elo.js'); +const {elo} = require('./_30s.js'); test('elo is a Function', () => { expect(elo).toBeInstanceOf(Function); diff --git a/test/elo/elo.js b/test/elo/elo.js deleted file mode 100644 index 4ea215191..000000000 --- a/test/elo/elo.js +++ /dev/null @@ -1,18 +0,0 @@ -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; -}; -module.exports = elo; diff --git a/test/equals/equals.test.js b/test/equals.test.js similarity index 95% rename from test/equals/equals.test.js rename to test/equals.test.js index 2f89886ec..dd3c64056 100644 --- a/test/equals/equals.test.js +++ b/test/equals.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const equals = require('./equals.js'); +const {equals} = require('./_30s.js'); test('equals is a Function', () => { expect(equals).toBeInstanceOf(Function); diff --git a/test/equals/equals.js b/test/equals/equals.js deleted file mode 100644 index 1d3665f5d..000000000 --- a/test/equals/equals.js +++ /dev/null @@ -1,11 +0,0 @@ -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])); -}; -module.exports = equals; diff --git a/test/escapeHTML/escapeHTML.test.js b/test/escapeHTML.test.js similarity index 86% rename from test/escapeHTML/escapeHTML.test.js rename to test/escapeHTML.test.js index e824acf9b..c7cd266ab 100644 --- a/test/escapeHTML/escapeHTML.test.js +++ b/test/escapeHTML.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const escapeHTML = require('./escapeHTML.js'); +const {escapeHTML} = require('./_30s.js'); test('escapeHTML is a Function', () => { expect(escapeHTML).toBeInstanceOf(Function); diff --git a/test/escapeHTML/escapeHTML.js b/test/escapeHTML/escapeHTML.js deleted file mode 100644 index d8c219fbc..000000000 --- a/test/escapeHTML/escapeHTML.js +++ /dev/null @@ -1,13 +0,0 @@ -const escapeHTML = str => - str.replace( - /[&<>'"]/g, - tag => - ({ - '&': '&', - '<': '<', - '>': '>', - "'": ''', - '"': '"' - }[tag] || tag) - ); -module.exports = escapeHTML; diff --git a/test/escapeRegExp/escapeRegExp.test.js b/test/escapeRegExp.test.js similarity index 83% rename from test/escapeRegExp/escapeRegExp.test.js rename to test/escapeRegExp.test.js index bd3f2168f..063a639af 100644 --- a/test/escapeRegExp/escapeRegExp.test.js +++ b/test/escapeRegExp.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const escapeRegExp = require('./escapeRegExp.js'); +const {escapeRegExp} = require('./_30s.js'); test('escapeRegExp is a Function', () => { expect(escapeRegExp).toBeInstanceOf(Function); diff --git a/test/escapeRegExp/escapeRegExp.js b/test/escapeRegExp/escapeRegExp.js deleted file mode 100644 index 2519cfe13..000000000 --- a/test/escapeRegExp/escapeRegExp.js +++ /dev/null @@ -1,2 +0,0 @@ -const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); -module.exports = escapeRegExp; diff --git a/test/everyNth/everyNth.test.js b/test/everyNth.test.js similarity index 84% rename from test/everyNth/everyNth.test.js rename to test/everyNth.test.js index 826f746cf..34b9918dd 100644 --- a/test/everyNth/everyNth.test.js +++ b/test/everyNth.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const everyNth = require('./everyNth.js'); +const {everyNth} = require('./_30s.js'); test('everyNth is a Function', () => { expect(everyNth).toBeInstanceOf(Function); diff --git a/test/everyNth/everyNth.js b/test/everyNth/everyNth.js deleted file mode 100644 index 4ef94c46c..000000000 --- a/test/everyNth/everyNth.js +++ /dev/null @@ -1,2 +0,0 @@ -const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1); -module.exports = everyNth; diff --git a/test/extendHex/extendHex.test.js b/test/extendHex.test.js similarity index 88% rename from test/extendHex/extendHex.test.js rename to test/extendHex.test.js index a31a3c6d2..52141ca11 100644 --- a/test/extendHex/extendHex.test.js +++ b/test/extendHex.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const extendHex = require('./extendHex.js'); +const {extendHex} = require('./_30s.js'); test('extendHex is a Function', () => { expect(extendHex).toBeInstanceOf(Function); diff --git a/test/extendHex/extendHex.js b/test/extendHex/extendHex.js deleted file mode 100644 index 36ea367a2..000000000 --- a/test/extendHex/extendHex.js +++ /dev/null @@ -1,8 +0,0 @@ -const extendHex = shortHex => - '#' + - shortHex - .slice(shortHex.startsWith('#') ? 1 : 0) - .split('') - .map(x => x + x) - .join(''); -module.exports = extendHex; diff --git a/test/factorial/factorial.test.js b/test/factorial.test.js similarity index 92% rename from test/factorial/factorial.test.js rename to test/factorial.test.js index 130d39a79..5f3c8d963 100644 --- a/test/factorial/factorial.test.js +++ b/test/factorial.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const factorial = require('./factorial.js'); +const {factorial} = require('./_30s.js'); test('factorial is a Function', () => { expect(factorial).toBeInstanceOf(Function); diff --git a/test/factorial/factorial.js b/test/factorial/factorial.js deleted file mode 100644 index 8248f1051..000000000 --- a/test/factorial/factorial.js +++ /dev/null @@ -1,9 +0,0 @@ -const factorial = n => - n < 0 - ? (() => { - throw new TypeError('Negative numbers are not allowed!'); - })() - : n <= 1 - ? 1 - : n * factorial(n - 1); -module.exports = factorial; diff --git a/test/factors/factors.test.js b/test/factors.test.js similarity index 74% rename from test/factors/factors.test.js rename to test/factors.test.js index 961098ef4..b02c475c1 100644 --- a/test/factors/factors.test.js +++ b/test/factors.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const factors = require('./factors.js'); +const {factors} = require('./_30s.js'); test('factors is a Function', () => { expect(factors).toBeInstanceOf(Function); diff --git a/test/factors/factors.js b/test/factors/factors.js deleted file mode 100644 index 80e9e4b9b..000000000 --- a/test/factors/factors.js +++ /dev/null @@ -1,20 +0,0 @@ -const factors = (num, primes = false) => { - 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 isNeg = num < 0; - num = isNeg ? -num : num; - let array = Array.from({ length: num - 1 }) - .map((val, i) => (num % (i + 2) === 0 ? i + 2 : false)) - .filter(val => val); - if (isNeg) - array = array.reduce((acc, val) => { - acc.push(val); - acc.push(-val); - return acc; - }, []); - return primes ? array.filter(isPrime) : array; -}; -module.exports = factors; diff --git a/test/fahrenheitToCelsius/fahrenheitToCelsius.test.js b/test/fahrenheitToCelsius.test.js similarity index 90% rename from test/fahrenheitToCelsius/fahrenheitToCelsius.test.js rename to test/fahrenheitToCelsius.test.js index 0ec80c38c..e22dda3c8 100644 --- a/test/fahrenheitToCelsius/fahrenheitToCelsius.test.js +++ b/test/fahrenheitToCelsius.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const fahrenheitToCelsius = require('./fahrenheitToCelsius.js'); +const {fahrenheitToCelsius} = require('./_30s.js'); test('fahrenheitToCelsius is a Function', () => { expect(fahrenheitToCelsius).toBeInstanceOf(Function); diff --git a/test/fahrenheitToCelsius/fahrenheitToCelsius.js b/test/fahrenheitToCelsius/fahrenheitToCelsius.js deleted file mode 100644 index 399fd0d61..000000000 --- a/test/fahrenheitToCelsius/fahrenheitToCelsius.js +++ /dev/null @@ -1,2 +0,0 @@ -const fahrenheitToCelsius = degrees => (degrees - 32) * 5/9; -module.exports = fahrenheitToCelsius; diff --git a/test/fibonacci/fibonacci.test.js b/test/fibonacci.test.js similarity index 84% rename from test/fibonacci/fibonacci.test.js rename to test/fibonacci.test.js index c13d3551b..bd824ab16 100644 --- a/test/fibonacci/fibonacci.test.js +++ b/test/fibonacci.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const fibonacci = require('./fibonacci.js'); +const {fibonacci} = require('./_30s.js'); test('fibonacci is a Function', () => { expect(fibonacci).toBeInstanceOf(Function); diff --git a/test/fibonacci/fibonacci.js b/test/fibonacci/fibonacci.js deleted file mode 100644 index 3fa87a6e1..000000000 --- a/test/fibonacci/fibonacci.js +++ /dev/null @@ -1,6 +0,0 @@ -const fibonacci = n => - Array.from({ length: n }).reduce( - (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), - [] - ); -module.exports = fibonacci; diff --git a/test/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js b/test/fibonacciCountUntilNum.test.js similarity index 68% rename from test/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js rename to test/fibonacciCountUntilNum.test.js index 249b4ae48..38bb0e307 100644 --- a/test/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js +++ b/test/fibonacciCountUntilNum.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const fibonacciCountUntilNum = require('./fibonacciCountUntilNum.js'); +const {fibonacciCountUntilNum} = require('./_30s.js'); test('fibonacciCountUntilNum is a Function', () => { expect(fibonacciCountUntilNum).toBeInstanceOf(Function); diff --git a/test/fibonacciCountUntilNum/fibonacciCountUntilNum.js b/test/fibonacciCountUntilNum/fibonacciCountUntilNum.js deleted file mode 100644 index aacbc269b..000000000 --- a/test/fibonacciCountUntilNum/fibonacciCountUntilNum.js +++ /dev/null @@ -1,3 +0,0 @@ -const fibonacciCountUntilNum = num => - Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2)); -module.exports = fibonacciCountUntilNum; diff --git a/test/fibonacciUntilNum/fibonacciUntilNum.test.js b/test/fibonacciUntilNum.test.js similarity index 69% rename from test/fibonacciUntilNum/fibonacciUntilNum.test.js rename to test/fibonacciUntilNum.test.js index a639afad4..f8c98a9c5 100644 --- a/test/fibonacciUntilNum/fibonacciUntilNum.test.js +++ b/test/fibonacciUntilNum.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const fibonacciUntilNum = require('./fibonacciUntilNum.js'); +const {fibonacciUntilNum} = require('./_30s.js'); test('fibonacciUntilNum is a Function', () => { expect(fibonacciUntilNum).toBeInstanceOf(Function); diff --git a/test/fibonacciUntilNum/fibonacciUntilNum.js b/test/fibonacciUntilNum/fibonacciUntilNum.js deleted file mode 100644 index e4c109fb1..000000000 --- a/test/fibonacciUntilNum/fibonacciUntilNum.js +++ /dev/null @@ -1,8 +0,0 @@ -const fibonacciUntilNum = num => { - let n = Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2)); - return Array.from({ length: n }).reduce( - (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), - [] - ); -}; -module.exports = fibonacciUntilNum; diff --git a/test/filterNonUnique/filterNonUnique.test.js b/test/filterNonUnique.test.js similarity index 82% rename from test/filterNonUnique/filterNonUnique.test.js rename to test/filterNonUnique.test.js index 288d0209a..459c67282 100644 --- a/test/filterNonUnique/filterNonUnique.test.js +++ b/test/filterNonUnique.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const filterNonUnique = require('./filterNonUnique.js'); +const {filterNonUnique} = require('./_30s.js'); test('filterNonUnique is a Function', () => { expect(filterNonUnique).toBeInstanceOf(Function); diff --git a/test/filterNonUnique/filterNonUnique.js b/test/filterNonUnique/filterNonUnique.js deleted file mode 100644 index 84ca7a4e8..000000000 --- a/test/filterNonUnique/filterNonUnique.js +++ /dev/null @@ -1,2 +0,0 @@ -const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i)); -module.exports = filterNonUnique; diff --git a/test/filterNonUniqueBy/filterNonUniqueBy.test.js b/test/filterNonUniqueBy.test.js similarity index 93% rename from test/filterNonUniqueBy/filterNonUniqueBy.test.js rename to test/filterNonUniqueBy.test.js index c5b150049..16108cb66 100644 --- a/test/filterNonUniqueBy/filterNonUniqueBy.test.js +++ b/test/filterNonUniqueBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const filterNonUniqueBy = require('./filterNonUniqueBy.js'); +const {filterNonUniqueBy} = require('./_30s.js'); test('filterNonUniqueBy is a Function', () => { expect(filterNonUniqueBy).toBeInstanceOf(Function); diff --git a/test/filterNonUniqueBy/filterNonUniqueBy.js b/test/filterNonUniqueBy/filterNonUniqueBy.js deleted file mode 100644 index 274c1ce8a..000000000 --- a/test/filterNonUniqueBy/filterNonUniqueBy.js +++ /dev/null @@ -1,3 +0,0 @@ -const filterNonUniqueBy = (arr, fn) => - arr.filter((v, i) => arr.every((x, j) => (i === j) === fn(v, x, i, j))); -module.exports = filterNonUniqueBy; diff --git a/test/findKey/findKey.test.js b/test/findKey.test.js similarity index 90% rename from test/findKey/findKey.test.js rename to test/findKey.test.js index da13fb698..7a97fb19a 100644 --- a/test/findKey/findKey.test.js +++ b/test/findKey.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const findKey = require('./findKey.js'); +const {findKey} = require('./_30s.js'); test('findKey is a Function', () => { expect(findKey).toBeInstanceOf(Function); diff --git a/test/findKey/findKey.js b/test/findKey/findKey.js deleted file mode 100644 index 4f77774ce..000000000 --- a/test/findKey/findKey.js +++ /dev/null @@ -1,2 +0,0 @@ -const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj)); -module.exports = findKey; diff --git a/test/findLast/findLast.test.js b/test/findLast.test.js similarity index 85% rename from test/findLast/findLast.test.js rename to test/findLast.test.js index 34fa06939..819b5083d 100644 --- a/test/findLast/findLast.test.js +++ b/test/findLast.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const findLast = require('./findLast.js'); +const {findLast} = require('./_30s.js'); test('findLast is a Function', () => { expect(findLast).toBeInstanceOf(Function); diff --git a/test/findLast/findLast.js b/test/findLast/findLast.js deleted file mode 100644 index da604a9bf..000000000 --- a/test/findLast/findLast.js +++ /dev/null @@ -1,2 +0,0 @@ -const findLast = (arr, fn) => arr.filter(fn).pop(); -module.exports = findLast; diff --git a/test/findLastIndex/findLastIndex.test.js b/test/findLastIndex.test.js similarity index 83% rename from test/findLastIndex/findLastIndex.test.js rename to test/findLastIndex.test.js index 6f438daf6..237ac94fb 100644 --- a/test/findLastIndex/findLastIndex.test.js +++ b/test/findLastIndex.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const findLastIndex = require('./findLastIndex.js'); +const {findLastIndex} = require('./_30s.js'); test('findLastIndex is a Function', () => { expect(findLastIndex).toBeInstanceOf(Function); diff --git a/test/findLastIndex/findLastIndex.js b/test/findLastIndex/findLastIndex.js deleted file mode 100644 index d99adccbb..000000000 --- a/test/findLastIndex/findLastIndex.js +++ /dev/null @@ -1,6 +0,0 @@ -const findLastIndex = (arr, fn) => - arr - .map((val, i) => [i, val]) - .filter(([i, val]) => fn(val, i, arr)) - .pop()[0]; -module.exports = findLastIndex; diff --git a/test/findLastKey/findLastKey.test.js b/test/findLastKey.test.js similarity index 89% rename from test/findLastKey/findLastKey.test.js rename to test/findLastKey.test.js index d2e910b2c..405f17496 100644 --- a/test/findLastKey/findLastKey.test.js +++ b/test/findLastKey.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const findLastKey = require('./findLastKey.js'); +const {findLastKey} = require('./_30s.js'); test('findLastKey is a Function', () => { expect(findLastKey).toBeInstanceOf(Function); diff --git a/test/findLastKey/findLastKey.js b/test/findLastKey/findLastKey.js deleted file mode 100644 index f27471663..000000000 --- a/test/findLastKey/findLastKey.js +++ /dev/null @@ -1,5 +0,0 @@ -const findLastKey = (obj, fn) => - Object.keys(obj) - .reverse() - .find(key => fn(obj[key], key, obj)); -module.exports = findLastKey; diff --git a/test/flatten/flatten.test.js b/test/flatten.test.js similarity index 89% rename from test/flatten/flatten.test.js rename to test/flatten.test.js index 536a63637..b88fca548 100644 --- a/test/flatten/flatten.test.js +++ b/test/flatten.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const flatten = require('./flatten.js'); +const {flatten} = require('./_30s.js'); test('flatten is a Function', () => { expect(flatten).toBeInstanceOf(Function); diff --git a/test/flatten/flatten.js b/test/flatten/flatten.js deleted file mode 100644 index 83cebd731..000000000 --- a/test/flatten/flatten.js +++ /dev/null @@ -1,3 +0,0 @@ -const flatten = (arr, depth = 1) => - arr.reduce((a, v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []); -module.exports = flatten; diff --git a/test/flattenObject/flattenObject.test.js b/test/flattenObject.test.js similarity index 88% rename from test/flattenObject/flattenObject.test.js rename to test/flattenObject.test.js index e1d845c5d..c752d26d7 100644 --- a/test/flattenObject/flattenObject.test.js +++ b/test/flattenObject.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const flattenObject = require('./flattenObject.js'); +const {flattenObject} = require('./_30s.js'); test('flattenObject is a Function', () => { expect(flattenObject).toBeInstanceOf(Function); diff --git a/test/flattenObject/flattenObject.js b/test/flattenObject/flattenObject.js deleted file mode 100644 index bd796c5e1..000000000 --- a/test/flattenObject/flattenObject.js +++ /dev/null @@ -1,8 +0,0 @@ -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; - }, {}); -module.exports = flattenObject; diff --git a/test/flip/flip.test.js b/test/flip.test.js similarity index 89% rename from test/flip/flip.test.js rename to test/flip.test.js index 26ad46f43..0a72eae42 100644 --- a/test/flip/flip.test.js +++ b/test/flip.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const flip = require('./flip.js'); +const {flip} = require('./_30s.js'); test('flip is a Function', () => { expect(flip).toBeInstanceOf(Function); diff --git a/test/flip/flip.js b/test/flip/flip.js deleted file mode 100644 index 68cd33bb2..000000000 --- a/test/flip/flip.js +++ /dev/null @@ -1,2 +0,0 @@ -const flip = fn => (first, ...rest) => fn(...rest, first); -module.exports = flip; diff --git a/test/forEachRight/forEachRight.test.js b/test/forEachRight.test.js similarity index 84% rename from test/forEachRight/forEachRight.test.js rename to test/forEachRight.test.js index aec112662..01a6aa406 100644 --- a/test/forEachRight/forEachRight.test.js +++ b/test/forEachRight.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const forEachRight = require('./forEachRight.js'); +const {forEachRight} = require('./_30s.js'); test('forEachRight is a Function', () => { expect(forEachRight).toBeInstanceOf(Function); diff --git a/test/forEachRight/forEachRight.js b/test/forEachRight/forEachRight.js deleted file mode 100644 index b2143e743..000000000 --- a/test/forEachRight/forEachRight.js +++ /dev/null @@ -1,6 +0,0 @@ -const forEachRight = (arr, callback) => - arr - .slice(0) - .reverse() - .forEach(callback); -module.exports = forEachRight; diff --git a/test/forOwn/forOwn.test.js b/test/forOwn.test.js similarity index 88% rename from test/forOwn/forOwn.test.js rename to test/forOwn.test.js index 54f598cd0..e297312dc 100644 --- a/test/forOwn/forOwn.test.js +++ b/test/forOwn.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const forOwn = require('./forOwn.js'); +const {forOwn} = require('./_30s.js'); test('forOwn is a Function', () => { expect(forOwn).toBeInstanceOf(Function); diff --git a/test/forOwn/forOwn.js b/test/forOwn/forOwn.js deleted file mode 100644 index f6ddfd0c3..000000000 --- a/test/forOwn/forOwn.js +++ /dev/null @@ -1,2 +0,0 @@ -const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj)); -module.exports = forOwn; diff --git a/test/forOwnRight/forOwnRight.test.js b/test/forOwnRight.test.js similarity index 86% rename from test/forOwnRight/forOwnRight.test.js rename to test/forOwnRight.test.js index 542743af7..77fc161af 100644 --- a/test/forOwnRight/forOwnRight.test.js +++ b/test/forOwnRight.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const forOwnRight = require('./forOwnRight.js'); +const {forOwnRight} = require('./_30s.js'); test('forOwnRight is a Function', () => { expect(forOwnRight).toBeInstanceOf(Function); diff --git a/test/forOwnRight/forOwnRight.js b/test/forOwnRight/forOwnRight.js deleted file mode 100644 index 643cad803..000000000 --- a/test/forOwnRight/forOwnRight.js +++ /dev/null @@ -1,5 +0,0 @@ -const forOwnRight = (obj, fn) => - Object.keys(obj) - .reverse() - .forEach(key => fn(obj[key], key, obj)); -module.exports = forOwnRight; diff --git a/test/formatDuration/formatDuration.test.js b/test/formatDuration.test.js similarity index 89% rename from test/formatDuration/formatDuration.test.js rename to test/formatDuration.test.js index e1514868d..078c048bf 100644 --- a/test/formatDuration/formatDuration.test.js +++ b/test/formatDuration.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const formatDuration = require('./formatDuration.js'); +const {formatDuration} = require('./_30s.js'); test('formatDuration is a Function', () => { expect(formatDuration).toBeInstanceOf(Function); diff --git a/test/formatDuration/formatDuration.js b/test/formatDuration/formatDuration.js deleted file mode 100644 index 79014859d..000000000 --- a/test/formatDuration/formatDuration.js +++ /dev/null @@ -1,15 +0,0 @@ -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(', '); -}; -module.exports = formatDuration; diff --git a/test/fromCamelCase/fromCamelCase.test.js b/test/fromCamelCase.test.js similarity index 91% rename from test/fromCamelCase/fromCamelCase.test.js rename to test/fromCamelCase.test.js index 28a067ebf..c4fed066f 100644 --- a/test/fromCamelCase/fromCamelCase.test.js +++ b/test/fromCamelCase.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const fromCamelCase = require('./fromCamelCase.js'); +const {fromCamelCase} = require('./_30s.js'); test('fromCamelCase is a Function', () => { expect(fromCamelCase).toBeInstanceOf(Function); diff --git a/test/fromCamelCase/fromCamelCase.js b/test/fromCamelCase/fromCamelCase.js deleted file mode 100644 index 49b0c7fee..000000000 --- a/test/fromCamelCase/fromCamelCase.js +++ /dev/null @@ -1,6 +0,0 @@ -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(); -module.exports = fromCamelCase; diff --git a/test/functionName/functionName.test.js b/test/functionName.test.js similarity index 100% rename from test/functionName/functionName.test.js rename to test/functionName.test.js diff --git a/test/functionName/functionName.js b/test/functionName/functionName.js deleted file mode 100644 index 3fb41366f..000000000 --- a/test/functionName/functionName.js +++ /dev/null @@ -1,2 +0,0 @@ -const functionName = fn => (console.debug(fn.name), fn); -module.exports = functionName; diff --git a/test/functions/functions.test.js b/test/functions.test.js similarity index 90% rename from test/functions/functions.test.js rename to test/functions.test.js index 92db006c1..6163d1b0c 100644 --- a/test/functions/functions.test.js +++ b/test/functions.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const functions = require('./functions.js'); +const {functions} = require('./_30s.js'); test('functions is a Function', () => { expect(functions).toBeInstanceOf(Function); diff --git a/test/functions/functions.js b/test/functions/functions.js deleted file mode 100644 index e01d43b3d..000000000 --- a/test/functions/functions.js +++ /dev/null @@ -1,6 +0,0 @@ -const functions = (obj, inherited = false) => - (inherited - ? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))] - : Object.keys(obj) - ).filter(key => typeof obj[key] === 'function'); -module.exports = functions; diff --git a/test/gcd/gcd.test.js b/test/gcd.test.js similarity index 91% rename from test/gcd/gcd.test.js rename to test/gcd.test.js index 0cb8d930a..764a628ca 100644 --- a/test/gcd/gcd.test.js +++ b/test/gcd.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const gcd = require('./gcd.js'); +const {gcd} = require('./_30s.js'); test('gcd is a Function', () => { expect(gcd).toBeInstanceOf(Function); diff --git a/test/gcd/gcd.js b/test/gcd/gcd.js deleted file mode 100644 index 06e88caa6..000000000 --- a/test/gcd/gcd.js +++ /dev/null @@ -1,5 +0,0 @@ -const gcd = (...arr) => { - const _gcd = (x, y) => (!y ? x : gcd(y, x % y)); - return [...arr].reduce((a, b) => _gcd(a, b)); -}; -module.exports = gcd; diff --git a/test/geometricProgression/geometricProgression.test.js b/test/geometricProgression.test.js similarity index 90% rename from test/geometricProgression/geometricProgression.test.js rename to test/geometricProgression.test.js index 6ac3ed8e4..6f3944be6 100644 --- a/test/geometricProgression/geometricProgression.test.js +++ b/test/geometricProgression.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const geometricProgression = require('./geometricProgression.js'); +const {geometricProgression} = require('./_30s.js'); test('geometricProgression is a Function', () => { expect(geometricProgression).toBeInstanceOf(Function); diff --git a/test/geometricProgression/geometricProgression.js b/test/geometricProgression/geometricProgression.js deleted file mode 100644 index fea8c663d..000000000 --- a/test/geometricProgression/geometricProgression.js +++ /dev/null @@ -1,5 +0,0 @@ -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 - ); -module.exports = geometricProgression; diff --git a/test/get/get.test.js b/test/get.test.js similarity index 89% rename from test/get/get.test.js rename to test/get.test.js index 715ee0033..06e90f56c 100644 --- a/test/get/get.test.js +++ b/test/get.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const get = require('./get.js'); +const {get} = require('./_30s.js'); test('get is a Function', () => { expect(get).toBeInstanceOf(Function); diff --git a/test/get/get.js b/test/get/get.js deleted file mode 100644 index 695c625b4..000000000 --- a/test/get/get.js +++ /dev/null @@ -1,9 +0,0 @@ -const get = (from, ...selectors) => - [...selectors].map(s => - s - .replace(/\[([^\[\]]*)\]/g, '.$1.') - .split('.') - .filter(t => t !== '') - .reduce((prev, cur) => prev && prev[cur], from) - ); -module.exports = get; diff --git a/test/getColonTimeFromDate/getColonTimeFromDate.test.js b/test/getColonTimeFromDate.test.js similarity index 68% rename from test/getColonTimeFromDate/getColonTimeFromDate.test.js rename to test/getColonTimeFromDate.test.js index e834ac265..6d14dee94 100644 --- a/test/getColonTimeFromDate/getColonTimeFromDate.test.js +++ b/test/getColonTimeFromDate.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const getColonTimeFromDate = require('./getColonTimeFromDate.js'); +const {getColonTimeFromDate} = require('./_30s.js'); test('getColonTimeFromDate is a Function', () => { expect(getColonTimeFromDate).toBeInstanceOf(Function); diff --git a/test/getColonTimeFromDate/getColonTimeFromDate.js b/test/getColonTimeFromDate/getColonTimeFromDate.js deleted file mode 100644 index 352804b05..000000000 --- a/test/getColonTimeFromDate/getColonTimeFromDate.js +++ /dev/null @@ -1,2 +0,0 @@ -const getColonTimeFromDate = date => date.toTimeString().slice(0, 8); -module.exports = getColonTimeFromDate; diff --git a/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.test.js b/test/getDaysDiffBetweenDates.test.js similarity index 81% rename from test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.test.js rename to test/getDaysDiffBetweenDates.test.js index 2128fe077..4fd396a39 100644 --- a/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.test.js +++ b/test/getDaysDiffBetweenDates.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const getDaysDiffBetweenDates = require('./getDaysDiffBetweenDates.js'); +const {getDaysDiffBetweenDates} = require('./_30s.js'); test('getDaysDiffBetweenDates is a Function', () => { expect(getDaysDiffBetweenDates).toBeInstanceOf(Function); diff --git a/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js b/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js deleted file mode 100644 index ebfa776a3..000000000 --- a/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js +++ /dev/null @@ -1,3 +0,0 @@ -const getDaysDiffBetweenDates = (dateInitial, dateFinal) => - (dateFinal - dateInitial) / (1000 * 3600 * 24); -module.exports = getDaysDiffBetweenDates; diff --git a/test/getImages/getImages.test.js b/test/getImages.test.js similarity index 94% rename from test/getImages/getImages.test.js rename to test/getImages.test.js index 835785816..dc259cdd6 100644 --- a/test/getImages/getImages.test.js +++ b/test/getImages.test.js @@ -1,5 +1,5 @@ const expect = require("expect"); -const getImages = require("./getImages.js"); +const {getImages} = require("./_30s.js"); const jsdom = require("jsdom"); const { JSDOM } = jsdom; const TEST_HTML = new JSDOM("

    Hello world

    ").window.document; diff --git a/test/getImages/getImages.js b/test/getImages/getImages.js deleted file mode 100644 index 675dc839f..000000000 --- a/test/getImages/getImages.js +++ /dev/null @@ -1,5 +0,0 @@ -const getImages = (el, includeDuplicates = false) => { - const images = [...el.getElementsByTagName('img')].map(img => img.getAttribute('src')); - return includeDuplicates ? images : [...new Set(images)]; -}; -module.exports = getImages; diff --git a/test/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.test.js b/test/getMeridiemSuffixOfInteger.test.js similarity index 66% rename from test/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.test.js rename to test/getMeridiemSuffixOfInteger.test.js index 936eb3c13..99a8bfe47 100644 --- a/test/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.test.js +++ b/test/getMeridiemSuffixOfInteger.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const getMeridiemSuffixOfInteger = require('./getMeridiemSuffixOfInteger.js'); +const {getMeridiemSuffixOfInteger} = require('./_30s.js'); test('getMeridiemSuffixOfInteger is a Function', () => { expect(getMeridiemSuffixOfInteger).toBeInstanceOf(Function); diff --git a/test/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.js b/test/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.js deleted file mode 100644 index 6e91ea80c..000000000 --- a/test/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.js +++ /dev/null @@ -1,9 +0,0 @@ -const getMeridiemSuffixOfInteger = num => - num === 0 || num === 24 - ? 12 + 'am' - : num === 12 - ? 12 + 'pm' - : num < 12 - ? (num % 12) + 'am' - : (num % 12) + 'pm'; -module.exports = getMeridiemSuffixOfInteger; diff --git a/test/getScrollPosition/getScrollPosition.test.js b/test/getScrollPosition.test.js similarity index 69% rename from test/getScrollPosition/getScrollPosition.test.js rename to test/getScrollPosition.test.js index 0137c4eb4..c061d268b 100644 --- a/test/getScrollPosition/getScrollPosition.test.js +++ b/test/getScrollPosition.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const getScrollPosition = require('./getScrollPosition.js'); +const {getScrollPosition} = require('./_30s.js'); test('getScrollPosition is a Function', () => { expect(getScrollPosition).toBeInstanceOf(Function); diff --git a/test/getScrollPosition/getScrollPosition.js b/test/getScrollPosition/getScrollPosition.js deleted file mode 100644 index aa3845525..000000000 --- a/test/getScrollPosition/getScrollPosition.js +++ /dev/null @@ -1,5 +0,0 @@ -const getScrollPosition = (el = window) => ({ - x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft, - y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop -}); -module.exports = getScrollPosition; diff --git a/test/getStyle/getStyle.test.js b/test/getStyle.test.js similarity index 74% rename from test/getStyle/getStyle.test.js rename to test/getStyle.test.js index 6f279ab81..c6d6e0a1a 100644 --- a/test/getStyle/getStyle.test.js +++ b/test/getStyle.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const getStyle = require('./getStyle.js'); +const {getStyle} = require('./_30s.js'); test('getStyle is a Function', () => { expect(getStyle).toBeInstanceOf(Function); diff --git a/test/getStyle/getStyle.js b/test/getStyle/getStyle.js deleted file mode 100644 index b276a13b0..000000000 --- a/test/getStyle/getStyle.js +++ /dev/null @@ -1,2 +0,0 @@ -const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName]; -module.exports = getStyle; diff --git a/test/getType/getType.test.js b/test/getType.test.js similarity index 84% rename from test/getType/getType.test.js rename to test/getType.test.js index 660a7f020..c402a0a16 100644 --- a/test/getType/getType.test.js +++ b/test/getType.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const getType = require('./getType.js'); +const {getType} = require('./_30s.js'); test('getType is a Function', () => { expect(getType).toBeInstanceOf(Function); diff --git a/test/getType/getType.js b/test/getType/getType.js deleted file mode 100644 index 6b3bd5f10..000000000 --- a/test/getType/getType.js +++ /dev/null @@ -1,3 +0,0 @@ -const getType = v => - v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase(); -module.exports = getType; diff --git a/test/getURLParameters/getURLParameters.test.js b/test/getURLParameters.test.js similarity index 85% rename from test/getURLParameters/getURLParameters.test.js rename to test/getURLParameters.test.js index baf391631..118cc4973 100644 --- a/test/getURLParameters/getURLParameters.test.js +++ b/test/getURLParameters.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const getURLParameters = require('./getURLParameters.js'); +const {getURLParameters} = require('./_30s.js'); test('getURLParameters is a Function', () => { expect(getURLParameters).toBeInstanceOf(Function); diff --git a/test/getURLParameters/getURLParameters.js b/test/getURLParameters/getURLParameters.js deleted file mode 100644 index 288c65d3b..000000000 --- a/test/getURLParameters/getURLParameters.js +++ /dev/null @@ -1,6 +0,0 @@ -const getURLParameters = url => - (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce( - (a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), - {} - ); -module.exports = getURLParameters; diff --git a/test/groupBy/groupBy.test.js b/test/groupBy.test.js similarity index 91% rename from test/groupBy/groupBy.test.js rename to test/groupBy.test.js index de3d0560b..e0dd8740a 100644 --- a/test/groupBy/groupBy.test.js +++ b/test/groupBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const groupBy = require('./groupBy.js'); +const {groupBy} = require('./_30s.js'); test('groupBy is a Function', () => { expect(groupBy).toBeInstanceOf(Function); diff --git a/test/groupBy/groupBy.js b/test/groupBy/groupBy.js deleted file mode 100644 index 8f4c9b95e..000000000 --- a/test/groupBy/groupBy.js +++ /dev/null @@ -1,6 +0,0 @@ -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; - }, {}); -module.exports = groupBy; diff --git a/test/hammingDistance/hammingDistance.test.js b/test/hammingDistance.test.js similarity index 80% rename from test/hammingDistance/hammingDistance.test.js rename to test/hammingDistance.test.js index b884b6c89..c156772df 100644 --- a/test/hammingDistance/hammingDistance.test.js +++ b/test/hammingDistance.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const hammingDistance = require('./hammingDistance.js'); +const {hammingDistance} = require('./_30s.js'); test('hammingDistance is a Function', () => { expect(hammingDistance).toBeInstanceOf(Function); diff --git a/test/hammingDistance/hammingDistance.js b/test/hammingDistance/hammingDistance.js deleted file mode 100644 index 429b458c3..000000000 --- a/test/hammingDistance/hammingDistance.js +++ /dev/null @@ -1,2 +0,0 @@ -const hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length; -module.exports = hammingDistance; diff --git a/test/hasClass/hasClass.test.js b/test/hasClass.test.js similarity index 74% rename from test/hasClass/hasClass.test.js rename to test/hasClass.test.js index cd8fc69c7..d7f796238 100644 --- a/test/hasClass/hasClass.test.js +++ b/test/hasClass.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const hasClass = require('./hasClass.js'); +const {hasClass} = require('./_30s.js'); test('hasClass is a Function', () => { expect(hasClass).toBeInstanceOf(Function); diff --git a/test/hasClass/hasClass.js b/test/hasClass/hasClass.js deleted file mode 100644 index f6c66e6e3..000000000 --- a/test/hasClass/hasClass.js +++ /dev/null @@ -1,2 +0,0 @@ -const hasClass = (el, className) => el.classList.contains(className); -module.exports = hasClass; diff --git a/test/hasFlags/hasFlags.test.js b/test/hasFlags.test.js similarity index 74% rename from test/hasFlags/hasFlags.test.js rename to test/hasFlags.test.js index b709e53f5..14f5a13f0 100644 --- a/test/hasFlags/hasFlags.test.js +++ b/test/hasFlags.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const hasFlags = require('./hasFlags.js'); +const {hasFlags} = require('./_30s.js'); test('hasFlags is a Function', () => { expect(hasFlags).toBeInstanceOf(Function); diff --git a/test/hasFlags/hasFlags.js b/test/hasFlags/hasFlags.js deleted file mode 100644 index fe3fbb363..000000000 --- a/test/hasFlags/hasFlags.js +++ /dev/null @@ -1,3 +0,0 @@ -const hasFlags = (...flags) => - flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag)); -module.exports = hasFlags; diff --git a/test/hashBrowser/hashBrowser.test.js b/test/hashBrowser.test.js similarity index 72% rename from test/hashBrowser/hashBrowser.test.js rename to test/hashBrowser.test.js index e51fe281c..71ced6299 100644 --- a/test/hashBrowser/hashBrowser.test.js +++ b/test/hashBrowser.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const hashBrowser = require('./hashBrowser.js'); +const {hashBrowser} = require('./_30s.js'); test('hashBrowser is a Function', () => { expect(hashBrowser).toBeInstanceOf(Function); diff --git a/test/hashBrowser/hashBrowser.js b/test/hashBrowser/hashBrowser.js deleted file mode 100644 index 03b91f14d..000000000 --- a/test/hashBrowser/hashBrowser.js +++ /dev/null @@ -1,9 +0,0 @@ -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(''); - }); -module.exports = hashBrowser; diff --git a/test/hashNode/hashNode.test.js b/test/hashNode.test.js similarity index 89% rename from test/hashNode/hashNode.test.js rename to test/hashNode.test.js index 6cf659be2..126601da4 100644 --- a/test/hashNode/hashNode.test.js +++ b/test/hashNode.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const hashNode = require('./hashNode.js'); +const {hashNode} = require('./_30s.js'); test('hashNode is a Function', () => { expect(hashNode).toBeInstanceOf(Function); diff --git a/test/hashNode/hashNode.js b/test/hashNode/hashNode.js deleted file mode 100644 index 49aa3371d..000000000 --- a/test/hashNode/hashNode.js +++ /dev/null @@ -1,15 +0,0 @@ -const crypto = require('crypto'); -const hashNode = val => - new Promise(resolve => - setTimeout( - () => - resolve( - crypto - .createHash('sha256') - .update(val) - .digest('hex') - ), - 0 - ) - ); -module.exports = hashNode; diff --git a/test/head/head.test.js b/test/head.test.js similarity index 96% rename from test/head/head.test.js rename to test/head.test.js index 4330a382a..c59af7dab 100644 --- a/test/head/head.test.js +++ b/test/head.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const head = require('./head.js'); +const {head} = require('./_30s.js'); test('head is a Function', () => { expect(head).toBeInstanceOf(Function); diff --git a/test/head/head.js b/test/head/head.js deleted file mode 100644 index 6f7144f5b..000000000 --- a/test/head/head.js +++ /dev/null @@ -1,2 +0,0 @@ -const head = arr => arr[0]; -module.exports = head; diff --git a/test/heronArea/heronArea.test.js b/test/heronArea.test.js similarity index 73% rename from test/heronArea/heronArea.test.js rename to test/heronArea.test.js index e323009ef..b0a76d1fc 100644 --- a/test/heronArea/heronArea.test.js +++ b/test/heronArea.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const heronArea = require('./heronArea.js'); +const {heronArea} = require('./_30s.js'); test('heronArea is a Function', () => { expect(heronArea).toBeInstanceOf(Function); diff --git a/test/heronArea/heronArea.js b/test/heronArea/heronArea.js deleted file mode 100644 index 3735380f1..000000000 --- a/test/heronArea/heronArea.js +++ /dev/null @@ -1,5 +0,0 @@ -const heronArea = (side_a, side_b, side_c) => { - const p = (side_a + side_b + side_c) / 2 - return Math.sqrt(p * (p-side_a) * (p-side_b) * (p-side_c)) - }; -module.exports = heronArea; diff --git a/test/hexToRGB/hexToRGB.test.js b/test/hexToRGB.test.js similarity index 92% rename from test/hexToRGB/hexToRGB.test.js rename to test/hexToRGB.test.js index 2f2bf427e..3526c748f 100644 --- a/test/hexToRGB/hexToRGB.test.js +++ b/test/hexToRGB.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const hexToRGB = require('./hexToRGB.js'); +const {hexToRGB} = require('./_30s.js'); test('hexToRGB is a Function', () => { expect(hexToRGB).toBeInstanceOf(Function); diff --git a/test/hexToRGB/hexToRGB.js b/test/hexToRGB/hexToRGB.js deleted file mode 100644 index 3cce4385b..000000000 --- a/test/hexToRGB/hexToRGB.js +++ /dev/null @@ -1,20 +0,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}` : '') + - ')' - ); -}; -module.exports = hexToRGB; diff --git a/test/hide/hide.test.js b/test/hide.test.js similarity index 75% rename from test/hide/hide.test.js rename to test/hide.test.js index 7cfa1ec53..ed5ad2ad1 100644 --- a/test/hide/hide.test.js +++ b/test/hide.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const hide = require('./hide.js'); +const {hide} = require('./_30s.js'); test('hide is a Function', () => { expect(hide).toBeInstanceOf(Function); diff --git a/test/hide/hide.js b/test/hide/hide.js deleted file mode 100644 index 0ae2b0d3c..000000000 --- a/test/hide/hide.js +++ /dev/null @@ -1,2 +0,0 @@ -const hide = els => els.forEach(e => (e.style.display = 'none')); -module.exports = hide; diff --git a/test/howManyTimes/howManyTimes.test.js b/test/howManyTimes.test.js similarity index 71% rename from test/howManyTimes/howManyTimes.test.js rename to test/howManyTimes.test.js index e0d7efe30..5c6b39838 100644 --- a/test/howManyTimes/howManyTimes.test.js +++ b/test/howManyTimes.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const howManyTimes = require('./howManyTimes.js'); +const {howManyTimes} = require('./_30s.js'); test('howManyTimes is a Function', () => { expect(howManyTimes).toBeInstanceOf(Function); diff --git a/test/howManyTimes/howManyTimes.js b/test/howManyTimes/howManyTimes.js deleted file mode 100644 index 029dff672..000000000 --- a/test/howManyTimes/howManyTimes.js +++ /dev/null @@ -1,11 +0,0 @@ -const howManyTimes = (num, divisor) => { - if (divisor === 1 || divisor === -1) return Infinity; - if (divisor === 0) return 0; - let i = 0; - while (Number.isInteger(num / divisor)) { - i++; - num = num / divisor; - } - return i; -}; -module.exports = howManyTimes; diff --git a/test/httpDelete/httpDelete.test.js b/test/httpDelete.test.js similarity index 72% rename from test/httpDelete/httpDelete.test.js rename to test/httpDelete.test.js index 6603d33bd..b5ea1c17a 100644 --- a/test/httpDelete/httpDelete.test.js +++ b/test/httpDelete.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const httpDelete = require('./httpDelete.js'); +const {httpDelete} = require('./_30s.js'); test('httpDelete is a Function', () => { expect(httpDelete).toBeInstanceOf(Function); diff --git a/test/httpDelete/httpDelete.js b/test/httpDelete/httpDelete.js deleted file mode 100644 index 5b86d324a..000000000 --- a/test/httpDelete/httpDelete.js +++ /dev/null @@ -1,8 +0,0 @@ -const httpDelete = (url, callback, err = console.error) => { - const request = new XMLHttpRequest(); - request.open('DELETE', url, true); - request.onload = () => callback(request); - request.onerror = () => err(request); - request.send(); -}; -module.exports = httpDelete; diff --git a/test/httpGet/httpGet.test.js b/test/httpGet.test.js similarity index 74% rename from test/httpGet/httpGet.test.js rename to test/httpGet.test.js index 5a19d5adc..9a02c0728 100644 --- a/test/httpGet/httpGet.test.js +++ b/test/httpGet.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const httpGet = require('./httpGet.js'); +const {httpGet} = require('./_30s.js'); test('httpGet is a Function', () => { expect(httpGet).toBeInstanceOf(Function); diff --git a/test/httpGet/httpGet.js b/test/httpGet/httpGet.js deleted file mode 100644 index 73f537e73..000000000 --- a/test/httpGet/httpGet.js +++ /dev/null @@ -1,8 +0,0 @@ -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(); -}; -module.exports = httpGet; diff --git a/test/httpPost/httpPost.test.js b/test/httpPost.test.js similarity index 74% rename from test/httpPost/httpPost.test.js rename to test/httpPost.test.js index 13ec36ccd..85cd66d59 100644 --- a/test/httpPost/httpPost.test.js +++ b/test/httpPost.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const httpPost = require('./httpPost.js'); +const {httpPost} = require('./_30s.js'); test('httpPost is a Function', () => { expect(httpPost).toBeInstanceOf(Function); diff --git a/test/httpPost/httpPost.js b/test/httpPost/httpPost.js deleted file mode 100644 index f1380dd1b..000000000 --- a/test/httpPost/httpPost.js +++ /dev/null @@ -1,9 +0,0 @@ -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); -}; -module.exports = httpPost; diff --git a/test/httpPut/httpPut.test.js b/test/httpPut.test.js similarity index 74% rename from test/httpPut/httpPut.test.js rename to test/httpPut.test.js index d76892baf..8b472caa7 100644 --- a/test/httpPut/httpPut.test.js +++ b/test/httpPut.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const httpPut = require('./httpPut.js'); +const {httpPut} = require('./_30s.js'); test('httpPut is a Function', () => { expect(httpPut).toBeInstanceOf(Function); diff --git a/test/httpPut/httpPut.js b/test/httpPut/httpPut.js deleted file mode 100644 index 8b966b39a..000000000 --- a/test/httpPut/httpPut.js +++ /dev/null @@ -1,9 +0,0 @@ -const httpPut = (url, data, callback, err = console.error) => { - const request = new XMLHttpRequest(); - request.open("PUT", url, true); - request.setRequestHeader('Content-type','application/json; charset=utf-8'); - request.onload = () => callback(request); - request.onerror = () => err(request); - request.send(data); -}; -module.exports = httpPut; diff --git a/test/httpsRedirect/httpsRedirect.test.js b/test/httpsRedirect.test.js similarity index 71% rename from test/httpsRedirect/httpsRedirect.test.js rename to test/httpsRedirect.test.js index 68dd20f32..cf35a863a 100644 --- a/test/httpsRedirect/httpsRedirect.test.js +++ b/test/httpsRedirect.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const httpsRedirect = require('./httpsRedirect.js'); +const {httpsRedirect} = require('./_30s.js'); test('httpsRedirect is a Function', () => { expect(httpsRedirect).toBeInstanceOf(Function); diff --git a/test/httpsRedirect/httpsRedirect.js b/test/httpsRedirect/httpsRedirect.js deleted file mode 100644 index ef477f282..000000000 --- a/test/httpsRedirect/httpsRedirect.js +++ /dev/null @@ -1,4 +0,0 @@ -const httpsRedirect = () => { - if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]); -}; -module.exports = httpsRedirect; diff --git a/test/hz/hz.test.js b/test/hz.test.js similarity index 76% rename from test/hz/hz.test.js rename to test/hz.test.js index 58d0b4678..34cc4c187 100644 --- a/test/hz/hz.test.js +++ b/test/hz.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const hz = require('./hz.js'); +const {hz} = require('./_30s.js'); test('hz is a Function', () => { expect(hz).toBeInstanceOf(Function); diff --git a/test/hz/hz.js b/test/hz/hz.js deleted file mode 100644 index 7172074bb..000000000 --- a/test/hz/hz.js +++ /dev/null @@ -1,6 +0,0 @@ -const hz = (fn, iterations = 100) => { - const before = performance.now(); - for (let i = 0; i < iterations; i++) fn(); - return (1000 * iterations) / (performance.now() - before); -}; -module.exports = hz; diff --git a/test/inRange/inRange.test.js b/test/inRange.test.js similarity index 93% rename from test/inRange/inRange.test.js rename to test/inRange.test.js index c72efec2d..9a93aa20f 100644 --- a/test/inRange/inRange.test.js +++ b/test/inRange.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const inRange = require('./inRange.js'); +const {inRange} = require('./_30s.js'); test('inRange is a Function', () => { expect(inRange).toBeInstanceOf(Function); diff --git a/test/inRange/inRange.js b/test/inRange/inRange.js deleted file mode 100644 index 022dd4344..000000000 --- a/test/inRange/inRange.js +++ /dev/null @@ -1,5 +0,0 @@ -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; -}; -module.exports = inRange; diff --git a/test/indentString/indentString.test.js b/test/indentString.test.js similarity index 87% rename from test/indentString/indentString.test.js rename to test/indentString.test.js index 474523fb8..0ba6043f5 100644 --- a/test/indentString/indentString.test.js +++ b/test/indentString.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const indentString = require('./indentString.js'); +const {indentString} = require('./_30s.js'); test('indentString is a Function', () => { expect(indentString).toBeInstanceOf(Function); diff --git a/test/indentString/indentString.js b/test/indentString/indentString.js deleted file mode 100644 index 9f11c4efa..000000000 --- a/test/indentString/indentString.js +++ /dev/null @@ -1,2 +0,0 @@ -const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count)); -module.exports = indentString; diff --git a/test/indexOfAll/indexOfAll.test.js b/test/indexOfAll.test.js similarity index 88% rename from test/indexOfAll/indexOfAll.test.js rename to test/indexOfAll.test.js index 90233ce78..cc0620a6d 100644 --- a/test/indexOfAll/indexOfAll.test.js +++ b/test/indexOfAll.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const indexOfAll = require('./indexOfAll.js'); +const {indexOfAll} = require('./_30s.js'); test('indexOfAll is a Function', () => { expect(indexOfAll).toBeInstanceOf(Function); diff --git a/test/indexOfAll/indexOfAll.js b/test/indexOfAll/indexOfAll.js deleted file mode 100644 index f8e1225c7..000000000 --- a/test/indexOfAll/indexOfAll.js +++ /dev/null @@ -1,2 +0,0 @@ -const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []); -module.exports = indexOfAll; diff --git a/test/initial/initial.test.js b/test/initial.test.js similarity index 85% rename from test/initial/initial.test.js rename to test/initial.test.js index 2c8a8b944..83507fd70 100644 --- a/test/initial/initial.test.js +++ b/test/initial.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const initial = require('./initial.js'); +const {initial} = require('./_30s.js'); test('initial is a Function', () => { expect(initial).toBeInstanceOf(Function); diff --git a/test/initial/initial.js b/test/initial/initial.js deleted file mode 100644 index e3fa5e368..000000000 --- a/test/initial/initial.js +++ /dev/null @@ -1,2 +0,0 @@ -const initial = arr => arr.slice(0, -1); -module.exports = initial; diff --git a/test/initialize2DArray/initialize2DArray.test.js b/test/initialize2DArray.test.js similarity index 82% rename from test/initialize2DArray/initialize2DArray.test.js rename to test/initialize2DArray.test.js index 885900afe..d520752c5 100644 --- a/test/initialize2DArray/initialize2DArray.test.js +++ b/test/initialize2DArray.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const initialize2DArray = require('./initialize2DArray.js'); +const {initialize2DArray} = require('./_30s.js'); test('initialize2DArray is a Function', () => { expect(initialize2DArray).toBeInstanceOf(Function); diff --git a/test/initialize2DArray/initialize2DArray.js b/test/initialize2DArray/initialize2DArray.js deleted file mode 100644 index 362362f11..000000000 --- a/test/initialize2DArray/initialize2DArray.js +++ /dev/null @@ -1,3 +0,0 @@ -const initialize2DArray = (w, h, val = null) => - Array.from({ length: h }).map(() => Array.from({ length: w }).fill(val)); -module.exports = initialize2DArray; diff --git a/test/initializeArrayWithRange/initializeArrayWithRange.test.js b/test/initializeArrayWithRange.test.js similarity index 89% rename from test/initializeArrayWithRange/initializeArrayWithRange.test.js rename to test/initializeArrayWithRange.test.js index a645edc54..ca83833f5 100644 --- a/test/initializeArrayWithRange/initializeArrayWithRange.test.js +++ b/test/initializeArrayWithRange.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const initializeArrayWithRange = require('./initializeArrayWithRange.js'); +const {initializeArrayWithRange} = require('./_30s.js'); test('initializeArrayWithRange is a Function', () => { expect(initializeArrayWithRange).toBeInstanceOf(Function); diff --git a/test/initializeArrayWithRange/initializeArrayWithRange.js b/test/initializeArrayWithRange/initializeArrayWithRange.js deleted file mode 100644 index a096edd8d..000000000 --- a/test/initializeArrayWithRange/initializeArrayWithRange.js +++ /dev/null @@ -1,3 +0,0 @@ -const initializeArrayWithRange = (end, start = 0, step = 1) => - Array.from({ length: Math.ceil((end - start + 1) / step) }, (v, i) => i * step + start); -module.exports = initializeArrayWithRange; diff --git a/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.test.js b/test/initializeArrayWithRangeRight.test.js similarity index 66% rename from test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.test.js rename to test/initializeArrayWithRangeRight.test.js index 61f60f825..8bfbc0c86 100644 --- a/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.test.js +++ b/test/initializeArrayWithRangeRight.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const initializeArrayWithRangeRight = require('./initializeArrayWithRangeRight.js'); +const {initializeArrayWithRangeRight} = require('./_30s.js'); test('initializeArrayWithRangeRight is a Function', () => { expect(initializeArrayWithRangeRight).toBeInstanceOf(Function); diff --git a/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.js b/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.js deleted file mode 100644 index f6a839c7f..000000000 --- a/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.js +++ /dev/null @@ -1,5 +0,0 @@ -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 - ); -module.exports = initializeArrayWithRangeRight; diff --git a/test/initializeArrayWithValues/initializeArrayWithValues.test.js b/test/initializeArrayWithValues.test.js similarity index 79% rename from test/initializeArrayWithValues/initializeArrayWithValues.test.js rename to test/initializeArrayWithValues.test.js index 6b1b22eb3..d47e6f60c 100644 --- a/test/initializeArrayWithValues/initializeArrayWithValues.test.js +++ b/test/initializeArrayWithValues.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const initializeArrayWithValues = require('./initializeArrayWithValues.js'); +const {initializeArrayWithValues} = require('./_30s.js'); test('initializeArrayWithValues is a Function', () => { expect(initializeArrayWithValues).toBeInstanceOf(Function); diff --git a/test/initializeArrayWithValues/initializeArrayWithValues.js b/test/initializeArrayWithValues/initializeArrayWithValues.js deleted file mode 100644 index 6f4ec947e..000000000 --- a/test/initializeArrayWithValues/initializeArrayWithValues.js +++ /dev/null @@ -1,2 +0,0 @@ -const initializeArrayWithValues = (n, val = 0) => Array(n).fill(val); -module.exports = initializeArrayWithValues; diff --git a/test/initializeNDArray/initializeNDArray.test.js b/test/initializeNDArray.test.js similarity index 69% rename from test/initializeNDArray/initializeNDArray.test.js rename to test/initializeNDArray.test.js index df9199213..b394f5d2a 100644 --- a/test/initializeNDArray/initializeNDArray.test.js +++ b/test/initializeNDArray.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const initializeNDArray = require('./initializeNDArray.js'); +const {initializeNDArray} = require('./_30s.js'); test('initializeNDArray is a Function', () => { expect(initializeNDArray).toBeInstanceOf(Function); diff --git a/test/initializeNDArray/initializeNDArray.js b/test/initializeNDArray/initializeNDArray.js deleted file mode 100644 index 44bcfe3a8..000000000 --- a/test/initializeNDArray/initializeNDArray.js +++ /dev/null @@ -1,5 +0,0 @@ -const initializeNDArray = (val, ...args) => - args.length === 0 - ? val - : Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1))); -module.exports = initializeNDArray; diff --git a/test/insertAfter/insertAfter.test.js b/test/insertAfter.test.js similarity index 72% rename from test/insertAfter/insertAfter.test.js rename to test/insertAfter.test.js index 05f508d1a..3363c30ea 100644 --- a/test/insertAfter/insertAfter.test.js +++ b/test/insertAfter.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const insertAfter = require('./insertAfter.js'); +const {insertAfter} = require('./_30s.js'); test('insertAfter is a Function', () => { expect(insertAfter).toBeInstanceOf(Function); diff --git a/test/insertAfter/insertAfter.js b/test/insertAfter/insertAfter.js deleted file mode 100644 index 69de4395b..000000000 --- a/test/insertAfter/insertAfter.js +++ /dev/null @@ -1,2 +0,0 @@ -const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString); -module.exports = insertAfter; diff --git a/test/insertBefore/insertBefore.test.js b/test/insertBefore.test.js similarity index 71% rename from test/insertBefore/insertBefore.test.js rename to test/insertBefore.test.js index a482fb3df..f78e3e17a 100644 --- a/test/insertBefore/insertBefore.test.js +++ b/test/insertBefore.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const insertBefore = require('./insertBefore.js'); +const {insertBefore} = require('./_30s.js'); test('insertBefore is a Function', () => { expect(insertBefore).toBeInstanceOf(Function); diff --git a/test/insertBefore/insertBefore.js b/test/insertBefore/insertBefore.js deleted file mode 100644 index 8e29af968..000000000 --- a/test/insertBefore/insertBefore.js +++ /dev/null @@ -1,2 +0,0 @@ -const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString); -module.exports = insertBefore; diff --git a/test/intersection/intersection.test.js b/test/intersection.test.js similarity index 83% rename from test/intersection/intersection.test.js rename to test/intersection.test.js index 39186b7bb..e4a9543d3 100644 --- a/test/intersection/intersection.test.js +++ b/test/intersection.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const intersection = require('./intersection.js'); +const {intersection} = require('./_30s.js'); test('intersection is a Function', () => { expect(intersection).toBeInstanceOf(Function); diff --git a/test/intersection/intersection.js b/test/intersection/intersection.js deleted file mode 100644 index 521059129..000000000 --- a/test/intersection/intersection.js +++ /dev/null @@ -1,5 +0,0 @@ -const intersection = (a, b) => { - const s = new Set(b); - return a.filter(x => s.has(x)); -}; -module.exports = intersection; diff --git a/test/intersectionBy/intersectionBy.test.js b/test/intersectionBy.test.js similarity index 86% rename from test/intersectionBy/intersectionBy.test.js rename to test/intersectionBy.test.js index 5d69246bd..90fe4c5d8 100644 --- a/test/intersectionBy/intersectionBy.test.js +++ b/test/intersectionBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const intersectionBy = require('./intersectionBy.js'); +const {intersectionBy} = require('./_30s.js'); test('intersectionBy is a Function', () => { expect(intersectionBy).toBeInstanceOf(Function); diff --git a/test/intersectionBy/intersectionBy.js b/test/intersectionBy/intersectionBy.js deleted file mode 100644 index 0a6684fce..000000000 --- a/test/intersectionBy/intersectionBy.js +++ /dev/null @@ -1,5 +0,0 @@ -const intersectionBy = (a, b, fn) => { - const s = new Set(b.map(fn)); - return a.filter(x => s.has(fn(x))); -}; -module.exports = intersectionBy; diff --git a/test/intersectionWith/intersectionWith.test.js b/test/intersectionWith.test.js similarity index 87% rename from test/intersectionWith/intersectionWith.test.js rename to test/intersectionWith.test.js index b9a3b2008..513475e95 100644 --- a/test/intersectionWith/intersectionWith.test.js +++ b/test/intersectionWith.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const intersectionWith = require('./intersectionWith.js'); +const {intersectionWith} = require('./_30s.js'); test('intersectionWith is a Function', () => { expect(intersectionWith).toBeInstanceOf(Function); diff --git a/test/intersectionWith/intersectionWith.js b/test/intersectionWith/intersectionWith.js deleted file mode 100644 index 9b194c6e0..000000000 --- a/test/intersectionWith/intersectionWith.js +++ /dev/null @@ -1,2 +0,0 @@ -const intersectionWith = (a, b, comp) => a.filter(x => b.findIndex(y => comp(x, y)) !== -1); -module.exports = intersectionWith; diff --git a/test/invertKeyValues/invertKeyValues.test.js b/test/invertKeyValues.test.js similarity index 91% rename from test/invertKeyValues/invertKeyValues.test.js rename to test/invertKeyValues.test.js index 3c431ee6a..ccbd78030 100644 --- a/test/invertKeyValues/invertKeyValues.test.js +++ b/test/invertKeyValues.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const invertKeyValues = require('./invertKeyValues.js'); +const {invertKeyValues} = require('./_30s.js'); test('invertKeyValues is a Function', () => { expect(invertKeyValues).toBeInstanceOf(Function); diff --git a/test/invertKeyValues/invertKeyValues.js b/test/invertKeyValues/invertKeyValues.js deleted file mode 100644 index 5c6546dbe..000000000 --- a/test/invertKeyValues/invertKeyValues.js +++ /dev/null @@ -1,8 +0,0 @@ -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; - }, {}); -module.exports = invertKeyValues; diff --git a/test/is/is.test.js b/test/is.test.js similarity index 97% rename from test/is/is.test.js rename to test/is.test.js index 5309f0c08..48ec43edc 100644 --- a/test/is/is.test.js +++ b/test/is.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const is = require('./is.js'); +const {is} = require('./_30s.js'); test('is is a Function', () => { expect(is).toBeInstanceOf(Function); diff --git a/test/is/is.js b/test/is/is.js deleted file mode 100644 index ee5b7f6ba..000000000 --- a/test/is/is.js +++ /dev/null @@ -1,2 +0,0 @@ -const is = (type, val) => ![, null].includes(val) && val.constructor === type; -module.exports = is; diff --git a/test/isAbsoluteURL/isAbsoluteURL.test.js b/test/isAbsoluteURL.test.js similarity index 89% rename from test/isAbsoluteURL/isAbsoluteURL.test.js rename to test/isAbsoluteURL.test.js index 806ac881c..5e36e8b54 100644 --- a/test/isAbsoluteURL/isAbsoluteURL.test.js +++ b/test/isAbsoluteURL.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isAbsoluteURL = require('./isAbsoluteURL.js'); +const {isAbsoluteURL} = require('./_30s.js'); test('isAbsoluteURL is a Function', () => { expect(isAbsoluteURL).toBeInstanceOf(Function); diff --git a/test/isAbsoluteURL/isAbsoluteURL.js b/test/isAbsoluteURL/isAbsoluteURL.js deleted file mode 100644 index 8d5950d20..000000000 --- a/test/isAbsoluteURL/isAbsoluteURL.js +++ /dev/null @@ -1,2 +0,0 @@ -const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); -module.exports = isAbsoluteURL; diff --git a/test/isAfterDate/isAfterDate.test.js b/test/isAfterDate.test.js similarity index 89% rename from test/isAfterDate/isAfterDate.test.js rename to test/isAfterDate.test.js index 4332eab5a..2386fe9a9 100644 --- a/test/isAfterDate/isAfterDate.test.js +++ b/test/isAfterDate.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isAfterDate = require('./isAfterDate.js'); +const {isAfterDate} = require('./_30s.js'); test('isAfterDate is a Function', () => { expect(isAfterDate).toBeInstanceOf(Function); diff --git a/test/isAfterDate/isAfterDate.js b/test/isAfterDate/isAfterDate.js deleted file mode 100644 index e489c8439..000000000 --- a/test/isAfterDate/isAfterDate.js +++ /dev/null @@ -1,2 +0,0 @@ -const isAfterDate = (dateA, dateB) => dateA > dateB; -module.exports = isAfterDate; diff --git a/test/isAnagram/isAnagram.test.js b/test/isAnagram.test.js similarity index 92% rename from test/isAnagram/isAnagram.test.js rename to test/isAnagram.test.js index 6fc0a9cb6..9258a2193 100644 --- a/test/isAnagram/isAnagram.test.js +++ b/test/isAnagram.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isAnagram = require('./isAnagram.js'); +const {isAnagram} = require('./_30s.js'); test('isAnagram is a Function', () => { expect(isAnagram).toBeInstanceOf(Function); diff --git a/test/isAnagram/isAnagram.js b/test/isAnagram/isAnagram.js deleted file mode 100644 index 72931b190..000000000 --- a/test/isAnagram/isAnagram.js +++ /dev/null @@ -1,11 +0,0 @@ -const isAnagram = (str1, str2) => { - const normalize = str => - str - .toLowerCase() - .replace(/[^a-z0-9]/gi, '') - .split('') - .sort() - .join(''); - return normalize(str1) === normalize(str2); -}; -module.exports = isAnagram; diff --git a/test/isArmstrongNumber/isArmstrongNumber.test.js b/test/isArmstrongNumber.test.js similarity index 69% rename from test/isArmstrongNumber/isArmstrongNumber.test.js rename to test/isArmstrongNumber.test.js index 946cfa76f..93993ac5d 100644 --- a/test/isArmstrongNumber/isArmstrongNumber.test.js +++ b/test/isArmstrongNumber.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isArmstrongNumber = require('./isArmstrongNumber.js'); +const {isArmstrongNumber} = require('./_30s.js'); test('isArmstrongNumber is a Function', () => { expect(isArmstrongNumber).toBeInstanceOf(Function); diff --git a/test/isArmstrongNumber/isArmstrongNumber.js b/test/isArmstrongNumber/isArmstrongNumber.js deleted file mode 100644 index b4933a796..000000000 --- a/test/isArmstrongNumber/isArmstrongNumber.js +++ /dev/null @@ -1,5 +0,0 @@ -const isArmstrongNumber = digits => - (arr => arr.reduce((a, d) => a + parseInt(d) ** arr.length, 0) == digits)( - (digits + '').split('') - ); -module.exports = isArmstrongNumber; diff --git a/test/isArray/isArray.js b/test/isArray/isArray.js deleted file mode 100644 index 44cb6f381..000000000 --- a/test/isArray/isArray.js +++ /dev/null @@ -1,2 +0,0 @@ -const isArray = val => Array.isArray(val); -module.exports = isArray; diff --git a/test/isArray/isArray.test.js b/test/isArray/isArray.test.js deleted file mode 100644 index 5ca77144b..000000000 --- a/test/isArray/isArray.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const expect = require('expect'); -const isArray = require('./isArray.js'); - -test('isArray is a Function', () => { - expect(isArray).toBeInstanceOf(Function); -}); -test('passed value is an array', () => { - expect(isArray([1])).toBeTruthy(); -}); -test('passed value is not an array', () => { - expect(isArray('array')).toBeFalsy(); -}); diff --git a/test/isArrayBuffer/isArrayBuffer.js b/test/isArrayBuffer/isArrayBuffer.js deleted file mode 100644 index bc888208e..000000000 --- a/test/isArrayBuffer/isArrayBuffer.js +++ /dev/null @@ -1,2 +0,0 @@ -const isArrayBuffer = val => val instanceof ArrayBuffer; -module.exports = isArrayBuffer; diff --git a/test/isArrayBuffer/isArrayBuffer.test.js b/test/isArrayBuffer/isArrayBuffer.test.js deleted file mode 100644 index fb65e81de..000000000 --- a/test/isArrayBuffer/isArrayBuffer.test.js +++ /dev/null @@ -1,6 +0,0 @@ -const expect = require('expect'); -const isArrayBuffer = require('./isArrayBuffer.js'); - -test('isArrayBuffer is a Function', () => { - expect(isArrayBuffer).toBeInstanceOf(Function); -}); diff --git a/test/isArrayLike/isArrayLike.test.js b/test/isArrayLike.test.js similarity index 88% rename from test/isArrayLike/isArrayLike.test.js rename to test/isArrayLike.test.js index b1ffb49d1..04ffc5eda 100644 --- a/test/isArrayLike/isArrayLike.test.js +++ b/test/isArrayLike.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isArrayLike = require('./isArrayLike.js'); +const {isArrayLike} = require('./_30s.js'); test('isArrayLike is a Function', () => { expect(isArrayLike).toBeInstanceOf(Function); diff --git a/test/isArrayLike/isArrayLike.js b/test/isArrayLike/isArrayLike.js deleted file mode 100644 index 144b181d0..000000000 --- a/test/isArrayLike/isArrayLike.js +++ /dev/null @@ -1,2 +0,0 @@ -const isArrayLike = obj => obj != null && typeof obj[Symbol.iterator] === 'function'; -module.exports = isArrayLike; diff --git a/test/isBeforeDate/isBeforeDate.test.js b/test/isBeforeDate.test.js similarity index 89% rename from test/isBeforeDate/isBeforeDate.test.js rename to test/isBeforeDate.test.js index 5656970c1..e3ecb1403 100644 --- a/test/isBeforeDate/isBeforeDate.test.js +++ b/test/isBeforeDate.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isBeforeDate = require('./isBeforeDate.js'); +const {isBeforeDate} = require('./_30s.js'); test('isBeforeDate is a Function', () => { expect(isBeforeDate).toBeInstanceOf(Function); diff --git a/test/isBeforeDate/isBeforeDate.js b/test/isBeforeDate/isBeforeDate.js deleted file mode 100644 index cd6207544..000000000 --- a/test/isBeforeDate/isBeforeDate.js +++ /dev/null @@ -1,2 +0,0 @@ -const isBeforeDate = (dateA, dateB) => dateA < dateB; -module.exports = isBeforeDate; diff --git a/test/isBoolean/isBoolean.test.js b/test/isBoolean.test.js similarity index 87% rename from test/isBoolean/isBoolean.test.js rename to test/isBoolean.test.js index 31074f1f4..ee527f7ca 100644 --- a/test/isBoolean/isBoolean.test.js +++ b/test/isBoolean.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isBoolean = require('./isBoolean.js'); +const {isBoolean} = require('./_30s.js'); test('isBoolean is a Function', () => { expect(isBoolean).toBeInstanceOf(Function); diff --git a/test/isBoolean/isBoolean.js b/test/isBoolean/isBoolean.js deleted file mode 100644 index 52698bff3..000000000 --- a/test/isBoolean/isBoolean.js +++ /dev/null @@ -1,2 +0,0 @@ -const isBoolean = val => typeof val === 'boolean'; -module.exports = isBoolean; diff --git a/test/isBrowser/isBrowser.test.js b/test/isBrowser.test.js similarity index 73% rename from test/isBrowser/isBrowser.test.js rename to test/isBrowser.test.js index a6c32ee74..359dfd8d8 100644 --- a/test/isBrowser/isBrowser.test.js +++ b/test/isBrowser.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isBrowser = require('./isBrowser.js'); +const {isBrowser} = require('./_30s.js'); test('isBrowser is a Function', () => { expect(isBrowser).toBeInstanceOf(Function); diff --git a/test/isBrowser/isBrowser.js b/test/isBrowser/isBrowser.js deleted file mode 100644 index 26d288f10..000000000 --- a/test/isBrowser/isBrowser.js +++ /dev/null @@ -1,2 +0,0 @@ -const isBrowser = () => ![typeof window, typeof document].includes('undefined'); -module.exports = isBrowser; diff --git a/test/isBrowserTabFocused/isBrowserTabFocused.test.js b/test/isBrowserTabFocused.test.js similarity index 69% rename from test/isBrowserTabFocused/isBrowserTabFocused.test.js rename to test/isBrowserTabFocused.test.js index 780a52095..1d3bf771d 100644 --- a/test/isBrowserTabFocused/isBrowserTabFocused.test.js +++ b/test/isBrowserTabFocused.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isBrowserTabFocused = require('./isBrowserTabFocused.js'); +const {isBrowserTabFocused} = require('./_30s.js'); test('isBrowserTabFocused is a Function', () => { expect(isBrowserTabFocused).toBeInstanceOf(Function); diff --git a/test/isBrowserTabFocused/isBrowserTabFocused.js b/test/isBrowserTabFocused/isBrowserTabFocused.js deleted file mode 100644 index f70930c29..000000000 --- a/test/isBrowserTabFocused/isBrowserTabFocused.js +++ /dev/null @@ -1,2 +0,0 @@ -const isBrowserTabFocused = () => !document.hidden; -module.exports = isBrowserTabFocused; diff --git a/test/isDivisible/isDivisible.test.js b/test/isDivisible.test.js similarity index 81% rename from test/isDivisible/isDivisible.test.js rename to test/isDivisible.test.js index e6a41305a..5a1ccd035 100644 --- a/test/isDivisible/isDivisible.test.js +++ b/test/isDivisible.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isDivisible = require('./isDivisible.js'); +const {isDivisible} = require('./_30s.js'); test('isDivisible is a Function', () => { expect(isDivisible).toBeInstanceOf(Function); diff --git a/test/isDivisible/isDivisible.js b/test/isDivisible/isDivisible.js deleted file mode 100644 index de112a3cc..000000000 --- a/test/isDivisible/isDivisible.js +++ /dev/null @@ -1,2 +0,0 @@ -const isDivisible = (dividend, divisor) => dividend % divisor === 0; -module.exports = isDivisible; diff --git a/test/isDuplexStream/isDuplexStream.test.js b/test/isDuplexStream.test.js similarity index 52% rename from test/isDuplexStream/isDuplexStream.test.js rename to test/isDuplexStream.test.js index 6ff332242..a037f401b 100644 --- a/test/isDuplexStream/isDuplexStream.test.js +++ b/test/isDuplexStream.test.js @@ -1,16 +1,15 @@ const expect = require('expect'); -const isDuplexStream = require('./isDuplexStream.js'); -const fs = require('fs'); +const {isDuplexStream} = require('./_30s.js'); const Stream = require('stream'); test('isDuplexStream is a Function', () => { expect(isDuplexStream).toBeInstanceOf(Function); }); -test('isDuplexStream returns true for read streams', () => { - expect(isDuplexStream(fs.createReadStream('isDuplexStream.js'))).toBeTruthy(); +test('isDuplexStream returns false for read streams', () => { + expect(isDuplexStream(new Stream.Readable())).toBeFalsy(); }); -test('isDuplexStream returns true for write streams', () => { - expect(isDuplexStream(fs.createWriteStream('isDuplexStream.js'))).toBeTruthy(); +test('isDuplexStream returns false for write streams', () => { + expect(isDuplexStream(new Stream.Writable())).toBeFalsy(); }); test('isDuplexStream returns true for duplex streams', () => { expect(isDuplexStream(new Stream.Duplex())).toBeTruthy(); diff --git a/test/isDuplexStream/isDuplexStream.js b/test/isDuplexStream/isDuplexStream.js deleted file mode 100644 index c39653e73..000000000 --- a/test/isDuplexStream/isDuplexStream.js +++ /dev/null @@ -1,9 +0,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'; -module.exports = isDuplexStream; diff --git a/test/isEmpty/isEmpty.test.js b/test/isEmpty.test.js similarity index 96% rename from test/isEmpty/isEmpty.test.js rename to test/isEmpty.test.js index da27a5581..cbb3078e3 100644 --- a/test/isEmpty/isEmpty.test.js +++ b/test/isEmpty.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isEmpty = require('./isEmpty.js'); +const {isEmpty} = require('./_30s.js'); test('isEmpty is a Function', () => { expect(isEmpty).toBeInstanceOf(Function); diff --git a/test/isEmpty/isEmpty.js b/test/isEmpty/isEmpty.js deleted file mode 100644 index 20738e4f2..000000000 --- a/test/isEmpty/isEmpty.js +++ /dev/null @@ -1,2 +0,0 @@ -const isEmpty = val => val == null || !(Object.keys(val) || val).length; -module.exports = isEmpty; diff --git a/test/isEven/isEven.test.js b/test/isEven.test.js similarity index 87% rename from test/isEven/isEven.test.js rename to test/isEven.test.js index 906f42b7b..6c9281460 100644 --- a/test/isEven/isEven.test.js +++ b/test/isEven.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isEven = require('./isEven.js'); +const {isEven} = require('./_30s.js'); test('isEven is a Function', () => { expect(isEven).toBeInstanceOf(Function); diff --git a/test/isEven/isEven.js b/test/isEven/isEven.js deleted file mode 100644 index d5eda889b..000000000 --- a/test/isEven/isEven.js +++ /dev/null @@ -1,2 +0,0 @@ -const isEven = num => num % 2 === 0; -module.exports = isEven; diff --git a/test/isFunction/isFunction.test.js b/test/isFunction.test.js similarity index 86% rename from test/isFunction/isFunction.test.js rename to test/isFunction.test.js index da7c3325a..36c70b88b 100644 --- a/test/isFunction/isFunction.test.js +++ b/test/isFunction.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isFunction = require('./isFunction.js'); +const {isFunction} = require('./_30s.js'); test('isFunction is a Function', () => { expect(isFunction).toBeInstanceOf(Function); diff --git a/test/isFunction/isFunction.js b/test/isFunction/isFunction.js deleted file mode 100644 index 29123f19f..000000000 --- a/test/isFunction/isFunction.js +++ /dev/null @@ -1,2 +0,0 @@ -const isFunction = val => typeof val === 'function'; -module.exports = isFunction; diff --git a/test/isLowerCase/isLowerCase.test.js b/test/isLowerCase.test.js similarity index 89% rename from test/isLowerCase/isLowerCase.test.js rename to test/isLowerCase.test.js index 9c6542476..fc38a7763 100644 --- a/test/isLowerCase/isLowerCase.test.js +++ b/test/isLowerCase.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isLowerCase = require('./isLowerCase.js'); +const {isLowerCase} = require('./_30s.js'); test('isLowerCase is a Function', () => { expect(isLowerCase).toBeInstanceOf(Function); diff --git a/test/isLowerCase/isLowerCase.js b/test/isLowerCase/isLowerCase.js deleted file mode 100644 index a5184a193..000000000 --- a/test/isLowerCase/isLowerCase.js +++ /dev/null @@ -1,2 +0,0 @@ -const isLowerCase = str => str === str.toLowerCase(); -module.exports = isLowerCase; diff --git a/test/isMap/isMap.js b/test/isMap/isMap.js deleted file mode 100644 index 8dc9687b4..000000000 --- a/test/isMap/isMap.js +++ /dev/null @@ -1,2 +0,0 @@ -const isMap = val => val instanceof Map; -module.exports = isMap; diff --git a/test/isMap/isMap.test.js b/test/isMap/isMap.test.js deleted file mode 100644 index e6e434636..000000000 --- a/test/isMap/isMap.test.js +++ /dev/null @@ -1,6 +0,0 @@ -const expect = require('expect'); -const isMap = require('./isMap.js'); - -test('isMap is a Function', () => { - expect(isMap).toBeInstanceOf(Function); -}); diff --git a/test/isNil/isNil.test.js b/test/isNil.test.js similarity index 90% rename from test/isNil/isNil.test.js rename to test/isNil.test.js index be77815a2..4fa531e49 100644 --- a/test/isNil/isNil.test.js +++ b/test/isNil.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isNil = require('./isNil.js'); +const {isNil} = require('./_30s.js'); test('isNil is a Function', () => { expect(isNil).toBeInstanceOf(Function); diff --git a/test/isNil/isNil.js b/test/isNil/isNil.js deleted file mode 100644 index 6ed72a7be..000000000 --- a/test/isNil/isNil.js +++ /dev/null @@ -1,2 +0,0 @@ -const isNil = val => val === undefined || val === null; -module.exports = isNil; diff --git a/test/isNull/isNull.test.js b/test/isNull.test.js similarity index 87% rename from test/isNull/isNull.test.js rename to test/isNull.test.js index fdf97d069..8cb1c9051 100644 --- a/test/isNull/isNull.test.js +++ b/test/isNull.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isNull = require('./isNull.js'); +const {isNull} = require('./_30s.js'); test('isNull is a Function', () => { expect(isNull).toBeInstanceOf(Function); diff --git a/test/isNull/isNull.js b/test/isNull/isNull.js deleted file mode 100644 index 5cfec0ee2..000000000 --- a/test/isNull/isNull.js +++ /dev/null @@ -1,2 +0,0 @@ -const isNull = val => val === null; -module.exports = isNull; diff --git a/test/isNumber/isNumber.test.js b/test/isNumber.test.js similarity index 87% rename from test/isNumber/isNumber.test.js rename to test/isNumber.test.js index 9b4872778..4f27fe9ca 100644 --- a/test/isNumber/isNumber.test.js +++ b/test/isNumber.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isNumber = require('./isNumber.js'); +const {isNumber} = require('./_30s.js'); test('isNumber is a Function', () => { expect(isNumber).toBeInstanceOf(Function); diff --git a/test/isNumber/isNumber.js b/test/isNumber/isNumber.js deleted file mode 100644 index cd76e2128..000000000 --- a/test/isNumber/isNumber.js +++ /dev/null @@ -1,2 +0,0 @@ -const isNumber = val => typeof val === 'number'; -module.exports = isNumber; diff --git a/test/isObject/isObject.test.js b/test/isObject.test.js similarity index 91% rename from test/isObject/isObject.test.js rename to test/isObject.test.js index e7f570feb..341e1f38f 100644 --- a/test/isObject/isObject.test.js +++ b/test/isObject.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isObject = require('./isObject.js'); +const {isObject} = require('./_30s.js'); test('isObject is a Function', () => { expect(isObject).toBeInstanceOf(Function); diff --git a/test/isObject/isObject.js b/test/isObject/isObject.js deleted file mode 100644 index 1eb389d52..000000000 --- a/test/isObject/isObject.js +++ /dev/null @@ -1,2 +0,0 @@ -const isObject = obj => obj === Object(obj); -module.exports = isObject; diff --git a/test/isObjectLike/isObjectLike.test.js b/test/isObjectLike.test.js similarity index 90% rename from test/isObjectLike/isObjectLike.test.js rename to test/isObjectLike.test.js index 410878d8e..dfa1dc0b2 100644 --- a/test/isObjectLike/isObjectLike.test.js +++ b/test/isObjectLike.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isObjectLike = require('./isObjectLike.js'); +const {isObjectLike} = require('./_30s.js'); test('isObjectLike is a Function', () => { expect(isObjectLike).toBeInstanceOf(Function); diff --git a/test/isObjectLike/isObjectLike.js b/test/isObjectLike/isObjectLike.js deleted file mode 100644 index 4bdf057d1..000000000 --- a/test/isObjectLike/isObjectLike.js +++ /dev/null @@ -1,2 +0,0 @@ -const isObjectLike = val => val !== null && typeof val === 'object'; -module.exports = isObjectLike; diff --git a/test/isPlainObject/isPlainObject.test.js b/test/isPlainObject.test.js similarity index 87% rename from test/isPlainObject/isPlainObject.test.js rename to test/isPlainObject.test.js index eda33dabc..8f79ece8b 100644 --- a/test/isPlainObject/isPlainObject.test.js +++ b/test/isPlainObject.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isPlainObject = require('./isPlainObject.js'); +const {isPlainObject} = require('./_30s.js'); test('isPlainObject is a Function', () => { expect(isPlainObject).toBeInstanceOf(Function); diff --git a/test/isPlainObject/isPlainObject.js b/test/isPlainObject/isPlainObject.js deleted file mode 100644 index 593560238..000000000 --- a/test/isPlainObject/isPlainObject.js +++ /dev/null @@ -1,2 +0,0 @@ -const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object; -module.exports = isPlainObject; diff --git a/test/isPrime/isPrime.test.js b/test/isPrime.test.js similarity index 83% rename from test/isPrime/isPrime.test.js rename to test/isPrime.test.js index f6776f687..2e967fce3 100644 --- a/test/isPrime/isPrime.test.js +++ b/test/isPrime.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isPrime = require('./isPrime.js'); +const {isPrime} = require('./_30s.js'); test('isPrime is a Function', () => { expect(isPrime).toBeInstanceOf(Function); diff --git a/test/isPrime/isPrime.js b/test/isPrime/isPrime.js deleted file mode 100644 index 9613c2f63..000000000 --- a/test/isPrime/isPrime.js +++ /dev/null @@ -1,6 +0,0 @@ -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; -}; -module.exports = isPrime; diff --git a/test/isPrimitive/isPrimitive.test.js b/test/isPrimitive.test.js similarity index 96% rename from test/isPrimitive/isPrimitive.test.js rename to test/isPrimitive.test.js index 2d5179475..325e0d122 100644 --- a/test/isPrimitive/isPrimitive.test.js +++ b/test/isPrimitive.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isPrimitive = require('./isPrimitive.js'); +const {isPrimitive} = require('./_30s.js'); test('isPrimitive is a Function', () => { expect(isPrimitive).toBeInstanceOf(Function); diff --git a/test/isPrimitive/isPrimitive.js b/test/isPrimitive/isPrimitive.js deleted file mode 100644 index eaab7f941..000000000 --- a/test/isPrimitive/isPrimitive.js +++ /dev/null @@ -1,2 +0,0 @@ -const isPrimitive = val => Object(val) !== val; -module.exports = isPrimitive; diff --git a/test/isPromiseLike/isPromiseLike.test.js b/test/isPromiseLike.test.js similarity index 88% rename from test/isPromiseLike/isPromiseLike.test.js rename to test/isPromiseLike.test.js index 7c3a17c28..eabc7fb80 100644 --- a/test/isPromiseLike/isPromiseLike.test.js +++ b/test/isPromiseLike.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isPromiseLike = require('./isPromiseLike.js'); +const {isPromiseLike} = require('./_30s.js'); test('isPromiseLike is a Function', () => { expect(isPromiseLike).toBeInstanceOf(Function); diff --git a/test/isPromiseLike/isPromiseLike.js b/test/isPromiseLike/isPromiseLike.js deleted file mode 100644 index b26b21400..000000000 --- a/test/isPromiseLike/isPromiseLike.js +++ /dev/null @@ -1,5 +0,0 @@ -const isPromiseLike = obj => - obj !== null && - (typeof obj === 'object' || typeof obj === 'function') && - typeof obj.then === 'function'; -module.exports = isPromiseLike; diff --git a/test/isReadableStream/isReadableStream.test.js b/test/isReadableStream.test.js similarity index 68% rename from test/isReadableStream/isReadableStream.test.js rename to test/isReadableStream.test.js index 7c5174d99..e8f5905e1 100644 --- a/test/isReadableStream/isReadableStream.test.js +++ b/test/isReadableStream.test.js @@ -1,16 +1,15 @@ const expect = require('expect'); -const isReadableStream = require('./isReadableStream.js'); -const fs = require('fs'); +const { isReadableStream } = require('./_30s.js'); const Stream = require('stream'); test('isReadableStream is a Function', () => { expect(isReadableStream).toBeInstanceOf(Function); }); test('isReadableStream returns true for read streams', () => { - expect(isReadableStream(fs.createReadStream('isReadableStream.js'))).toBeTruthy(); + expect(isReadableStream(new Stream.Readable())).toBeTruthy(); }); test('isReadableStream returns false for write streams', () => { - expect(isReadableStream(fs.createWriteStream('isReadableStream.js'))).toBeFalsy(); + expect(isReadableStream(new Stream.Writable())).toBeFalsy(); }); test('isReadableStream returns true for duplex streams', () => { expect(isReadableStream(new Stream.Duplex())).toBeTruthy(); diff --git a/test/isReadableStream/isReadableStream.js b/test/isReadableStream/isReadableStream.js deleted file mode 100644 index a514cc8d2..000000000 --- a/test/isReadableStream/isReadableStream.js +++ /dev/null @@ -1,7 +0,0 @@ -const isReadableStream = val => - val !== null && - typeof val === 'object' && - typeof val.pipe === 'function' && - typeof val._read === 'function' && - typeof val._readableState === 'object'; -module.exports = isReadableStream; diff --git a/test/isRegExp/isRegExp.js b/test/isRegExp/isRegExp.js deleted file mode 100644 index bae7a3135..000000000 --- a/test/isRegExp/isRegExp.js +++ /dev/null @@ -1,2 +0,0 @@ -const isRegExp = val => val instanceof RegExp; -module.exports = isRegExp; diff --git a/test/isRegExp/isRegExp.test.js b/test/isRegExp/isRegExp.test.js deleted file mode 100644 index ec565713f..000000000 --- a/test/isRegExp/isRegExp.test.js +++ /dev/null @@ -1,6 +0,0 @@ -const expect = require('expect'); -const isRegExp = require('./isRegExp.js'); - -test('isRegExp is a Function', () => { - expect(isRegExp).toBeInstanceOf(Function); -}); diff --git a/test/isSameDate/isSameDate.test.js b/test/isSameDate.test.js similarity index 89% rename from test/isSameDate/isSameDate.test.js rename to test/isSameDate.test.js index 2b6e8cbd4..3467bf5b1 100644 --- a/test/isSameDate/isSameDate.test.js +++ b/test/isSameDate.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isSameDate = require('./isSameDate.js'); +const {isSameDate} = require('./_30s.js'); test('isSameDate is a Function', () => { expect(isSameDate).toBeInstanceOf(Function); diff --git a/test/isSameDate/isSameDate.js b/test/isSameDate/isSameDate.js deleted file mode 100644 index 3bd6f2218..000000000 --- a/test/isSameDate/isSameDate.js +++ /dev/null @@ -1,2 +0,0 @@ -const isSameDate = (dateA, dateB) => dateA.toISOString() === dateB.toISOString(); -module.exports = isSameDate; diff --git a/test/isSet/isSet.js b/test/isSet/isSet.js deleted file mode 100644 index d2a3b00cb..000000000 --- a/test/isSet/isSet.js +++ /dev/null @@ -1,2 +0,0 @@ -const isSet = val => val instanceof Set; -module.exports = isSet; diff --git a/test/isSet/isSet.test.js b/test/isSet/isSet.test.js deleted file mode 100644 index 559889443..000000000 --- a/test/isSet/isSet.test.js +++ /dev/null @@ -1,6 +0,0 @@ -const expect = require('expect'); -const isSet = require('./isSet.js'); - -test('isSet is a Function', () => { - expect(isSet).toBeInstanceOf(Function); -}); diff --git a/test/isSimilar/isSimilar.test.js b/test/isSimilar.test.js similarity index 73% rename from test/isSimilar/isSimilar.test.js rename to test/isSimilar.test.js index 0a632774e..0032f39d4 100644 --- a/test/isSimilar/isSimilar.test.js +++ b/test/isSimilar.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isSimilar = require('./isSimilar.js'); +const {isSimilar} = require('./_30s.js'); test('isSimilar is a Function', () => { expect(isSimilar).toBeInstanceOf(Function); diff --git a/test/isSimilar/isSimilar.js b/test/isSimilar/isSimilar.js deleted file mode 100644 index 9fbeb204c..000000000 --- a/test/isSimilar/isSimilar.js +++ /dev/null @@ -1,9 +0,0 @@ -const isSimilar = (pattern, str) => - [...str].reduce( - (matchIndex, char) => - char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() - ? matchIndex + 1 - : matchIndex, - 0 - ) === pattern.length; -module.exports = isSimilar; diff --git a/test/isSorted/isSorted.test.js b/test/isSorted.test.js similarity index 96% rename from test/isSorted/isSorted.test.js rename to test/isSorted.test.js index d1d9fcfd9..c5268ba02 100644 --- a/test/isSorted/isSorted.test.js +++ b/test/isSorted.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isSorted = require('./isSorted.js'); +const {isSorted} = require('./_30s.js'); test('isSorted is a Function', () => { expect(isSorted).toBeInstanceOf(Function); diff --git a/test/isSorted/isSorted.js b/test/isSorted/isSorted.js deleted file mode 100644 index 8250ab454..000000000 --- a/test/isSorted/isSorted.js +++ /dev/null @@ -1,9 +0,0 @@ -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; - } -}; -module.exports = isSorted; diff --git a/test/isStream/isStream.test.js b/test/isStream.test.js similarity index 70% rename from test/isStream/isStream.test.js rename to test/isStream.test.js index 3d0f18e56..2c535933c 100644 --- a/test/isStream/isStream.test.js +++ b/test/isStream.test.js @@ -1,16 +1,15 @@ const expect = require('expect'); -const isStream = require('./isStream.js'); -const fs = require('fs'); +const { isStream } = require('./_30s.js'); const Stream = require('stream'); test('isStream is a Function', () => { expect(isStream).toBeInstanceOf(Function); }); test('isStream returns true for read streams', () => { - expect(isStream(fs.createReadStream('isStream.js'))).toBeTruthy(); + expect(isStream(new Stream.Readable())).toBeTruthy(); }); test('isStream returns true for write streams', () => { - expect(isStream(fs.createWriteStream('isStream.js'))).toBeTruthy(); + expect(isStream(new Stream.Writable())).toBeTruthy(); }); test('isStream returns true for duplex streams', () => { expect(isStream(new Stream.Duplex())).toBeTruthy(); diff --git a/test/isStream/isStream.js b/test/isStream/isStream.js deleted file mode 100644 index cbdd9bd61..000000000 --- a/test/isStream/isStream.js +++ /dev/null @@ -1,2 +0,0 @@ -const isStream = val => val !== null && typeof val === 'object' && typeof val.pipe === 'function'; -module.exports = isStream; diff --git a/test/isString/isString.test.js b/test/isString.test.js similarity index 92% rename from test/isString/isString.test.js rename to test/isString.test.js index d3021b275..a1ba6bbdf 100644 --- a/test/isString/isString.test.js +++ b/test/isString.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isString = require('./isString.js'); +const {isString} = require('./_30s.js'); test('isString is a Function', () => { expect(isString).toBeInstanceOf(Function); diff --git a/test/isString/isString.js b/test/isString/isString.js deleted file mode 100644 index 6f644887f..000000000 --- a/test/isString/isString.js +++ /dev/null @@ -1,2 +0,0 @@ -const isString = val => typeof val === 'string'; -module.exports = isString; diff --git a/test/isSymbol/isSymbol.test.js b/test/isSymbol.test.js similarity index 84% rename from test/isSymbol/isSymbol.test.js rename to test/isSymbol.test.js index 7b614771b..162291a08 100644 --- a/test/isSymbol/isSymbol.test.js +++ b/test/isSymbol.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isSymbol = require('./isSymbol.js'); +const {isSymbol} = require('./_30s.js'); test('isSymbol is a Function', () => { expect(isSymbol).toBeInstanceOf(Function); diff --git a/test/isSymbol/isSymbol.js b/test/isSymbol/isSymbol.js deleted file mode 100644 index 8a3ebf2dc..000000000 --- a/test/isSymbol/isSymbol.js +++ /dev/null @@ -1,2 +0,0 @@ -const isSymbol = val => typeof val === 'symbol'; -module.exports = isSymbol; diff --git a/test/isTravisCI/isTravisCI.test.js b/test/isTravisCI.test.js similarity index 88% rename from test/isTravisCI/isTravisCI.test.js rename to test/isTravisCI.test.js index 024b6869f..6489b57ea 100644 --- a/test/isTravisCI/isTravisCI.test.js +++ b/test/isTravisCI.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isTravisCI = require('./isTravisCI.js'); +const {isTravisCI} = require('./_30s.js'); test('isTravisCI is a Function', () => { expect(isTravisCI).toBeInstanceOf(Function); diff --git a/test/isTravisCI/isTravisCI.js b/test/isTravisCI/isTravisCI.js deleted file mode 100644 index 9f4a22de5..000000000 --- a/test/isTravisCI/isTravisCI.js +++ /dev/null @@ -1,2 +0,0 @@ -const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; -module.exports = isTravisCI; diff --git a/test/isTypedArray/isTypedArray.js b/test/isTypedArray/isTypedArray.js deleted file mode 100644 index 45e44809c..000000000 --- a/test/isTypedArray/isTypedArray.js +++ /dev/null @@ -1,2 +0,0 @@ -const isTypedArray = val => val instanceof TypedArray; -module.exports = isTypedArray; diff --git a/test/isTypedArray/isTypedArray.test.js b/test/isTypedArray/isTypedArray.test.js deleted file mode 100644 index 4264f8835..000000000 --- a/test/isTypedArray/isTypedArray.test.js +++ /dev/null @@ -1,6 +0,0 @@ -const expect = require('expect'); -const isTypedArray = require('./isTypedArray.js'); - -test('isTypedArray is a Function', () => { - expect(isTypedArray).toBeInstanceOf(Function); -}); diff --git a/test/isUndefined/isUndefined.test.js b/test/isUndefined.test.js similarity index 81% rename from test/isUndefined/isUndefined.test.js rename to test/isUndefined.test.js index 60a725190..447b197dd 100644 --- a/test/isUndefined/isUndefined.test.js +++ b/test/isUndefined.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isUndefined = require('./isUndefined.js'); +const {isUndefined} = require('./_30s.js'); test('isUndefined is a Function', () => { expect(isUndefined).toBeInstanceOf(Function); diff --git a/test/isUndefined/isUndefined.js b/test/isUndefined/isUndefined.js deleted file mode 100644 index e0d3d5cee..000000000 --- a/test/isUndefined/isUndefined.js +++ /dev/null @@ -1,2 +0,0 @@ -const isUndefined = val => val === undefined; -module.exports = isUndefined; diff --git a/test/isUpperCase/isUpperCase.test.js b/test/isUpperCase.test.js similarity index 88% rename from test/isUpperCase/isUpperCase.test.js rename to test/isUpperCase.test.js index 0c2aeffa0..3156f9eed 100644 --- a/test/isUpperCase/isUpperCase.test.js +++ b/test/isUpperCase.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isUpperCase = require('./isUpperCase.js'); +const {isUpperCase} = require('./_30s.js'); test('isUpperCase is a Function', () => { expect(isUpperCase).toBeInstanceOf(Function); diff --git a/test/isUpperCase/isUpperCase.js b/test/isUpperCase/isUpperCase.js deleted file mode 100644 index b235dc8d1..000000000 --- a/test/isUpperCase/isUpperCase.js +++ /dev/null @@ -1,2 +0,0 @@ -const isUpperCase = str => str === str.toUpperCase(); -module.exports = isUpperCase; diff --git a/test/isValidJSON/isValidJSON.test.js b/test/isValidJSON.test.js similarity index 90% rename from test/isValidJSON/isValidJSON.test.js rename to test/isValidJSON.test.js index 6426d77ab..e014b697c 100644 --- a/test/isValidJSON/isValidJSON.test.js +++ b/test/isValidJSON.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const isValidJSON = require('./isValidJSON.js'); +const {isValidJSON} = require('./_30s.js'); test('isValidJSON is a Function', () => { expect(isValidJSON).toBeInstanceOf(Function); diff --git a/test/isValidJSON/isValidJSON.js b/test/isValidJSON/isValidJSON.js deleted file mode 100644 index eeeb340e9..000000000 --- a/test/isValidJSON/isValidJSON.js +++ /dev/null @@ -1,9 +0,0 @@ -const isValidJSON = obj => { - try { - JSON.parse(obj); - return true; - } catch (e) { - return false; - } -}; -module.exports = isValidJSON; diff --git a/test/isWeakMap/isWeakMap.js b/test/isWeakMap/isWeakMap.js deleted file mode 100644 index b53b69f5a..000000000 --- a/test/isWeakMap/isWeakMap.js +++ /dev/null @@ -1,2 +0,0 @@ -const isWeakMap = val => val instanceof WeakMap; -module.exports = isWeakMap; diff --git a/test/isWeakMap/isWeakMap.test.js b/test/isWeakMap/isWeakMap.test.js deleted file mode 100644 index 6643677e9..000000000 --- a/test/isWeakMap/isWeakMap.test.js +++ /dev/null @@ -1,6 +0,0 @@ -const expect = require('expect'); -const isWeakMap = require('./isWeakMap.js'); - -test('isWeakMap is a Function', () => { - expect(isWeakMap).toBeInstanceOf(Function); -}); diff --git a/test/isWeakSet/isWeakSet.js b/test/isWeakSet/isWeakSet.js deleted file mode 100644 index c3b55777b..000000000 --- a/test/isWeakSet/isWeakSet.js +++ /dev/null @@ -1,2 +0,0 @@ -const isWeakSet = val => val instanceof WeakSet; -module.exports = isWeakSet; diff --git a/test/isWeakSet/isWeakSet.test.js b/test/isWeakSet/isWeakSet.test.js deleted file mode 100644 index 2466138af..000000000 --- a/test/isWeakSet/isWeakSet.test.js +++ /dev/null @@ -1,6 +0,0 @@ -const expect = require('expect'); -const isWeakSet = require('./isWeakSet.js'); - -test('isWeakSet is a Function', () => { - expect(isWeakSet).toBeInstanceOf(Function); -}); diff --git a/test/isWritableStream/isWritableStream.test.js b/test/isWritableStream.test.js similarity index 68% rename from test/isWritableStream/isWritableStream.test.js rename to test/isWritableStream.test.js index 4ad21eb23..a2ff52297 100644 --- a/test/isWritableStream/isWritableStream.test.js +++ b/test/isWritableStream.test.js @@ -1,16 +1,15 @@ const expect = require('expect'); -const isWritableStream = require('./isWritableStream.js'); -const fs = require('fs'); +const { isWritableStream } = require('./_30s.js'); const Stream = require('stream'); test('isWritableStream is a Function', () => { expect(isWritableStream).toBeInstanceOf(Function); }); test('isWritableStream returns false for read streams', () => { - expect(isWritableStream(fs.createReadStream('isWritableStream.js'))).toBeFalsy(); + expect(isWritableStream(new Stream.Readable())).toBeFalsy(); }); test('isWritableStream returns true for write streams', () => { - expect(isWritableStream(fs.createWriteStream('isWritableStream.js'))).toBeTruthy(); + expect(isWritableStream(new Stream.Writable())).toBeTruthy(); }); test('isWritableStream returns true for duplex streams', () => { expect(isWritableStream(new Stream.Duplex())).toBeTruthy(); diff --git a/test/isWritableStream/isWritableStream.js b/test/isWritableStream/isWritableStream.js deleted file mode 100644 index a9679cc3d..000000000 --- a/test/isWritableStream/isWritableStream.js +++ /dev/null @@ -1,7 +0,0 @@ -const isWritableStream = val => - val !== null && - typeof val === 'object' && - typeof val.pipe === 'function' && - typeof val._write === 'function' && - typeof val._writableState === 'object'; -module.exports = isWritableStream; diff --git a/test/join/join.test.js b/test/join.test.js similarity index 94% rename from test/join/join.test.js rename to test/join.test.js index cb5209563..f8c25a300 100644 --- a/test/join/join.test.js +++ b/test/join.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const join = require('./join.js'); +const {join} = require('./_30s.js'); test('join is a Function', () => { expect(join).toBeInstanceOf(Function); diff --git a/test/join/join.js b/test/join/join.js deleted file mode 100644 index 15d0dd96e..000000000 --- a/test/join/join.js +++ /dev/null @@ -1,11 +0,0 @@ -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, - '' - ); -module.exports = join; diff --git a/test/kmphToMph/kmphToMph.test.js b/test/kmphToMph.test.js similarity index 82% rename from test/kmphToMph/kmphToMph.test.js rename to test/kmphToMph.test.js index 23923c287..2ab2cf007 100644 --- a/test/kmphToMph/kmphToMph.test.js +++ b/test/kmphToMph.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const kmphToMph = require('./kmphToMph.js'); +const {kmphToMph} = require('./_30s.js'); test('kmphToMph is a Function', () => { expect(kmphToMph).toBeInstanceOf(Function); diff --git a/test/kmphToMph/kmphToMph.js b/test/kmphToMph/kmphToMph.js deleted file mode 100644 index 7dc23ac31..000000000 --- a/test/kmphToMph/kmphToMph.js +++ /dev/null @@ -1,2 +0,0 @@ -const kmphToMph = (kmph) => 0.621371192 * kmph; -module.exports = kmphToMph; diff --git a/test/last/last.test.js b/test/last.test.js similarity index 96% rename from test/last/last.test.js rename to test/last.test.js index e86f71ecd..fefc62b16 100644 --- a/test/last/last.test.js +++ b/test/last.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const last = require('./last.js'); +const {last} = require('./_30s.js'); test('last is a Function', () => { expect(last).toBeInstanceOf(Function); diff --git a/test/last/last.js b/test/last/last.js deleted file mode 100644 index 1e1d8a756..000000000 --- a/test/last/last.js +++ /dev/null @@ -1,2 +0,0 @@ -const last = arr => arr[arr.length - 1]; -module.exports = last; diff --git a/test/lcm/lcm.test.js b/test/lcm.test.js similarity index 90% rename from test/lcm/lcm.test.js rename to test/lcm.test.js index dfa340b88..70fcf8230 100644 --- a/test/lcm/lcm.test.js +++ b/test/lcm.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const lcm = require('./lcm.js'); +const {lcm} = require('./_30s.js'); test('lcm is a Function', () => { expect(lcm).toBeInstanceOf(Function); diff --git a/test/lcm/lcm.js b/test/lcm/lcm.js deleted file mode 100644 index a4d8b1032..000000000 --- a/test/lcm/lcm.js +++ /dev/null @@ -1,6 +0,0 @@ -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)); -}; -module.exports = lcm; diff --git a/test/levenshteinDistance/levenshteinDistance.test.js b/test/levenshteinDistance.test.js similarity index 69% rename from test/levenshteinDistance/levenshteinDistance.test.js rename to test/levenshteinDistance.test.js index c5556114d..8a8c5920b 100644 --- a/test/levenshteinDistance/levenshteinDistance.test.js +++ b/test/levenshteinDistance.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const levenshteinDistance = require('./levenshteinDistance.js'); +const {levenshteinDistance} = require('./_30s.js'); test('levenshteinDistance is a Function', () => { expect(levenshteinDistance).toBeInstanceOf(Function); diff --git a/test/levenshteinDistance/levenshteinDistance.js b/test/levenshteinDistance/levenshteinDistance.js deleted file mode 100644 index d9a76b41d..000000000 --- a/test/levenshteinDistance/levenshteinDistance.js +++ /dev/null @@ -1,25 +0,0 @@ -const levenshteinDistance = (string1, string2) => { - if (string1.length === 0) return string2.length; - if (string2.length === 0) return string1.length; - let matrix = Array(string2.length + 1) - .fill(0) - .map((x, i) => [i]); - matrix[0] = Array(string1.length + 1) - .fill(0) - .map((x, i) => i); - for (let i = 1; i <= string2.length; i++) { - for (let j = 1; j <= string1.length; j++) { - if (string2[i - 1] === string1[j - 1]) { - matrix[i][j] = matrix[i - 1][j - 1]; - } else { - matrix[i][j] = Math.min( - matrix[i - 1][j - 1] + 1, - matrix[i][j - 1] + 1, - matrix[i - 1][j] + 1 - ); - } - } - } - return matrix[string2.length][string1.length]; -}; -module.exports = levenshteinDistance; diff --git a/test/longestItem/longestItem.test.js b/test/longestItem.test.js similarity index 95% rename from test/longestItem/longestItem.test.js rename to test/longestItem.test.js index c4315215d..b0a6fc999 100644 --- a/test/longestItem/longestItem.test.js +++ b/test/longestItem.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const longestItem = require('./longestItem.js'); +const {longestItem} = require('./_30s.js'); test('longestItem is a Function', () => { expect(longestItem).toBeInstanceOf(Function); diff --git a/test/longestItem/longestItem.js b/test/longestItem/longestItem.js deleted file mode 100644 index 3bfe6d8d3..000000000 --- a/test/longestItem/longestItem.js +++ /dev/null @@ -1,3 +0,0 @@ -const longestItem = (val, ...vals) => - [val, ...vals].reduce((a, x) => (x.length > a.length ? x : a)); -module.exports = longestItem; diff --git a/test/lowercaseKeys/lowercaseKeys.test.js b/test/lowercaseKeys.test.js similarity index 89% rename from test/lowercaseKeys/lowercaseKeys.test.js rename to test/lowercaseKeys.test.js index 8fee98446..ec991a352 100644 --- a/test/lowercaseKeys/lowercaseKeys.test.js +++ b/test/lowercaseKeys.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const lowercaseKeys = require('./lowercaseKeys.js'); +const {lowercaseKeys} = require('./_30s.js'); test('lowercaseKeys is a Function', () => { expect(lowercaseKeys).toBeInstanceOf(Function); diff --git a/test/lowercaseKeys/lowercaseKeys.js b/test/lowercaseKeys/lowercaseKeys.js deleted file mode 100644 index 235a0d5d8..000000000 --- a/test/lowercaseKeys/lowercaseKeys.js +++ /dev/null @@ -1,6 +0,0 @@ -const lowercaseKeys = obj => - Object.keys(obj).reduce((acc, key) => { - acc[key.toLowerCase()] = obj[key]; - return acc; - }, {}); -module.exports = lowercaseKeys; diff --git a/test/luhnCheck/luhnCheck.test.js b/test/luhnCheck.test.js similarity index 90% rename from test/luhnCheck/luhnCheck.test.js rename to test/luhnCheck.test.js index 28d176fe5..75e4a0daf 100644 --- a/test/luhnCheck/luhnCheck.test.js +++ b/test/luhnCheck.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const luhnCheck = require('./luhnCheck.js'); +const {luhnCheck} = require('./_30s.js'); test('luhnCheck is a Function', () => { expect(luhnCheck).toBeInstanceOf(Function); diff --git a/test/luhnCheck/luhnCheck.js b/test/luhnCheck/luhnCheck.js deleted file mode 100644 index d666a021a..000000000 --- a/test/luhnCheck/luhnCheck.js +++ /dev/null @@ -1,11 +0,0 @@ -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; -}; -module.exports = luhnCheck; diff --git a/test/mapKeys/mapKeys.test.js b/test/mapKeys.test.js similarity index 85% rename from test/mapKeys/mapKeys.test.js rename to test/mapKeys.test.js index 076f1fabe..aa3136f13 100644 --- a/test/mapKeys/mapKeys.test.js +++ b/test/mapKeys.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const mapKeys = require('./mapKeys.js'); +const {mapKeys} = require('./_30s.js'); test('mapKeys is a Function', () => { expect(mapKeys).toBeInstanceOf(Function); diff --git a/test/mapKeys/mapKeys.js b/test/mapKeys/mapKeys.js deleted file mode 100644 index fcafd2ff4..000000000 --- a/test/mapKeys/mapKeys.js +++ /dev/null @@ -1,6 +0,0 @@ -const mapKeys = (obj, fn) => - Object.keys(obj).reduce((acc, k) => { - acc[fn(obj[k], k, obj)] = obj[k]; - return acc; - }, {}); -module.exports = mapKeys; diff --git a/test/mapObject/mapObject.test.js b/test/mapObject.test.js similarity index 93% rename from test/mapObject/mapObject.test.js rename to test/mapObject.test.js index 86d5cf698..c9ffa673b 100644 --- a/test/mapObject/mapObject.test.js +++ b/test/mapObject.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const mapObject = require('./mapObject.js'); +const {mapObject} = require('./_30s.js'); test('mapObject is a Function', () => { expect(mapObject).toBeInstanceOf(Function); diff --git a/test/mapObject/mapObject.js b/test/mapObject/mapObject.js deleted file mode 100644 index 84710c299..000000000 --- a/test/mapObject/mapObject.js +++ /dev/null @@ -1,5 +0,0 @@ -const mapObject = (arr, fn) => - (a => ( - (a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {}) - ))(); -module.exports = mapObject; diff --git a/test/mapString/mapString.test.js b/test/mapString.test.js similarity index 93% rename from test/mapString/mapString.test.js rename to test/mapString.test.js index 9e400d095..a30444fbf 100644 --- a/test/mapString/mapString.test.js +++ b/test/mapString.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const mapString = require('./mapString.js'); +const {mapString} = require('./_30s.js'); test('mapString is a Function', () => { expect(mapString).toBeInstanceOf(Function); diff --git a/test/mapString/mapString.js b/test/mapString/mapString.js deleted file mode 100644 index b186c81ff..000000000 --- a/test/mapString/mapString.js +++ /dev/null @@ -1,6 +0,0 @@ -const mapString = (str, fn) => - str - .split('') - .map((c, i) => fn(c, i, str)) - .join(''); -module.exports = mapString; diff --git a/test/mapValues/mapValues.test.js b/test/mapValues.test.js similarity index 87% rename from test/mapValues/mapValues.test.js rename to test/mapValues.test.js index 24273703c..5b92ae3fd 100644 --- a/test/mapValues/mapValues.test.js +++ b/test/mapValues.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const mapValues = require('./mapValues.js'); +const {mapValues} = require('./_30s.js'); test('mapValues is a Function', () => { expect(mapValues).toBeInstanceOf(Function); diff --git a/test/mapValues/mapValues.js b/test/mapValues/mapValues.js deleted file mode 100644 index b278d0d15..000000000 --- a/test/mapValues/mapValues.js +++ /dev/null @@ -1,6 +0,0 @@ -const mapValues = (obj, fn) => - Object.keys(obj).reduce((acc, k) => { - acc[k] = fn(obj[k], k, obj); - return acc; - }, {}); -module.exports = mapValues; diff --git a/test/mask/mask.test.js b/test/mask.test.js similarity index 93% rename from test/mask/mask.test.js rename to test/mask.test.js index 11c8e4cb5..1080c0ee8 100644 --- a/test/mask/mask.test.js +++ b/test/mask.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const mask = require('./mask.js'); +const {mask} = require('./_30s.js'); test('mask is a Function', () => { expect(mask).toBeInstanceOf(Function); diff --git a/test/mask/mask.js b/test/mask/mask.js deleted file mode 100644 index a268b3710..000000000 --- a/test/mask/mask.js +++ /dev/null @@ -1,2 +0,0 @@ -const mask = (cc, num = 4, mask = '*') => `${cc}`.slice(-num).padStart(`${cc}`.length, mask); -module.exports = mask; diff --git a/test/matches/matches.test.js b/test/matches.test.js similarity index 92% rename from test/matches/matches.test.js rename to test/matches.test.js index 58f07dd9c..2a406e274 100644 --- a/test/matches/matches.test.js +++ b/test/matches.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const matches = require('./matches.js'); +const {matches} = require('./_30s.js'); test('matches is a Function', () => { expect(matches).toBeInstanceOf(Function); diff --git a/test/matches/matches.js b/test/matches/matches.js deleted file mode 100644 index cc354fb57..000000000 --- a/test/matches/matches.js +++ /dev/null @@ -1,3 +0,0 @@ -const matches = (obj, source) => - Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]); -module.exports = matches; diff --git a/test/matchesWith/matchesWith.test.js b/test/matchesWith.test.js similarity index 89% rename from test/matchesWith/matchesWith.test.js rename to test/matchesWith.test.js index 5627ae2af..ee1e6b1ea 100644 --- a/test/matchesWith/matchesWith.test.js +++ b/test/matchesWith.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const matchesWith = require('./matchesWith.js'); +const {matchesWith} = require('./_30s.js'); test('matchesWith is a Function', () => { expect(matchesWith).toBeInstanceOf(Function); diff --git a/test/matchesWith/matchesWith.js b/test/matchesWith/matchesWith.js deleted file mode 100644 index 9f3b5ee34..000000000 --- a/test/matchesWith/matchesWith.js +++ /dev/null @@ -1,8 +0,0 @@ -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] - ); -module.exports = matchesWith; diff --git a/test/maxBy/maxBy.test.js b/test/maxBy.test.js similarity index 91% rename from test/maxBy/maxBy.test.js rename to test/maxBy.test.js index 2cd581553..3b805dea6 100644 --- a/test/maxBy/maxBy.test.js +++ b/test/maxBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const maxBy = require('./maxBy.js'); +const {maxBy} = require('./_30s.js'); test('maxBy is a Function', () => { expect(maxBy).toBeInstanceOf(Function); diff --git a/test/maxBy/maxBy.js b/test/maxBy/maxBy.js deleted file mode 100644 index f549f0e80..000000000 --- a/test/maxBy/maxBy.js +++ /dev/null @@ -1,2 +0,0 @@ -const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); -module.exports = maxBy; diff --git a/test/maxDate/maxDate.test.js b/test/maxDate.test.js similarity index 89% rename from test/maxDate/maxDate.test.js rename to test/maxDate.test.js index e7d6ae60c..0bfcd0a1a 100644 --- a/test/maxDate/maxDate.test.js +++ b/test/maxDate.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const maxDate = require('./maxDate.js'); +const {maxDate} = require('./_30s.js'); test('maxDate is a Function', () => { expect(maxDate).toBeInstanceOf(Function); diff --git a/test/maxDate/maxDate.js b/test/maxDate/maxDate.js deleted file mode 100644 index b2413c849..000000000 --- a/test/maxDate/maxDate.js +++ /dev/null @@ -1,2 +0,0 @@ -const maxDate = (...dates) => new Date(Math.max.apply(null, ...dates)); -module.exports = maxDate; diff --git a/test/maxN/maxN.test.js b/test/maxN.test.js similarity index 90% rename from test/maxN/maxN.test.js rename to test/maxN.test.js index dc100b2f7..6a866f8c4 100644 --- a/test/maxN/maxN.test.js +++ b/test/maxN.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const maxN = require('./maxN.js'); +const {maxN} = require('./_30s.js'); test('maxN is a Function', () => { expect(maxN).toBeInstanceOf(Function); diff --git a/test/maxN/maxN.js b/test/maxN/maxN.js deleted file mode 100644 index 7663fb20e..000000000 --- a/test/maxN/maxN.js +++ /dev/null @@ -1,2 +0,0 @@ -const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n); -module.exports = maxN; diff --git a/test/median/median.test.js b/test/median.test.js similarity index 89% rename from test/median/median.test.js rename to test/median.test.js index 76835c0b8..0a62f30c0 100644 --- a/test/median/median.test.js +++ b/test/median.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const median = require('./median.js'); +const {median} = require('./_30s.js'); test('median is a Function', () => { expect(median).toBeInstanceOf(Function); diff --git a/test/median/median.js b/test/median/median.js deleted file mode 100644 index 6c48900c3..000000000 --- a/test/median/median.js +++ /dev/null @@ -1,6 +0,0 @@ -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; -}; -module.exports = median; diff --git a/test/memoize/memoize.test.js b/test/memoize.test.js similarity index 91% rename from test/memoize/memoize.test.js rename to test/memoize.test.js index b288861d3..fd906727b 100644 --- a/test/memoize/memoize.test.js +++ b/test/memoize.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const memoize = require('./memoize.js'); +const {memoize} = require('./_30s.js'); test('memoize is a Function', () => { expect(memoize).toBeInstanceOf(Function); diff --git a/test/memoize/memoize.js b/test/memoize/memoize.js deleted file mode 100644 index 53cb2d5eb..000000000 --- a/test/memoize/memoize.js +++ /dev/null @@ -1,9 +0,0 @@ -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; -}; -module.exports = memoize; diff --git a/test/merge/merge.test.js b/test/merge.test.js similarity index 91% rename from test/merge/merge.test.js rename to test/merge.test.js index 635966c14..035b3b722 100644 --- a/test/merge/merge.test.js +++ b/test/merge.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const merge = require('./merge.js'); +const {merge} = require('./_30s.js'); test('merge is a Function', () => { expect(merge).toBeInstanceOf(Function); diff --git a/test/merge/merge.js b/test/merge/merge.js deleted file mode 100644 index 91d1355c6..000000000 --- a/test/merge/merge.js +++ /dev/null @@ -1,10 +0,0 @@ -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; - }, {}), - {} - ); -module.exports = merge; diff --git a/test/minBy/minBy.test.js b/test/minBy.test.js similarity index 91% rename from test/minBy/minBy.test.js rename to test/minBy.test.js index 82a1beeed..2c4c4a641 100644 --- a/test/minBy/minBy.test.js +++ b/test/minBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const minBy = require('./minBy.js'); +const {minBy} = require('./_30s.js'); test('minBy is a Function', () => { expect(minBy).toBeInstanceOf(Function); diff --git a/test/minBy/minBy.js b/test/minBy/minBy.js deleted file mode 100644 index 7318d7901..000000000 --- a/test/minBy/minBy.js +++ /dev/null @@ -1,2 +0,0 @@ -const minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); -module.exports = minBy; diff --git a/test/minDate/minDate.test.js b/test/minDate.test.js similarity index 89% rename from test/minDate/minDate.test.js rename to test/minDate.test.js index 7156eb98b..21154eb7d 100644 --- a/test/minDate/minDate.test.js +++ b/test/minDate.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const minDate = require('./minDate.js'); +const {minDate} = require('./_30s.js'); test('minDate is a Function', () => { expect(minDate).toBeInstanceOf(Function); diff --git a/test/minDate/minDate.js b/test/minDate/minDate.js deleted file mode 100644 index a740098ed..000000000 --- a/test/minDate/minDate.js +++ /dev/null @@ -1,2 +0,0 @@ -const minDate = (...dates) => new Date(Math.min.apply(null, ...dates)); -module.exports = minDate; diff --git a/test/minN/minN.test.js b/test/minN.test.js similarity index 90% rename from test/minN/minN.test.js rename to test/minN.test.js index ac8fc29a9..5721f0350 100644 --- a/test/minN/minN.test.js +++ b/test/minN.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const minN = require('./minN.js'); +const {minN} = require('./_30s.js'); test('minN is a Function', () => { expect(minN).toBeInstanceOf(Function); diff --git a/test/minN/minN.js b/test/minN/minN.js deleted file mode 100644 index fd0f0e95a..000000000 --- a/test/minN/minN.js +++ /dev/null @@ -1,2 +0,0 @@ -const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n); -module.exports = minN; diff --git a/test/mostPerformant/mostPerformant.test.js b/test/mostPerformant.test.js similarity index 71% rename from test/mostPerformant/mostPerformant.test.js rename to test/mostPerformant.test.js index 877fcdfa8..28f2b46dd 100644 --- a/test/mostPerformant/mostPerformant.test.js +++ b/test/mostPerformant.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const mostPerformant = require('./mostPerformant.js'); +const {mostPerformant} = require('./_30s.js'); test('mostPerformant is a Function', () => { expect(mostPerformant).toBeInstanceOf(Function); diff --git a/test/mostPerformant/mostPerformant.js b/test/mostPerformant/mostPerformant.js deleted file mode 100644 index ffeb69cba..000000000 --- a/test/mostPerformant/mostPerformant.js +++ /dev/null @@ -1,9 +0,0 @@ -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)); -}; -module.exports = mostPerformant; diff --git a/test/mphToKmph/mphToKmph.test.js b/test/mphToKmph.test.js similarity index 82% rename from test/mphToKmph/mphToKmph.test.js rename to test/mphToKmph.test.js index f5a229623..626d96e28 100644 --- a/test/mphToKmph/mphToKmph.test.js +++ b/test/mphToKmph.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const mphToKmph = require('./mphToKmph.js'); +const {mphToKmph} = require('./_30s.js'); test('mphToKmph is a Function', () => { expect(mphToKmph).toBeInstanceOf(Function); diff --git a/test/mphToKmph/mphToKmph.js b/test/mphToKmph/mphToKmph.js deleted file mode 100644 index d4190a376..000000000 --- a/test/mphToKmph/mphToKmph.js +++ /dev/null @@ -1,2 +0,0 @@ -const mphToKmph = (mph) => 1.6093440006146922 * mph; -module.exports = mphToKmph; diff --git a/test/negate/negate.test.js b/test/negate.test.js similarity index 86% rename from test/negate/negate.test.js rename to test/negate.test.js index 7dfd8b080..82fe26a3e 100644 --- a/test/negate/negate.test.js +++ b/test/negate.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const negate = require('./negate.js'); +const {negate} = require('./_30s.js'); test('negate is a Function', () => { expect(negate).toBeInstanceOf(Function); diff --git a/test/negate/negate.js b/test/negate/negate.js deleted file mode 100644 index cf8436528..000000000 --- a/test/negate/negate.js +++ /dev/null @@ -1,2 +0,0 @@ -const negate = func => (...args) => !func(...args); -module.exports = negate; diff --git a/test/nest/nest.test.js b/test/nest.test.js similarity index 75% rename from test/nest/nest.test.js rename to test/nest.test.js index 894a17001..c06b9f6bd 100644 --- a/test/nest/nest.test.js +++ b/test/nest.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const nest = require('./nest.js'); +const {nest} = require('./_30s.js'); test('nest is a Function', () => { expect(nest).toBeInstanceOf(Function); diff --git a/test/nest/nest.js b/test/nest/nest.js deleted file mode 100644 index 4585b8bda..000000000 --- a/test/nest/nest.js +++ /dev/null @@ -1,5 +0,0 @@ -const nest = (items, id = null, link = 'parent_id') => - items - .filter(item => item[link] === id) - .map(item => ({ ...item, children: nest(items, item.id) })); -module.exports = nest; diff --git a/test/nodeListToArray/nodeListToArray.test.js b/test/nodeListToArray.test.js similarity index 70% rename from test/nodeListToArray/nodeListToArray.test.js rename to test/nodeListToArray.test.js index 414565976..b775d168a 100644 --- a/test/nodeListToArray/nodeListToArray.test.js +++ b/test/nodeListToArray.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const nodeListToArray = require('./nodeListToArray.js'); +const {nodeListToArray} = require('./_30s.js'); test('nodeListToArray is a Function', () => { expect(nodeListToArray).toBeInstanceOf(Function); diff --git a/test/nodeListToArray/nodeListToArray.js b/test/nodeListToArray/nodeListToArray.js deleted file mode 100644 index 2fc92fad0..000000000 --- a/test/nodeListToArray/nodeListToArray.js +++ /dev/null @@ -1,2 +0,0 @@ -const nodeListToArray = nodeList => [...nodeList]; -module.exports = nodeListToArray; diff --git a/test/none/none.test.js b/test/none.test.js similarity index 93% rename from test/none/none.test.js rename to test/none.test.js index fcc6c904c..87b53f48b 100644 --- a/test/none/none.test.js +++ b/test/none.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const none = require('./none.js'); +const {none} = require('./_30s.js'); test('none is a Function', () => { expect(none).toBeInstanceOf(Function); diff --git a/test/none/none.js b/test/none/none.js deleted file mode 100644 index a36445848..000000000 --- a/test/none/none.js +++ /dev/null @@ -1,2 +0,0 @@ -const none = (arr, fn = Boolean) => !arr.some(fn); -module.exports = none; diff --git a/test/nthArg/nthArg.test.js b/test/nthArg.test.js similarity index 91% rename from test/nthArg/nthArg.test.js rename to test/nthArg.test.js index b5689e24a..68a24f923 100644 --- a/test/nthArg/nthArg.test.js +++ b/test/nthArg.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const nthArg = require('./nthArg.js'); +const {nthArg} = require('./_30s.js'); test('nthArg is a Function', () => { expect(nthArg).toBeInstanceOf(Function); diff --git a/test/nthArg/nthArg.js b/test/nthArg/nthArg.js deleted file mode 100644 index cf2497e04..000000000 --- a/test/nthArg/nthArg.js +++ /dev/null @@ -1,2 +0,0 @@ -const nthArg = n => (...args) => args.slice(n)[0]; -module.exports = nthArg; diff --git a/test/nthElement/nthElement.test.js b/test/nthElement.test.js similarity index 88% rename from test/nthElement/nthElement.test.js rename to test/nthElement.test.js index 774de6f78..f17937e0f 100644 --- a/test/nthElement/nthElement.test.js +++ b/test/nthElement.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const nthElement = require('./nthElement.js'); +const {nthElement} = require('./_30s.js'); test('nthElement is a Function', () => { expect(nthElement).toBeInstanceOf(Function); diff --git a/test/nthElement/nthElement.js b/test/nthElement/nthElement.js deleted file mode 100644 index c9c0ffe21..000000000 --- a/test/nthElement/nthElement.js +++ /dev/null @@ -1,2 +0,0 @@ -const nthElement = (arr, n = 0) => (n === -1 ? arr.slice(n) : arr.slice(n, n + 1))[0]; -module.exports = nthElement; diff --git a/test/objectFromPairs/objectFromPairs.test.js b/test/objectFromPairs.test.js similarity index 83% rename from test/objectFromPairs/objectFromPairs.test.js rename to test/objectFromPairs.test.js index fcb9e8c6a..58e55b50d 100644 --- a/test/objectFromPairs/objectFromPairs.test.js +++ b/test/objectFromPairs.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const objectFromPairs = require('./objectFromPairs.js'); +const {objectFromPairs} = require('./_30s.js'); test('objectFromPairs is a Function', () => { expect(objectFromPairs).toBeInstanceOf(Function); diff --git a/test/objectFromPairs/objectFromPairs.js b/test/objectFromPairs/objectFromPairs.js deleted file mode 100644 index 6d27ccf4f..000000000 --- a/test/objectFromPairs/objectFromPairs.js +++ /dev/null @@ -1,2 +0,0 @@ -const objectFromPairs = arr => arr.reduce((a, [key, val]) => ((a[key] = val), a), {}); -module.exports = objectFromPairs; diff --git a/test/objectToPairs/objectToPairs.test.js b/test/objectToPairs.test.js similarity index 84% rename from test/objectToPairs/objectToPairs.test.js rename to test/objectToPairs.test.js index da2dd0c5f..c49dd39db 100644 --- a/test/objectToPairs/objectToPairs.test.js +++ b/test/objectToPairs.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const objectToPairs = require('./objectToPairs.js'); +const {objectToPairs} = require('./_30s.js'); test('objectToPairs is a Function', () => { expect(objectToPairs).toBeInstanceOf(Function); diff --git a/test/objectToPairs/objectToPairs.js b/test/objectToPairs/objectToPairs.js deleted file mode 100644 index e17645c30..000000000 --- a/test/objectToPairs/objectToPairs.js +++ /dev/null @@ -1,2 +0,0 @@ -const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]); -module.exports = objectToPairs; diff --git a/test/observeMutations/observeMutations.test.js b/test/observeMutations.test.js similarity index 70% rename from test/observeMutations/observeMutations.test.js rename to test/observeMutations.test.js index 314cdf633..0eb713695 100644 --- a/test/observeMutations/observeMutations.test.js +++ b/test/observeMutations.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const observeMutations = require('./observeMutations.js'); +const {observeMutations} = require('./_30s.js'); test('observeMutations is a Function', () => { expect(observeMutations).toBeInstanceOf(Function); diff --git a/test/observeMutations/observeMutations.js b/test/observeMutations/observeMutations.js deleted file mode 100644 index fd2a7f31a..000000000 --- a/test/observeMutations/observeMutations.js +++ /dev/null @@ -1,19 +0,0 @@ -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; -}; -module.exports = observeMutations; diff --git a/test/off/off.test.js b/test/off.test.js similarity index 75% rename from test/off/off.test.js rename to test/off.test.js index 59b87132d..0da5e9d94 100644 --- a/test/off/off.test.js +++ b/test/off.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const off = require('./off.js'); +const {off} = require('./_30s.js'); test('off is a Function', () => { expect(off).toBeInstanceOf(Function); diff --git a/test/off/off.js b/test/off/off.js deleted file mode 100644 index fa1ae6ec3..000000000 --- a/test/off/off.js +++ /dev/null @@ -1,2 +0,0 @@ -const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts); -module.exports = off; diff --git a/test/offset/offset.test.js b/test/offset.test.js similarity index 95% rename from test/offset/offset.test.js rename to test/offset.test.js index 73ee2fe04..2d6cd932a 100644 --- a/test/offset/offset.test.js +++ b/test/offset.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const offset = require('./offset.js'); +const {offset} = require('./_30s.js'); test('offset is a Function', () => { expect(offset).toBeInstanceOf(Function); diff --git a/test/offset/offset.js b/test/offset/offset.js deleted file mode 100644 index c20b1fe4c..000000000 --- a/test/offset/offset.js +++ /dev/null @@ -1,2 +0,0 @@ -const offset = (arr, offset) => [...arr.slice(offset), ...arr.slice(0, offset)]; -module.exports = offset; diff --git a/test/omit/omit.test.js b/test/omit.test.js similarity index 88% rename from test/omit/omit.test.js rename to test/omit.test.js index 05200cff3..766037a7f 100644 --- a/test/omit/omit.test.js +++ b/test/omit.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const omit = require('./omit.js'); +const {omit} = require('./_30s.js'); test('omit is a Function', () => { expect(omit).toBeInstanceOf(Function); diff --git a/test/omit/omit.js b/test/omit/omit.js deleted file mode 100644 index e443a6ef3..000000000 --- a/test/omit/omit.js +++ /dev/null @@ -1,5 +0,0 @@ -const omit = (obj, arr) => - Object.keys(obj) - .filter(k => !arr.includes(k)) - .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); -module.exports = omit; diff --git a/test/omitBy/omitBy.test.js b/test/omitBy.test.js similarity index 88% rename from test/omitBy/omitBy.test.js rename to test/omitBy.test.js index 3d433f904..467606dfc 100644 --- a/test/omitBy/omitBy.test.js +++ b/test/omitBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const omitBy = require('./omitBy.js'); +const {omitBy} = require('./_30s.js'); test('omitBy is a Function', () => { expect(omitBy).toBeInstanceOf(Function); diff --git a/test/omitBy/omitBy.js b/test/omitBy/omitBy.js deleted file mode 100644 index 297c51593..000000000 --- a/test/omitBy/omitBy.js +++ /dev/null @@ -1,5 +0,0 @@ -const omitBy = (obj, fn) => - Object.keys(obj) - .filter(k => !fn(obj[k], k)) - .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); -module.exports = omitBy; diff --git a/test/on/on.test.js b/test/on.test.js similarity index 76% rename from test/on/on.test.js rename to test/on.test.js index 8c1912742..c757e9592 100644 --- a/test/on/on.test.js +++ b/test/on.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const on = require('./on.js'); +const {on} = require('./_30s.js'); test('on is a Function', () => { expect(on).toBeInstanceOf(Function); diff --git a/test/on/on.js b/test/on/on.js deleted file mode 100644 index 5797671c9..000000000 --- a/test/on/on.js +++ /dev/null @@ -1,6 +0,0 @@ -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; -}; -module.exports = on; diff --git a/test/onUserInputChange/onUserInputChange.test.js b/test/onUserInputChange.test.js similarity index 69% rename from test/onUserInputChange/onUserInputChange.test.js rename to test/onUserInputChange.test.js index 675143979..c0ac171a9 100644 --- a/test/onUserInputChange/onUserInputChange.test.js +++ b/test/onUserInputChange.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const onUserInputChange = require('./onUserInputChange.js'); +const {onUserInputChange} = require('./_30s.js'); test('onUserInputChange is a Function', () => { expect(onUserInputChange).toBeInstanceOf(Function); diff --git a/test/onUserInputChange/onUserInputChange.js b/test/onUserInputChange/onUserInputChange.js deleted file mode 100644 index 2e18d25f2..000000000 --- a/test/onUserInputChange/onUserInputChange.js +++ /dev/null @@ -1,15 +0,0 @@ -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); - }); -}; -module.exports = onUserInputChange; diff --git a/test/once/once.test.js b/test/once.test.js similarity index 75% rename from test/once/once.test.js rename to test/once.test.js index ecd7ed6f0..04c07b340 100644 --- a/test/once/once.test.js +++ b/test/once.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const once = require('./once.js'); +const {once} = require('./_30s.js'); test('once is a Function', () => { expect(once).toBeInstanceOf(Function); diff --git a/test/once/once.js b/test/once/once.js deleted file mode 100644 index 3854d57c1..000000000 --- a/test/once/once.js +++ /dev/null @@ -1,9 +0,0 @@ -const once = fn => { - let called = false; - return function(...args) { - if (called) return; - called = true; - return fn.apply(this, args); - }; -}; -module.exports = once; diff --git a/test/orderBy/orderBy.test.js b/test/orderBy.test.js similarity index 94% rename from test/orderBy/orderBy.test.js rename to test/orderBy.test.js index 119950376..74b7e61c5 100644 --- a/test/orderBy/orderBy.test.js +++ b/test/orderBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const orderBy = require('./orderBy.js'); +const {orderBy} = require('./_30s.js'); test('orderBy is a Function', () => { expect(orderBy).toBeInstanceOf(Function); diff --git a/test/orderBy/orderBy.js b/test/orderBy/orderBy.js deleted file mode 100644 index a950b7af9..000000000 --- a/test/orderBy/orderBy.js +++ /dev/null @@ -1,11 +0,0 @@ -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) - ); -module.exports = orderBy; diff --git a/test/over/over.test.js b/test/over.test.js similarity index 88% rename from test/over/over.test.js rename to test/over.test.js index f4b7dd578..adb0c1918 100644 --- a/test/over/over.test.js +++ b/test/over.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const over = require('./over.js'); +const {over} = require('./_30s.js'); test('over is a Function', () => { expect(over).toBeInstanceOf(Function); diff --git a/test/over/over.js b/test/over/over.js deleted file mode 100644 index 304afe4cd..000000000 --- a/test/over/over.js +++ /dev/null @@ -1,2 +0,0 @@ -const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args)); -module.exports = over; diff --git a/test/overArgs/overArgs.test.js b/test/overArgs.test.js similarity index 89% rename from test/overArgs/overArgs.test.js rename to test/overArgs.test.js index 2025c109c..87162bba8 100644 --- a/test/overArgs/overArgs.test.js +++ b/test/overArgs.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const overArgs = require('./overArgs.js'); +const {overArgs} = require('./_30s.js'); test('overArgs is a Function', () => { expect(overArgs).toBeInstanceOf(Function); diff --git a/test/overArgs/overArgs.js b/test/overArgs/overArgs.js deleted file mode 100644 index 8f832de7a..000000000 --- a/test/overArgs/overArgs.js +++ /dev/null @@ -1,2 +0,0 @@ -const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val))); -module.exports = overArgs; diff --git a/test/pad/pad.test.js b/test/pad.test.js similarity index 93% rename from test/pad/pad.test.js rename to test/pad.test.js index d01e4a983..4070553ba 100644 --- a/test/pad/pad.test.js +++ b/test/pad.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const pad = require('./pad.js'); +const {pad} = require('./_30s.js'); test('pad is a Function', () => { expect(pad).toBeInstanceOf(Function); diff --git a/test/pad/pad.js b/test/pad/pad.js deleted file mode 100644 index 70aac13ed..000000000 --- a/test/pad/pad.js +++ /dev/null @@ -1,3 +0,0 @@ -const pad = (str, length, char = ' ') => - str.padStart((str.length + length) / 2, char).padEnd(length, char); -module.exports = pad; diff --git a/test/palindrome/palindrome.test.js b/test/palindrome.test.js similarity index 87% rename from test/palindrome/palindrome.test.js rename to test/palindrome.test.js index ae174bbec..834cc89b7 100644 --- a/test/palindrome/palindrome.test.js +++ b/test/palindrome.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const palindrome = require('./palindrome.js'); +const {palindrome} = require('./_30s.js'); test('palindrome is a Function', () => { expect(palindrome).toBeInstanceOf(Function); diff --git a/test/palindrome/palindrome.js b/test/palindrome/palindrome.js deleted file mode 100644 index 479292b4c..000000000 --- a/test/palindrome/palindrome.js +++ /dev/null @@ -1,5 +0,0 @@ -const palindrome = str => { - const s = str.toLowerCase().replace(/[\W_]/g, ''); - return s === [...s].reverse().join(''); -}; -module.exports = palindrome; diff --git a/test/parseCookie/parseCookie.test.js b/test/parseCookie.test.js similarity index 84% rename from test/parseCookie/parseCookie.test.js rename to test/parseCookie.test.js index 42e942538..536301992 100644 --- a/test/parseCookie/parseCookie.test.js +++ b/test/parseCookie.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const parseCookie = require('./parseCookie.js'); +const {parseCookie} = require('./_30s.js'); test('parseCookie is a Function', () => { expect(parseCookie).toBeInstanceOf(Function); diff --git a/test/parseCookie/parseCookie.js b/test/parseCookie/parseCookie.js deleted file mode 100644 index 6e9cc957a..000000000 --- a/test/parseCookie/parseCookie.js +++ /dev/null @@ -1,9 +0,0 @@ -const parseCookie = str => - str - .split(';') - .map(v => v.split('=')) - .reduce((acc, v) => { - acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim()); - return acc; - }, {}); -module.exports = parseCookie; diff --git a/test/partial/partial.test.js b/test/partial.test.js similarity index 88% rename from test/partial/partial.test.js rename to test/partial.test.js index 5b3fd8f2b..0cd4687b9 100644 --- a/test/partial/partial.test.js +++ b/test/partial.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const partial = require('./partial.js'); +const {partial} = require('./_30s.js'); test('partial is a Function', () => { expect(partial).toBeInstanceOf(Function); diff --git a/test/partial/partial.js b/test/partial/partial.js deleted file mode 100644 index 9b18c7a61..000000000 --- a/test/partial/partial.js +++ /dev/null @@ -1,2 +0,0 @@ -const partial = (fn, ...partials) => (...args) => fn(...partials, ...args); -module.exports = partial; diff --git a/test/partialRight/partialRight.test.js b/test/partialRight.test.js similarity index 86% rename from test/partialRight/partialRight.test.js rename to test/partialRight.test.js index 7e04a83ba..9f825f91d 100644 --- a/test/partialRight/partialRight.test.js +++ b/test/partialRight.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const partialRight = require('./partialRight.js'); +const {partialRight} = require('./_30s.js'); test('partialRight is a Function', () => { expect(partialRight).toBeInstanceOf(Function); diff --git a/test/partialRight/partialRight.js b/test/partialRight/partialRight.js deleted file mode 100644 index e8e956e72..000000000 --- a/test/partialRight/partialRight.js +++ /dev/null @@ -1,2 +0,0 @@ -const partialRight = (fn, ...partials) => (...args) => fn(...args, ...partials); -module.exports = partialRight; diff --git a/test/partition/partition.test.js b/test/partition.test.js similarity index 91% rename from test/partition/partition.test.js rename to test/partition.test.js index d86d95124..c2844264d 100644 --- a/test/partition/partition.test.js +++ b/test/partition.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const partition = require('./partition.js'); +const {partition} = require('./_30s.js'); test('partition is a Function', () => { expect(partition).toBeInstanceOf(Function); diff --git a/test/partition/partition.js b/test/partition/partition.js deleted file mode 100644 index 754a9104c..000000000 --- a/test/partition/partition.js +++ /dev/null @@ -1,9 +0,0 @@ -const partition = (arr, fn) => - arr.reduce( - (acc, val, i, arr) => { - acc[fn(val, i, arr) ? 0 : 1].push(val); - return acc; - }, - [[], []] - ); -module.exports = partition; diff --git a/test/percentile/percentile.test.js b/test/percentile.test.js similarity index 87% rename from test/percentile/percentile.test.js rename to test/percentile.test.js index 689c1be26..22affd750 100644 --- a/test/percentile/percentile.test.js +++ b/test/percentile.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const percentile = require('./percentile.js'); +const {percentile} = require('./_30s.js'); test('percentile is a Function', () => { expect(percentile).toBeInstanceOf(Function); diff --git a/test/percentile/percentile.js b/test/percentile/percentile.js deleted file mode 100644 index 07669d78b..000000000 --- a/test/percentile/percentile.js +++ /dev/null @@ -1,3 +0,0 @@ -const percentile = (arr, val) => - (100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0)) / arr.length; -module.exports = percentile; diff --git a/test/permutations/permutations.test.js b/test/permutations.test.js similarity index 86% rename from test/permutations/permutations.test.js rename to test/permutations.test.js index d7c085a7f..f0d8764ab 100644 --- a/test/permutations/permutations.test.js +++ b/test/permutations.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const permutations = require('./permutations.js'); +const {permutations} = require('./_30s.js'); test('permutations is a Function', () => { expect(permutations).toBeInstanceOf(Function); diff --git a/test/permutations/permutations.js b/test/permutations/permutations.js deleted file mode 100644 index 69a31471c..000000000 --- a/test/permutations/permutations.js +++ /dev/null @@ -1,11 +0,0 @@ -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]) - ), - [] - ); -}; -module.exports = permutations; diff --git a/test/pick/pick.test.js b/test/pick.test.js similarity index 88% rename from test/pick/pick.test.js rename to test/pick.test.js index 08cac4fe2..248df1054 100644 --- a/test/pick/pick.test.js +++ b/test/pick.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const pick = require('./pick.js'); +const {pick} = require('./_30s.js'); test('pick is a Function', () => { expect(pick).toBeInstanceOf(Function); diff --git a/test/pick/pick.js b/test/pick/pick.js deleted file mode 100644 index 5b7b72ca6..000000000 --- a/test/pick/pick.js +++ /dev/null @@ -1,3 +0,0 @@ -const pick = (obj, arr) => - arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {}); -module.exports = pick; diff --git a/test/pickBy/pickBy.test.js b/test/pickBy.test.js similarity index 89% rename from test/pickBy/pickBy.test.js rename to test/pickBy.test.js index d0d679682..4ace0e674 100644 --- a/test/pickBy/pickBy.test.js +++ b/test/pickBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const pickBy = require('./pickBy.js'); +const {pickBy} = require('./_30s.js'); test('pickBy is a Function', () => { expect(pickBy).toBeInstanceOf(Function); diff --git a/test/pickBy/pickBy.js b/test/pickBy/pickBy.js deleted file mode 100644 index eca8e0f11..000000000 --- a/test/pickBy/pickBy.js +++ /dev/null @@ -1,5 +0,0 @@ -const pickBy = (obj, fn) => - Object.keys(obj) - .filter(k => fn(obj[k], k)) - .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); -module.exports = pickBy; diff --git a/test/pipeAsyncFunctions/pipeAsyncFunctions.test.js b/test/pipeAsyncFunctions.test.js similarity index 86% rename from test/pipeAsyncFunctions/pipeAsyncFunctions.test.js rename to test/pipeAsyncFunctions.test.js index a53006bf4..294c10fe3 100644 --- a/test/pipeAsyncFunctions/pipeAsyncFunctions.test.js +++ b/test/pipeAsyncFunctions.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const pipeAsyncFunctions = require('./pipeAsyncFunctions.js'); +const {pipeAsyncFunctions} = require('./_30s.js'); test('pipeAsyncFunctions is a Function', () => { expect(pipeAsyncFunctions).toBeInstanceOf(Function); diff --git a/test/pipeAsyncFunctions/pipeAsyncFunctions.js b/test/pipeAsyncFunctions/pipeAsyncFunctions.js deleted file mode 100644 index 501fda5bd..000000000 --- a/test/pipeAsyncFunctions/pipeAsyncFunctions.js +++ /dev/null @@ -1,2 +0,0 @@ -const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg)); -module.exports = pipeAsyncFunctions; diff --git a/test/pipeFunctions/pipeFunctions.test.js b/test/pipeFunctions.test.js similarity index 86% rename from test/pipeFunctions/pipeFunctions.test.js rename to test/pipeFunctions.test.js index b121c9612..17aa9654e 100644 --- a/test/pipeFunctions/pipeFunctions.test.js +++ b/test/pipeFunctions.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const pipeFunctions = require('./pipeFunctions.js'); +const {pipeFunctions} = require('./_30s.js'); test('pipeFunctions is a Function', () => { expect(pipeFunctions).toBeInstanceOf(Function); diff --git a/test/pipeFunctions/pipeFunctions.js b/test/pipeFunctions/pipeFunctions.js deleted file mode 100644 index f6703cf5d..000000000 --- a/test/pipeFunctions/pipeFunctions.js +++ /dev/null @@ -1,2 +0,0 @@ -const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); -module.exports = pipeFunctions; diff --git a/test/pipeLog/pipeLog.test.js b/test/pipeLog.test.js similarity index 74% rename from test/pipeLog/pipeLog.test.js rename to test/pipeLog.test.js index 0c3804936..47ac1f9b1 100644 --- a/test/pipeLog/pipeLog.test.js +++ b/test/pipeLog.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const pipeLog = require('./pipeLog.js'); +const {pipeLog} = require('./_30s.js'); test('pipeLog is a Function', () => { expect(pipeLog).toBeInstanceOf(Function); diff --git a/test/pipeLog/pipeLog.js b/test/pipeLog/pipeLog.js deleted file mode 100644 index 24a764e4d..000000000 --- a/test/pipeLog/pipeLog.js +++ /dev/null @@ -1,2 +0,0 @@ -const pipeLog = data => console.log(data) || data; -module.exports = pipeLog; diff --git a/test/pluralize/pluralize.test.js b/test/pluralize.test.js similarity index 94% rename from test/pluralize/pluralize.test.js rename to test/pluralize.test.js index 2a61e63b9..0dbe882cd 100644 --- a/test/pluralize/pluralize.test.js +++ b/test/pluralize.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const pluralize = require('./pluralize.js'); +const {pluralize} = require('./_30s.js'); test('pluralize is a Function', () => { expect(pluralize).toBeInstanceOf(Function); diff --git a/test/pluralize/pluralize.js b/test/pluralize/pluralize.js deleted file mode 100644 index a7e5d9fdd..000000000 --- a/test/pluralize/pluralize.js +++ /dev/null @@ -1,7 +0,0 @@ -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); -}; -module.exports = pluralize; diff --git a/test/powerset/powerset.test.js b/test/powerset.test.js similarity index 85% rename from test/powerset/powerset.test.js rename to test/powerset.test.js index 50fd91f89..598408863 100644 --- a/test/powerset/powerset.test.js +++ b/test/powerset.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const powerset = require('./powerset.js'); +const {powerset} = require('./_30s.js'); test('powerset is a Function', () => { expect(powerset).toBeInstanceOf(Function); diff --git a/test/powerset/powerset.js b/test/powerset/powerset.js deleted file mode 100644 index e9a2f5099..000000000 --- a/test/powerset/powerset.js +++ /dev/null @@ -1,2 +0,0 @@ -const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]); -module.exports = powerset; diff --git a/test/prefix/prefix.test.js b/test/prefix.test.js similarity index 75% rename from test/prefix/prefix.test.js rename to test/prefix.test.js index b2c491ad4..df22a6f28 100644 --- a/test/prefix/prefix.test.js +++ b/test/prefix.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const prefix = require('./prefix.js'); +const {prefix} = require('./_30s.js'); test('prefix is a Function', () => { expect(prefix).toBeInstanceOf(Function); diff --git a/test/prefix/prefix.js b/test/prefix/prefix.js deleted file mode 100644 index ddcd28958..000000000 --- a/test/prefix/prefix.js +++ /dev/null @@ -1,9 +0,0 @@ -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; -}; -module.exports = prefix; diff --git a/test/prettyBytes/prettyBytes.test.js b/test/prettyBytes.test.js similarity index 91% rename from test/prettyBytes/prettyBytes.test.js rename to test/prettyBytes.test.js index 4bf4e3794..954713d42 100644 --- a/test/prettyBytes/prettyBytes.test.js +++ b/test/prettyBytes.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const prettyBytes = require('./prettyBytes.js'); +const {prettyBytes} = require('./_30s.js'); test('prettyBytes is a Function', () => { expect(prettyBytes).toBeInstanceOf(Function); diff --git a/test/prettyBytes/prettyBytes.js b/test/prettyBytes/prettyBytes.js deleted file mode 100644 index 1616f4f58..000000000 --- a/test/prettyBytes/prettyBytes.js +++ /dev/null @@ -1,8 +0,0 @@ -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]; -}; -module.exports = prettyBytes; diff --git a/test/primes/primes.test.js b/test/primes.test.js similarity index 86% rename from test/primes/primes.test.js rename to test/primes.test.js index b0561c953..2d2e46ff7 100644 --- a/test/primes/primes.test.js +++ b/test/primes.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const primes = require('./primes.js'); +const {primes} = require('./_30s.js'); test('primes is a Function', () => { expect(primes).toBeInstanceOf(Function); diff --git a/test/primes/primes.js b/test/primes/primes.js deleted file mode 100644 index 710c52db2..000000000 --- a/test/primes/primes.js +++ /dev/null @@ -1,8 +0,0 @@ -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; -}; -module.exports = primes; diff --git a/test/promisify/promisify.test.js b/test/promisify.test.js similarity index 89% rename from test/promisify/promisify.test.js rename to test/promisify.test.js index 9a65b98fc..820c73ba0 100644 --- a/test/promisify/promisify.test.js +++ b/test/promisify.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const promisify = require('./promisify.js'); +const {promisify} = require('./_30s.js'); test('promisify is a Function', () => { expect(promisify).toBeInstanceOf(Function); diff --git a/test/promisify/promisify.js b/test/promisify/promisify.js deleted file mode 100644 index 829aa5cda..000000000 --- a/test/promisify/promisify.js +++ /dev/null @@ -1,5 +0,0 @@ -const promisify = func => (...args) => - new Promise((resolve, reject) => - func(...args, (err, result) => (err ? reject(err) : resolve(result))) - ); -module.exports = promisify; diff --git a/test/pull/pull.test.js b/test/pull.test.js similarity index 88% rename from test/pull/pull.test.js rename to test/pull.test.js index 5a3ba43d1..1e2cb138f 100644 --- a/test/pull/pull.test.js +++ b/test/pull.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const pull = require('./pull.js'); +const {pull} = require('./_30s.js'); test('pull is a Function', () => { expect(pull).toBeInstanceOf(Function); diff --git a/test/pull/pull.js b/test/pull/pull.js deleted file mode 100644 index 919af8ae8..000000000 --- a/test/pull/pull.js +++ /dev/null @@ -1,7 +0,0 @@ -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)); -}; -module.exports = pull; diff --git a/test/pullAtIndex/pullAtIndex.test.js b/test/pullAtIndex.test.js similarity index 88% rename from test/pullAtIndex/pullAtIndex.test.js rename to test/pullAtIndex.test.js index 380dee163..dd237b086 100644 --- a/test/pullAtIndex/pullAtIndex.test.js +++ b/test/pullAtIndex.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const pullAtIndex = require('./pullAtIndex.js'); +const {pullAtIndex} = require('./_30s.js'); test('pullAtIndex is a Function', () => { expect(pullAtIndex).toBeInstanceOf(Function); diff --git a/test/pullAtIndex/pullAtIndex.js b/test/pullAtIndex/pullAtIndex.js deleted file mode 100644 index fa28f372b..000000000 --- a/test/pullAtIndex/pullAtIndex.js +++ /dev/null @@ -1,10 +0,0 @@ -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; -}; -module.exports = pullAtIndex; diff --git a/test/pullAtValue/pullAtValue.test.js b/test/pullAtValue.test.js similarity index 88% rename from test/pullAtValue/pullAtValue.test.js rename to test/pullAtValue.test.js index 261704da7..44e550668 100644 --- a/test/pullAtValue/pullAtValue.test.js +++ b/test/pullAtValue.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const pullAtValue = require('./pullAtValue.js'); +const {pullAtValue} = require('./_30s.js'); test('pullAtValue is a Function', () => { expect(pullAtValue).toBeInstanceOf(Function); diff --git a/test/pullAtValue/pullAtValue.js b/test/pullAtValue/pullAtValue.js deleted file mode 100644 index 85599fd43..000000000 --- a/test/pullAtValue/pullAtValue.js +++ /dev/null @@ -1,9 +0,0 @@ -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; -}; -module.exports = pullAtValue; diff --git a/test/pullBy/pullBy.test.js b/test/pullBy.test.js similarity index 88% rename from test/pullBy/pullBy.test.js rename to test/pullBy.test.js index a1a7f1852..dd9be21a7 100644 --- a/test/pullBy/pullBy.test.js +++ b/test/pullBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const pullBy = require('./pullBy.js'); +const {pullBy} = require('./_30s.js'); test('pullBy is a Function', () => { expect(pullBy).toBeInstanceOf(Function); diff --git a/test/pullBy/pullBy.js b/test/pullBy/pullBy.js deleted file mode 100644 index fb254dbc2..000000000 --- a/test/pullBy/pullBy.js +++ /dev/null @@ -1,10 +0,0 @@ -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)); -}; -module.exports = pullBy; diff --git a/test/quickSort/quickSort.test.js b/test/quickSort.test.js similarity index 96% rename from test/quickSort/quickSort.test.js rename to test/quickSort.test.js index 780f81c93..57403de8b 100644 --- a/test/quickSort/quickSort.test.js +++ b/test/quickSort.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const quickSort = require('./quickSort.js'); +const {quickSort} = require('./_30s.js'); test('quickSort is a Function', () => { expect(quickSort).toBeInstanceOf(Function); diff --git a/test/quickSort/quickSort.js b/test/quickSort/quickSort.js deleted file mode 100644 index 692604be0..000000000 --- a/test/quickSort/quickSort.js +++ /dev/null @@ -1,9 +0,0 @@ -const quickSort = ([n, ...nums], desc) => - isNaN(n) - ? [] - : [ - ...quickSort(nums.filter(v => (desc ? v > n : v <= n)), desc), - n, - ...quickSort(nums.filter(v => (!desc ? v > n : v <= n)), desc) - ]; -module.exports = quickSort; diff --git a/test/radsToDegrees/radsToDegrees.test.js b/test/radsToDegrees.test.js similarity index 81% rename from test/radsToDegrees/radsToDegrees.test.js rename to test/radsToDegrees.test.js index 5e7bdea5c..7d0438f5e 100644 --- a/test/radsToDegrees/radsToDegrees.test.js +++ b/test/radsToDegrees.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const radsToDegrees = require('./radsToDegrees.js'); +const {radsToDegrees} = require('./_30s.js'); test('radsToDegrees is a Function', () => { expect(radsToDegrees).toBeInstanceOf(Function); diff --git a/test/radsToDegrees/radsToDegrees.js b/test/radsToDegrees/radsToDegrees.js deleted file mode 100644 index fde727a2f..000000000 --- a/test/radsToDegrees/radsToDegrees.js +++ /dev/null @@ -1,2 +0,0 @@ -const radsToDegrees = rad => (rad * 180.0) / Math.PI; -module.exports = radsToDegrees; diff --git a/test/randomHexColorCode/randomHexColorCode.test.js b/test/randomHexColorCode.test.js similarity index 89% rename from test/randomHexColorCode/randomHexColorCode.test.js rename to test/randomHexColorCode.test.js index 353cd2c4c..cce363b08 100644 --- a/test/randomHexColorCode/randomHexColorCode.test.js +++ b/test/randomHexColorCode.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const randomHexColorCode = require('./randomHexColorCode.js'); +const {randomHexColorCode} = require('./_30s.js'); test('randomHexColorCode is a Function', () => { expect(randomHexColorCode).toBeInstanceOf(Function); diff --git a/test/randomHexColorCode/randomHexColorCode.js b/test/randomHexColorCode/randomHexColorCode.js deleted file mode 100644 index 0b692db35..000000000 --- a/test/randomHexColorCode/randomHexColorCode.js +++ /dev/null @@ -1,5 +0,0 @@ -const randomHexColorCode = () => { - let n = (Math.random() * 0xfffff * 1000000).toString(16); - return '#' + n.slice(0, 6); -}; -module.exports = randomHexColorCode; diff --git a/test/randomIntArrayInRange/randomIntArrayInRange.test.js b/test/randomIntArrayInRange.test.js similarity index 91% rename from test/randomIntArrayInRange/randomIntArrayInRange.test.js rename to test/randomIntArrayInRange.test.js index f0e9e4913..21a037fd7 100644 --- a/test/randomIntArrayInRange/randomIntArrayInRange.test.js +++ b/test/randomIntArrayInRange.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const randomIntArrayInRange = require('./randomIntArrayInRange.js'); +const {randomIntArrayInRange} = require('./_30s.js'); test('randomIntArrayInRange is a Function', () => { expect(randomIntArrayInRange).toBeInstanceOf(Function); diff --git a/test/randomIntArrayInRange/randomIntArrayInRange.js b/test/randomIntArrayInRange/randomIntArrayInRange.js deleted file mode 100644 index f4e3a0dc6..000000000 --- a/test/randomIntArrayInRange/randomIntArrayInRange.js +++ /dev/null @@ -1,3 +0,0 @@ -const randomIntArrayInRange = (min, max, n = 1) => - Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min); -module.exports = randomIntArrayInRange; diff --git a/test/randomIntegerInRange/randomIntegerInRange.test.js b/test/randomIntegerInRange.test.js similarity index 90% rename from test/randomIntegerInRange/randomIntegerInRange.test.js rename to test/randomIntegerInRange.test.js index 1e7179441..88e567892 100644 --- a/test/randomIntegerInRange/randomIntegerInRange.test.js +++ b/test/randomIntegerInRange.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const randomIntegerInRange = require('./randomIntegerInRange.js'); +const {randomIntegerInRange} = require('./_30s.js'); test('randomIntegerInRange is a Function', () => { expect(randomIntegerInRange).toBeInstanceOf(Function); diff --git a/test/randomIntegerInRange/randomIntegerInRange.js b/test/randomIntegerInRange/randomIntegerInRange.js deleted file mode 100644 index 8489482e8..000000000 --- a/test/randomIntegerInRange/randomIntegerInRange.js +++ /dev/null @@ -1,2 +0,0 @@ -const randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; -module.exports = randomIntegerInRange; diff --git a/test/randomNumberInRange/randomNumberInRange.test.js b/test/randomNumberInRange.test.js similarity index 90% rename from test/randomNumberInRange/randomNumberInRange.test.js rename to test/randomNumberInRange.test.js index f3eb1ddd8..f783bde4c 100644 --- a/test/randomNumberInRange/randomNumberInRange.test.js +++ b/test/randomNumberInRange.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const randomNumberInRange = require('./randomNumberInRange.js'); +const {randomNumberInRange} = require('./_30s.js'); test('randomNumberInRange is a Function', () => { expect(randomNumberInRange).toBeInstanceOf(Function); diff --git a/test/randomNumberInRange/randomNumberInRange.js b/test/randomNumberInRange/randomNumberInRange.js deleted file mode 100644 index 603adcbcb..000000000 --- a/test/randomNumberInRange/randomNumberInRange.js +++ /dev/null @@ -1,2 +0,0 @@ -const randomNumberInRange = (min, max) => Math.random() * (max - min) + min; -module.exports = randomNumberInRange; diff --git a/test/readFileLines/readFileLines.test.js b/test/readFileLines.test.js similarity index 71% rename from test/readFileLines/readFileLines.test.js rename to test/readFileLines.test.js index 604c87d79..7873a03be 100644 --- a/test/readFileLines/readFileLines.test.js +++ b/test/readFileLines.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const readFileLines = require('./readFileLines.js'); +const {readFileLines} = require('./_30s.js'); test('readFileLines is a Function', () => { expect(readFileLines).toBeInstanceOf(Function); diff --git a/test/readFileLines/readFileLines.js b/test/readFileLines/readFileLines.js deleted file mode 100644 index 5b041d603..000000000 --- a/test/readFileLines/readFileLines.js +++ /dev/null @@ -1,7 +0,0 @@ -const fs = require('fs'); -const readFileLines = filename => - fs - .readFileSync(filename) - .toString('UTF8') - .split('\n'); -module.exports = readFileLines; diff --git a/test/rearg/rearg.test.js b/test/rearg.test.js similarity index 89% rename from test/rearg/rearg.test.js rename to test/rearg.test.js index 28a589db3..ef20bfee2 100644 --- a/test/rearg/rearg.test.js +++ b/test/rearg.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const rearg = require('./rearg.js'); +const {rearg} = require('./_30s.js'); test('rearg is a Function', () => { expect(rearg).toBeInstanceOf(Function); diff --git a/test/rearg/rearg.js b/test/rearg/rearg.js deleted file mode 100644 index 927d9e9da..000000000 --- a/test/rearg/rearg.js +++ /dev/null @@ -1,2 +0,0 @@ -const rearg = (fn, indexes) => (...args) => fn(...indexes.map(i => args[i])); -module.exports = rearg; diff --git a/test/recordAnimationFrames/recordAnimationFrames.test.js b/test/recordAnimationFrames.test.js similarity index 68% rename from test/recordAnimationFrames/recordAnimationFrames.test.js rename to test/recordAnimationFrames.test.js index 7c95d8452..900c03488 100644 --- a/test/recordAnimationFrames/recordAnimationFrames.test.js +++ b/test/recordAnimationFrames.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const recordAnimationFrames = require('./recordAnimationFrames.js'); +const {recordAnimationFrames} = require('./_30s.js'); test('recordAnimationFrames is a Function', () => { expect(recordAnimationFrames).toBeInstanceOf(Function); diff --git a/test/recordAnimationFrames/recordAnimationFrames.js b/test/recordAnimationFrames/recordAnimationFrames.js deleted file mode 100644 index 753175588..000000000 --- a/test/recordAnimationFrames/recordAnimationFrames.js +++ /dev/null @@ -1,21 +0,0 @@ -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 }; -}; -module.exports = recordAnimationFrames; diff --git a/test/redirect/redirect.test.js b/test/redirect.test.js similarity index 74% rename from test/redirect/redirect.test.js rename to test/redirect.test.js index 831a1d75d..6f6ea68dd 100644 --- a/test/redirect/redirect.test.js +++ b/test/redirect.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const redirect = require('./redirect.js'); +const {redirect} = require('./_30s.js'); test('redirect is a Function', () => { expect(redirect).toBeInstanceOf(Function); diff --git a/test/redirect/redirect.js b/test/redirect/redirect.js deleted file mode 100644 index c0dc849eb..000000000 --- a/test/redirect/redirect.js +++ /dev/null @@ -1,3 +0,0 @@ -const redirect = (url, asLink = true) => - asLink ? (window.location.href = url) : window.location.replace(url); -module.exports = redirect; diff --git a/test/reduceSuccessive/reduceSuccessive.test.js b/test/reduceSuccessive.test.js similarity index 85% rename from test/reduceSuccessive/reduceSuccessive.test.js rename to test/reduceSuccessive.test.js index 333e613af..2f096c0a8 100644 --- a/test/reduceSuccessive/reduceSuccessive.test.js +++ b/test/reduceSuccessive.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const reduceSuccessive = require('./reduceSuccessive.js'); +const {reduceSuccessive} = require('./_30s.js'); test('reduceSuccessive is a Function', () => { expect(reduceSuccessive).toBeInstanceOf(Function); diff --git a/test/reduceSuccessive/reduceSuccessive.js b/test/reduceSuccessive/reduceSuccessive.js deleted file mode 100644 index 73579bb6f..000000000 --- a/test/reduceSuccessive/reduceSuccessive.js +++ /dev/null @@ -1,3 +0,0 @@ -const reduceSuccessive = (arr, fn, acc) => - arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]); -module.exports = reduceSuccessive; diff --git a/test/reduceWhich/reduceWhich.test.js b/test/reduceWhich.test.js similarity index 92% rename from test/reduceWhich/reduceWhich.test.js rename to test/reduceWhich.test.js index 7789a74e9..757a0767d 100644 --- a/test/reduceWhich/reduceWhich.test.js +++ b/test/reduceWhich.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const reduceWhich = require('./reduceWhich.js'); +const {reduceWhich} = require('./_30s.js'); test('reduceWhich is a Function', () => { expect(reduceWhich).toBeInstanceOf(Function); diff --git a/test/reduceWhich/reduceWhich.js b/test/reduceWhich/reduceWhich.js deleted file mode 100644 index b74349439..000000000 --- a/test/reduceWhich/reduceWhich.js +++ /dev/null @@ -1,3 +0,0 @@ -const reduceWhich = (arr, comparator = (a, b) => a - b) => - arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a)); -module.exports = reduceWhich; diff --git a/test/reducedFilter/reducedFilter.test.js b/test/reducedFilter.test.js similarity index 89% rename from test/reducedFilter/reducedFilter.test.js rename to test/reducedFilter.test.js index bd37980ee..2630f1098 100644 --- a/test/reducedFilter/reducedFilter.test.js +++ b/test/reducedFilter.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const reducedFilter = require('./reducedFilter.js'); +const {reducedFilter} = require('./_30s.js'); test('reducedFilter is a Function', () => { expect(reducedFilter).toBeInstanceOf(Function); diff --git a/test/reducedFilter/reducedFilter.js b/test/reducedFilter/reducedFilter.js deleted file mode 100644 index c9ef05049..000000000 --- a/test/reducedFilter/reducedFilter.js +++ /dev/null @@ -1,8 +0,0 @@ -const reducedFilter = (data, keys, fn) => - data.filter(fn).map(el => - keys.reduce((acc, key) => { - acc[key] = el[key]; - return acc; - }, {}) - ); -module.exports = reducedFilter; diff --git a/test/reject/reject.test.js b/test/reject.test.js similarity index 91% rename from test/reject/reject.test.js rename to test/reject.test.js index 3dddd9fb2..6af1fbb28 100644 --- a/test/reject/reject.test.js +++ b/test/reject.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const reject = require('./reject.js'); +const {reject} = require('./_30s.js'); test('reject is a Function', () => { expect(reject).toBeInstanceOf(Function); diff --git a/test/reject/reject.js b/test/reject/reject.js deleted file mode 100644 index 4f095ce0a..000000000 --- a/test/reject/reject.js +++ /dev/null @@ -1,2 +0,0 @@ -const reject = (pred, array) => array.filter((...args) => !pred(...args)); -module.exports = reject; diff --git a/test/remove/remove.test.js b/test/remove.test.js similarity index 87% rename from test/remove/remove.test.js rename to test/remove.test.js index efafcc3da..85c57d951 100644 --- a/test/remove/remove.test.js +++ b/test/remove.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const remove = require('./remove.js'); +const {remove} = require('./_30s.js'); test('remove is a Function', () => { expect(remove).toBeInstanceOf(Function); diff --git a/test/remove/remove.js b/test/remove/remove.js deleted file mode 100644 index 034bc9436..000000000 --- a/test/remove/remove.js +++ /dev/null @@ -1,8 +0,0 @@ -const remove = (arr, func) => - Array.isArray(arr) - ? arr.filter(func).reduce((acc, val) => { - arr.splice(arr.indexOf(val), 1); - return acc.concat(val); - }, []) - : []; -module.exports = remove; diff --git a/test/removeNonASCII/removeNonASCII.test.js b/test/removeNonASCII.test.js similarity index 83% rename from test/removeNonASCII/removeNonASCII.test.js rename to test/removeNonASCII.test.js index 4e8f6f7bd..9c3ccdd62 100644 --- a/test/removeNonASCII/removeNonASCII.test.js +++ b/test/removeNonASCII.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const removeNonASCII = require('./removeNonASCII.js'); +const {removeNonASCII} = require('./_30s.js'); test('removeNonASCII is a Function', () => { expect(removeNonASCII).toBeInstanceOf(Function); diff --git a/test/removeNonASCII/removeNonASCII.js b/test/removeNonASCII/removeNonASCII.js deleted file mode 100644 index 1c6220bae..000000000 --- a/test/removeNonASCII/removeNonASCII.js +++ /dev/null @@ -1,2 +0,0 @@ -const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, ''); -module.exports = removeNonASCII; diff --git a/test/removeVowels/removeVowels.test.js b/test/removeVowels.test.js similarity index 71% rename from test/removeVowels/removeVowels.test.js rename to test/removeVowels.test.js index a9e2458f8..13477fcb1 100644 --- a/test/removeVowels/removeVowels.test.js +++ b/test/removeVowels.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const removeVowels = require('./removeVowels.js'); +const {removeVowels} = require('./_30s.js'); test('removeVowels is a Function', () => { expect(removeVowels).toBeInstanceOf(Function); diff --git a/test/removeVowels/removeVowels.js b/test/removeVowels/removeVowels.js deleted file mode 100644 index 31250b816..000000000 --- a/test/removeVowels/removeVowels.js +++ /dev/null @@ -1,2 +0,0 @@ -const removeVowels = (str, repl = '') => str.replace(/[aeiou]/gi, repl); -module.exports = removeVowels; diff --git a/test/renameKeys/renameKeys.test.js b/test/renameKeys.test.js similarity index 89% rename from test/renameKeys/renameKeys.test.js rename to test/renameKeys.test.js index 574c18289..dd390f8ae 100644 --- a/test/renameKeys/renameKeys.test.js +++ b/test/renameKeys.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const renameKeys = require('./renameKeys.js'); +const {renameKeys} = require('./_30s.js'); test('renameKeys is a Function', () => { expect(renameKeys).toBeInstanceOf(Function); diff --git a/test/renameKeys/renameKeys.js b/test/renameKeys/renameKeys.js deleted file mode 100644 index 4a5fe11c8..000000000 --- a/test/renameKeys/renameKeys.js +++ /dev/null @@ -1,9 +0,0 @@ -const renameKeys = (keysMap, obj) => - Object.keys(obj).reduce( - (acc, key) => ({ - ...acc, - ...{ [keysMap[key] || key]: obj[key] } - }), - {} - ); -module.exports = renameKeys; diff --git a/test/reverseString/reverseString.test.js b/test/reverseString.test.js similarity index 80% rename from test/reverseString/reverseString.test.js rename to test/reverseString.test.js index 8eef925d7..40820df25 100644 --- a/test/reverseString/reverseString.test.js +++ b/test/reverseString.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const reverseString = require('./reverseString.js'); +const {reverseString} = require('./_30s.js'); test('reverseString is a Function', () => { expect(reverseString).toBeInstanceOf(Function); diff --git a/test/reverseString/reverseString.js b/test/reverseString/reverseString.js deleted file mode 100644 index 328f70143..000000000 --- a/test/reverseString/reverseString.js +++ /dev/null @@ -1,2 +0,0 @@ -const reverseString = str => [...str].reverse().join(''); -module.exports = reverseString; diff --git a/test/round/round.test.js b/test/round.test.js similarity index 96% rename from test/round/round.test.js rename to test/round.test.js index b3a834bf6..c2a3af3cf 100644 --- a/test/round/round.test.js +++ b/test/round.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const round = require('./round.js'); +const {round} = require('./_30s.js'); test('round is a Function', () => { expect(round).toBeInstanceOf(Function); diff --git a/test/round/round.js b/test/round/round.js deleted file mode 100644 index 2e9fdc4ec..000000000 --- a/test/round/round.js +++ /dev/null @@ -1,2 +0,0 @@ -const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`); -module.exports = round; diff --git a/test/runAsync/runAsync.test.js b/test/runAsync.test.js similarity index 74% rename from test/runAsync/runAsync.test.js rename to test/runAsync.test.js index fb2806ed4..18c84289d 100644 --- a/test/runAsync/runAsync.test.js +++ b/test/runAsync.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const runAsync = require('./runAsync.js'); +const {runAsync} = require('./_30s.js'); test('runAsync is a Function', () => { expect(runAsync).toBeInstanceOf(Function); diff --git a/test/runAsync/runAsync.js b/test/runAsync/runAsync.js deleted file mode 100644 index c588b6842..000000000 --- a/test/runAsync/runAsync.js +++ /dev/null @@ -1,16 +0,0 @@ -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(); - }; - }); -}; -module.exports = runAsync; diff --git a/test/runPromisesInSeries/runPromisesInSeries.test.js b/test/runPromisesInSeries.test.js similarity index 84% rename from test/runPromisesInSeries/runPromisesInSeries.test.js rename to test/runPromisesInSeries.test.js index 489a95859..b772745ec 100644 --- a/test/runPromisesInSeries/runPromisesInSeries.test.js +++ b/test/runPromisesInSeries.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const runPromisesInSeries = require('./runPromisesInSeries.js'); +const {runPromisesInSeries} = require('./_30s.js'); test('runPromisesInSeries is a Function', () => { expect(runPromisesInSeries).toBeInstanceOf(Function); diff --git a/test/runPromisesInSeries/runPromisesInSeries.js b/test/runPromisesInSeries/runPromisesInSeries.js deleted file mode 100644 index aacbe2f59..000000000 --- a/test/runPromisesInSeries/runPromisesInSeries.js +++ /dev/null @@ -1,2 +0,0 @@ -const runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.resolve()); -module.exports = runPromisesInSeries; diff --git a/test/sample/sample.test.js b/test/sample.test.js similarity index 91% rename from test/sample/sample.test.js rename to test/sample.test.js index e2549df61..0f139654c 100644 --- a/test/sample/sample.test.js +++ b/test/sample.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const sample = require('./sample.js'); +const {sample} = require('./_30s.js'); test('sample is a Function', () => { expect(sample).toBeInstanceOf(Function); diff --git a/test/sample/sample.js b/test/sample/sample.js deleted file mode 100644 index 413d94d41..000000000 --- a/test/sample/sample.js +++ /dev/null @@ -1,2 +0,0 @@ -const sample = arr => arr[Math.floor(Math.random() * arr.length)]; -module.exports = sample; diff --git a/test/sampleSize/sampleSize.test.js b/test/sampleSize.test.js similarity index 93% rename from test/sampleSize/sampleSize.test.js rename to test/sampleSize.test.js index ef5b3ae96..9441a6967 100644 --- a/test/sampleSize/sampleSize.test.js +++ b/test/sampleSize.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const sampleSize = require('./sampleSize.js'); +const {sampleSize} = require('./_30s.js'); test('sampleSize is a Function', () => { expect(sampleSize).toBeInstanceOf(Function); diff --git a/test/sampleSize/sampleSize.js b/test/sampleSize/sampleSize.js deleted file mode 100644 index 90cb4e64d..000000000 --- a/test/sampleSize/sampleSize.js +++ /dev/null @@ -1,9 +0,0 @@ -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); -}; -module.exports = sampleSize; diff --git a/test/scrollToTop/scrollToTop.test.js b/test/scrollToTop.test.js similarity index 72% rename from test/scrollToTop/scrollToTop.test.js rename to test/scrollToTop.test.js index c92677b1b..1700d24c8 100644 --- a/test/scrollToTop/scrollToTop.test.js +++ b/test/scrollToTop.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const scrollToTop = require('./scrollToTop.js'); +const {scrollToTop} = require('./_30s.js'); test('scrollToTop is a Function', () => { expect(scrollToTop).toBeInstanceOf(Function); diff --git a/test/scrollToTop/scrollToTop.js b/test/scrollToTop/scrollToTop.js deleted file mode 100644 index 337e461b1..000000000 --- a/test/scrollToTop/scrollToTop.js +++ /dev/null @@ -1,8 +0,0 @@ -const scrollToTop = () => { - const c = document.documentElement.scrollTop || document.body.scrollTop; - if (c > 0) { - window.requestAnimationFrame(scrollToTop); - window.scrollTo(0, c - c / 8); - } -}; -module.exports = scrollToTop; diff --git a/test/sdbm/sdbm.test.js b/test/sdbm.test.js similarity index 85% rename from test/sdbm/sdbm.test.js rename to test/sdbm.test.js index 58567bc40..583500da6 100644 --- a/test/sdbm/sdbm.test.js +++ b/test/sdbm.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const sdbm = require('./sdbm.js'); +const {sdbm} = require('./_30s.js'); test('sdbm is a Function', () => { expect(sdbm).toBeInstanceOf(Function); diff --git a/test/sdbm/sdbm.js b/test/sdbm/sdbm.js deleted file mode 100644 index 03aae310c..000000000 --- a/test/sdbm/sdbm.js +++ /dev/null @@ -1,9 +0,0 @@ -const sdbm = str => { - let arr = str.split(''); - return arr.reduce( - (hashCode, currentVal) => - (hashCode = currentVal.charCodeAt(0) + (hashCode << 6) + (hashCode << 16) - hashCode), - 0 - ); -}; -module.exports = sdbm; diff --git a/test/serializeCookie/serializeCookie.test.js b/test/serializeCookie.test.js similarity index 80% rename from test/serializeCookie/serializeCookie.test.js rename to test/serializeCookie.test.js index 211ca7c21..2de3c2d1c 100644 --- a/test/serializeCookie/serializeCookie.test.js +++ b/test/serializeCookie.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const serializeCookie = require('./serializeCookie.js'); +const {serializeCookie} = require('./_30s.js'); test('serializeCookie is a Function', () => { expect(serializeCookie).toBeInstanceOf(Function); diff --git a/test/serializeCookie/serializeCookie.js b/test/serializeCookie/serializeCookie.js deleted file mode 100644 index 48155e78f..000000000 --- a/test/serializeCookie/serializeCookie.js +++ /dev/null @@ -1,2 +0,0 @@ -const serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`; -module.exports = serializeCookie; diff --git a/test/setStyle/setStyle.test.js b/test/setStyle.test.js similarity index 74% rename from test/setStyle/setStyle.test.js rename to test/setStyle.test.js index 2982ae7cd..8d3e786c6 100644 --- a/test/setStyle/setStyle.test.js +++ b/test/setStyle.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const setStyle = require('./setStyle.js'); +const {setStyle} = require('./_30s.js'); test('setStyle is a Function', () => { expect(setStyle).toBeInstanceOf(Function); diff --git a/test/setStyle/setStyle.js b/test/setStyle/setStyle.js deleted file mode 100644 index 3a48adac9..000000000 --- a/test/setStyle/setStyle.js +++ /dev/null @@ -1,2 +0,0 @@ -const setStyle = (el, ruleName, val) => (el.style[ruleName] = val); -module.exports = setStyle; diff --git a/test/shallowClone/shallowClone.test.js b/test/shallowClone.test.js similarity index 87% rename from test/shallowClone/shallowClone.test.js rename to test/shallowClone.test.js index 14c8fdf1c..e58665917 100644 --- a/test/shallowClone/shallowClone.test.js +++ b/test/shallowClone.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const shallowClone = require('./shallowClone.js'); +const {shallowClone} = require('./_30s.js'); test('shallowClone is a Function', () => { expect(shallowClone).toBeInstanceOf(Function); diff --git a/test/shallowClone/shallowClone.js b/test/shallowClone/shallowClone.js deleted file mode 100644 index ecad6c309..000000000 --- a/test/shallowClone/shallowClone.js +++ /dev/null @@ -1,2 +0,0 @@ -const shallowClone = obj => Object.assign({}, obj); -module.exports = shallowClone; diff --git a/test/shank/shank.test.js b/test/shank.test.js similarity index 93% rename from test/shank/shank.test.js rename to test/shank.test.js index e14414748..c53b90656 100644 --- a/test/shank/shank.test.js +++ b/test/shank.test.js @@ -1,5 +1,5 @@ const expect = require("expect"); -const shank = require("./shank.js"); +const {shank} = require("./_30s.js"); test("shank is a Function", () => { expect(shank).toBeInstanceOf(Function); diff --git a/test/shank/shank.js b/test/shank/shank.js deleted file mode 100644 index 3d5e19f9c..000000000 --- a/test/shank/shank.js +++ /dev/null @@ -1,6 +0,0 @@ -const shank = (arr, index = 0, delCount = 0, ...elements) => - arr - .slice(0, index) - .concat(elements) - .concat(arr.slice(index + delCount)); -module.exports = shank; diff --git a/test/show/show.test.js b/test/show.test.js similarity index 75% rename from test/show/show.test.js rename to test/show.test.js index 81c5ea492..e1e535f43 100644 --- a/test/show/show.test.js +++ b/test/show.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const show = require('./show.js'); +const {show} = require('./_30s.js'); test('show is a Function', () => { expect(show).toBeInstanceOf(Function); diff --git a/test/show/show.js b/test/show/show.js deleted file mode 100644 index 028f2fc76..000000000 --- a/test/show/show.js +++ /dev/null @@ -1,2 +0,0 @@ -const show = (...el) => [...el].forEach(e => (e.style.display = '')); -module.exports = show; diff --git a/test/shuffle/shuffle.test.js b/test/shuffle.test.js similarity index 92% rename from test/shuffle/shuffle.test.js rename to test/shuffle.test.js index c71985f8e..9360ce237 100644 --- a/test/shuffle/shuffle.test.js +++ b/test/shuffle.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const shuffle = require('./shuffle.js'); +const {shuffle} = require('./_30s.js'); test('shuffle is a Function', () => { expect(shuffle).toBeInstanceOf(Function); diff --git a/test/shuffle/shuffle.js b/test/shuffle/shuffle.js deleted file mode 100644 index f03481f7a..000000000 --- a/test/shuffle/shuffle.js +++ /dev/null @@ -1,9 +0,0 @@ -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; -}; -module.exports = shuffle; diff --git a/test/similarity/similarity.test.js b/test/similarity.test.js similarity index 84% rename from test/similarity/similarity.test.js rename to test/similarity.test.js index 479c64b9c..5efd16e50 100644 --- a/test/similarity/similarity.test.js +++ b/test/similarity.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const similarity = require('./similarity.js'); +const {similarity} = require('./_30s.js'); test('similarity is a Function', () => { expect(similarity).toBeInstanceOf(Function); diff --git a/test/similarity/similarity.js b/test/similarity/similarity.js deleted file mode 100644 index 1614f82e4..000000000 --- a/test/similarity/similarity.js +++ /dev/null @@ -1,2 +0,0 @@ -const similarity = (arr, values) => arr.filter(v => values.includes(v)); -module.exports = similarity; diff --git a/test/size/size.test.js b/test/size.test.js similarity index 89% rename from test/size/size.test.js rename to test/size.test.js index 54622aa01..4a306faf5 100644 --- a/test/size/size.test.js +++ b/test/size.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const size = require('./size.js'); +const {size} = require('./_30s.js'); test('size is a Function', () => { expect(size).toBeInstanceOf(Function); diff --git a/test/size/size.js b/test/size/size.js deleted file mode 100644 index 88073bcb5..000000000 --- a/test/size/size.js +++ /dev/null @@ -1,9 +0,0 @@ -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; -module.exports = size; diff --git a/test/sleep/sleep.test.js b/test/sleep.test.js similarity index 86% rename from test/sleep/sleep.test.js rename to test/sleep.test.js index faff7c0f2..5dd0f9f6f 100644 --- a/test/sleep/sleep.test.js +++ b/test/sleep.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const sleep = require('./sleep.js'); +const {sleep} = require('./_30s.js'); test('sleep is a Function', () => { expect(sleep).toBeInstanceOf(Function); diff --git a/test/sleep/sleep.js b/test/sleep/sleep.js deleted file mode 100644 index 56f452762..000000000 --- a/test/sleep/sleep.js +++ /dev/null @@ -1,2 +0,0 @@ -const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); -module.exports = sleep; diff --git a/test/smoothScroll/smoothScroll.test.js b/test/smoothScroll.test.js similarity index 71% rename from test/smoothScroll/smoothScroll.test.js rename to test/smoothScroll.test.js index 269e7252c..b8e60c56a 100644 --- a/test/smoothScroll/smoothScroll.test.js +++ b/test/smoothScroll.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const smoothScroll = require('./smoothScroll.js'); +const {smoothScroll} = require('./_30s.js'); test('smoothScroll is a Function', () => { expect(smoothScroll).toBeInstanceOf(Function); diff --git a/test/smoothScroll/smoothScroll.js b/test/smoothScroll/smoothScroll.js deleted file mode 100644 index ef93400af..000000000 --- a/test/smoothScroll/smoothScroll.js +++ /dev/null @@ -1,5 +0,0 @@ -const smoothScroll = element => - document.querySelector(element).scrollIntoView({ - behavior: 'smooth' - }); -module.exports = smoothScroll; diff --git a/test/solveRPN/solveRPN.test.js b/test/solveRPN.test.js similarity index 74% rename from test/solveRPN/solveRPN.test.js rename to test/solveRPN.test.js index c6a2fee8b..a2d942aed 100644 --- a/test/solveRPN/solveRPN.test.js +++ b/test/solveRPN.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const solveRPN = require('./solveRPN.js'); +const {solveRPN} = require('./_30s.js'); test('solveRPN is a Function', () => { expect(solveRPN).toBeInstanceOf(Function); diff --git a/test/solveRPN/solveRPN.js b/test/solveRPN/solveRPN.js deleted file mode 100644 index fec5b3b7e..000000000 --- a/test/solveRPN/solveRPN.js +++ /dev/null @@ -1,29 +0,0 @@ -const solveRPN = rpn => { - const OPERATORS = { - '*': (a, b) => a * b, - '+': (a, b) => a + b, - '-': (a, b) => a - b, - '/': (a, b) => a / b, - '**': (a, b) => a ** b - }; - const [stack, solve] = [ - [], - rpn - .replace(/\^/g, '**') - .split(/\s+/g) - .filter(el => !/\s+/.test(el) && el !== '') - ]; - solve.forEach(symbol => { - if (!isNaN(parseFloat(symbol)) && isFinite(symbol)) { - stack.push(symbol); - } else if (Object.keys(OPERATORS).includes(symbol)) { - const [a, b] = [stack.pop(), stack.pop()]; - stack.push(OPERATORS[symbol](parseFloat(b), parseFloat(a))); - } else { - throw `${symbol} is not a recognized symbol`; - } - }); - if (stack.length === 1) return stack.pop(); - else throw `${rpn} is not a proper RPN. Please check it and try again`; -}; -module.exports = solveRPN; diff --git a/test/sortCharactersInString/sortCharactersInString.test.js b/test/sortCharactersInString.test.js similarity index 79% rename from test/sortCharactersInString/sortCharactersInString.test.js rename to test/sortCharactersInString.test.js index 8979fe2b7..4fa845fe0 100644 --- a/test/sortCharactersInString/sortCharactersInString.test.js +++ b/test/sortCharactersInString.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const sortCharactersInString = require('./sortCharactersInString.js'); +const {sortCharactersInString} = require('./_30s.js'); test('sortCharactersInString is a Function', () => { expect(sortCharactersInString).toBeInstanceOf(Function); diff --git a/test/sortCharactersInString/sortCharactersInString.js b/test/sortCharactersInString/sortCharactersInString.js deleted file mode 100644 index f92166670..000000000 --- a/test/sortCharactersInString/sortCharactersInString.js +++ /dev/null @@ -1,2 +0,0 @@ -const sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join(''); -module.exports = sortCharactersInString; diff --git a/test/sortedIndex/sortedIndex.test.js b/test/sortedIndex.test.js similarity index 90% rename from test/sortedIndex/sortedIndex.test.js rename to test/sortedIndex.test.js index 0bfe6ff39..bf1606098 100644 --- a/test/sortedIndex/sortedIndex.test.js +++ b/test/sortedIndex.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const sortedIndex = require('./sortedIndex.js'); +const {sortedIndex} = require('./_30s.js'); test('sortedIndex is a Function', () => { expect(sortedIndex).toBeInstanceOf(Function); diff --git a/test/sortedIndex/sortedIndex.js b/test/sortedIndex/sortedIndex.js deleted file mode 100644 index 82d023c6a..000000000 --- a/test/sortedIndex/sortedIndex.js +++ /dev/null @@ -1,6 +0,0 @@ -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; -}; -module.exports = sortedIndex; diff --git a/test/sortedIndexBy/sortedIndexBy.test.js b/test/sortedIndexBy.test.js similarity index 85% rename from test/sortedIndexBy/sortedIndexBy.test.js rename to test/sortedIndexBy.test.js index 6e02b36a4..65545dd7f 100644 --- a/test/sortedIndexBy/sortedIndexBy.test.js +++ b/test/sortedIndexBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const sortedIndexBy = require('./sortedIndexBy.js'); +const {sortedIndexBy} = require('./_30s.js'); test('sortedIndexBy is a Function', () => { expect(sortedIndexBy).toBeInstanceOf(Function); diff --git a/test/sortedIndexBy/sortedIndexBy.js b/test/sortedIndexBy/sortedIndexBy.js deleted file mode 100644 index 1a284e074..000000000 --- a/test/sortedIndexBy/sortedIndexBy.js +++ /dev/null @@ -1,7 +0,0 @@ -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; -}; -module.exports = sortedIndexBy; diff --git a/test/sortedLastIndex/sortedLastIndex.test.js b/test/sortedLastIndex.test.js similarity index 84% rename from test/sortedLastIndex/sortedLastIndex.test.js rename to test/sortedLastIndex.test.js index 84a9ff63a..789fcc188 100644 --- a/test/sortedLastIndex/sortedLastIndex.test.js +++ b/test/sortedLastIndex.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const sortedLastIndex = require('./sortedLastIndex.js'); +const {sortedLastIndex} = require('./_30s.js'); test('sortedLastIndex is a Function', () => { expect(sortedLastIndex).toBeInstanceOf(Function); diff --git a/test/sortedLastIndex/sortedLastIndex.js b/test/sortedLastIndex/sortedLastIndex.js deleted file mode 100644 index 78cafda2a..000000000 --- a/test/sortedLastIndex/sortedLastIndex.js +++ /dev/null @@ -1,6 +0,0 @@ -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; -}; -module.exports = sortedLastIndex; diff --git a/test/sortedLastIndexBy/sortedLastIndexBy.test.js b/test/sortedLastIndexBy.test.js similarity index 84% rename from test/sortedLastIndexBy/sortedLastIndexBy.test.js rename to test/sortedLastIndexBy.test.js index ad0bfc718..8185bed93 100644 --- a/test/sortedLastIndexBy/sortedLastIndexBy.test.js +++ b/test/sortedLastIndexBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const sortedLastIndexBy = require('./sortedLastIndexBy.js'); +const {sortedLastIndexBy} = require('./_30s.js'); test('sortedLastIndexBy is a Function', () => { expect(sortedLastIndexBy).toBeInstanceOf(Function); diff --git a/test/sortedLastIndexBy/sortedLastIndexBy.js b/test/sortedLastIndexBy/sortedLastIndexBy.js deleted file mode 100644 index d028f44b5..000000000 --- a/test/sortedLastIndexBy/sortedLastIndexBy.js +++ /dev/null @@ -1,10 +0,0 @@ -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; -}; -module.exports = sortedLastIndexBy; diff --git a/test/speechSynthesis/speechSynthesis.test.js b/test/speechSynthesis.test.js similarity index 70% rename from test/speechSynthesis/speechSynthesis.test.js rename to test/speechSynthesis.test.js index 9981924c8..e15907cf6 100644 --- a/test/speechSynthesis/speechSynthesis.test.js +++ b/test/speechSynthesis.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const speechSynthesis = require('./speechSynthesis.js'); +const {speechSynthesis} = require('./_30s.js'); test('speechSynthesis is a Function', () => { expect(speechSynthesis).toBeInstanceOf(Function); diff --git a/test/speechSynthesis/speechSynthesis.js b/test/speechSynthesis/speechSynthesis.js deleted file mode 100644 index 867f477ba..000000000 --- a/test/speechSynthesis/speechSynthesis.js +++ /dev/null @@ -1,6 +0,0 @@ -const speechSynthesis = message => { - const msg = new SpeechSynthesisUtterance(message); - msg.voice = window.speechSynthesis.getVoices()[0]; - window.speechSynthesis.speak(msg); -}; -module.exports = speechSynthesis; diff --git a/test/splitLines/splitLines.test.js b/test/splitLines.test.js similarity index 87% rename from test/splitLines/splitLines.test.js rename to test/splitLines.test.js index c35d956b9..4788486f3 100644 --- a/test/splitLines/splitLines.test.js +++ b/test/splitLines.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const splitLines = require('./splitLines.js'); +const {splitLines} = require('./_30s.js'); test('splitLines is a Function', () => { expect(splitLines).toBeInstanceOf(Function); diff --git a/test/splitLines/splitLines.js b/test/splitLines/splitLines.js deleted file mode 100644 index fc73cabe0..000000000 --- a/test/splitLines/splitLines.js +++ /dev/null @@ -1,2 +0,0 @@ -const splitLines = str => str.split(/\r?\n/); -module.exports = splitLines; diff --git a/test/spreadOver/spreadOver.test.js b/test/spreadOver.test.js similarity index 88% rename from test/spreadOver/spreadOver.test.js rename to test/spreadOver.test.js index 7f101c1d9..f1b8d30b5 100644 --- a/test/spreadOver/spreadOver.test.js +++ b/test/spreadOver.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const spreadOver = require('./spreadOver.js'); +const {spreadOver} = require('./_30s.js'); test('spreadOver is a Function', () => { expect(spreadOver).toBeInstanceOf(Function); diff --git a/test/spreadOver/spreadOver.js b/test/spreadOver/spreadOver.js deleted file mode 100644 index e84eb8060..000000000 --- a/test/spreadOver/spreadOver.js +++ /dev/null @@ -1,2 +0,0 @@ -const spreadOver = fn => argsArr => fn(...argsArr); -module.exports = spreadOver; diff --git a/test/squareSum/squareSum.test.js b/test/squareSum.test.js similarity index 73% rename from test/squareSum/squareSum.test.js rename to test/squareSum.test.js index 447cd90d7..08b60a65c 100644 --- a/test/squareSum/squareSum.test.js +++ b/test/squareSum.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const squareSum = require('./squareSum.js'); +const {squareSum} = require('./_30s.js'); test('squareSum is a Function', () => { expect(squareSum).toBeInstanceOf(Function); diff --git a/test/squareSum/squareSum.js b/test/squareSum/squareSum.js deleted file mode 100644 index ed3c4a743..000000000 --- a/test/squareSum/squareSum.js +++ /dev/null @@ -1,2 +0,0 @@ -const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0); -module.exports = squareSum; diff --git a/test/stableSort/stableSort.test.js b/test/stableSort.test.js similarity index 86% rename from test/stableSort/stableSort.test.js rename to test/stableSort.test.js index 4c2f3a37b..903cea229 100644 --- a/test/stableSort/stableSort.test.js +++ b/test/stableSort.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const stableSort = require('./stableSort.js'); +const {stableSort} = require('./_30s.js'); test('stableSort is a Function', () => { expect(stableSort).toBeInstanceOf(Function); diff --git a/test/stableSort/stableSort.js b/test/stableSort/stableSort.js deleted file mode 100644 index dc75cd83d..000000000 --- a/test/stableSort/stableSort.js +++ /dev/null @@ -1,6 +0,0 @@ -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); -module.exports = stableSort; diff --git a/test/standardDeviation/standardDeviation.test.js b/test/standardDeviation.test.js similarity index 88% rename from test/standardDeviation/standardDeviation.test.js rename to test/standardDeviation.test.js index 2836df632..0f5d68394 100644 --- a/test/standardDeviation/standardDeviation.test.js +++ b/test/standardDeviation.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const standardDeviation = require('./standardDeviation.js'); +const {standardDeviation} = require('./_30s.js'); test('standardDeviation is a Function', () => { expect(standardDeviation).toBeInstanceOf(Function); diff --git a/test/standardDeviation/standardDeviation.js b/test/standardDeviation/standardDeviation.js deleted file mode 100644 index b698e7826..000000000 --- a/test/standardDeviation/standardDeviation.js +++ /dev/null @@ -1,8 +0,0 @@ -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)) - ); -}; -module.exports = standardDeviation; diff --git a/test/stringPermutations/stringPermutations.test.js b/test/stringPermutations.test.js similarity index 88% rename from test/stringPermutations/stringPermutations.test.js rename to test/stringPermutations.test.js index 80019e110..5ff4586f6 100644 --- a/test/stringPermutations/stringPermutations.test.js +++ b/test/stringPermutations.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const stringPermutations = require('./stringPermutations.js'); +const {stringPermutations} = require('./_30s.js'); test('stringPermutations is a Function', () => { expect(stringPermutations).toBeInstanceOf(Function); diff --git a/test/stringPermutations/stringPermutations.js b/test/stringPermutations/stringPermutations.js deleted file mode 100644 index 5f5c613b6..000000000 --- a/test/stringPermutations/stringPermutations.js +++ /dev/null @@ -1,11 +0,0 @@ -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)), - [] - ); -}; -module.exports = stringPermutations; diff --git a/test/stripHTMLTags/stripHTMLTags.test.js b/test/stripHTMLTags.test.js similarity index 84% rename from test/stripHTMLTags/stripHTMLTags.test.js rename to test/stripHTMLTags.test.js index 1543517a2..67eabfd4e 100644 --- a/test/stripHTMLTags/stripHTMLTags.test.js +++ b/test/stripHTMLTags.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const stripHTMLTags = require('./stripHTMLTags.js'); +const {stripHTMLTags} = require('./_30s.js'); test('stripHTMLTags is a Function', () => { expect(stripHTMLTags).toBeInstanceOf(Function); diff --git a/test/stripHTMLTags/stripHTMLTags.js b/test/stripHTMLTags/stripHTMLTags.js deleted file mode 100644 index 1106c81f0..000000000 --- a/test/stripHTMLTags/stripHTMLTags.js +++ /dev/null @@ -1,2 +0,0 @@ -const stripHTMLTags = str => str.replace(/<[^>]*>/g, ''); -module.exports = stripHTMLTags; diff --git a/test/sum/sum.test.js b/test/sum.test.js similarity index 85% rename from test/sum/sum.test.js rename to test/sum.test.js index ac94b8891..e1f8c846d 100644 --- a/test/sum/sum.test.js +++ b/test/sum.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const sum = require('./sum.js'); +const {sum} = require('./_30s.js'); test('sum is a Function', () => { expect(sum).toBeInstanceOf(Function); diff --git a/test/sum/sum.js b/test/sum/sum.js deleted file mode 100644 index 64a39052e..000000000 --- a/test/sum/sum.js +++ /dev/null @@ -1,2 +0,0 @@ -const sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0); -module.exports = sum; diff --git a/test/sumBy/sumBy.test.js b/test/sumBy.test.js similarity index 75% rename from test/sumBy/sumBy.test.js rename to test/sumBy.test.js index 07e8c2b17..3fcd55f68 100644 --- a/test/sumBy/sumBy.test.js +++ b/test/sumBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const sumBy = require('./sumBy.js'); +const {sumBy} = require('./_30s.js'); test('sumBy is a Function', () => { expect(sumBy).toBeInstanceOf(Function); diff --git a/test/sumBy/sumBy.js b/test/sumBy/sumBy.js deleted file mode 100644 index 8d6466d6b..000000000 --- a/test/sumBy/sumBy.js +++ /dev/null @@ -1,3 +0,0 @@ -const sumBy = (arr, fn) => - arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0); -module.exports = sumBy; diff --git a/test/sumPower/sumPower.test.js b/test/sumPower.test.js similarity index 92% rename from test/sumPower/sumPower.test.js rename to test/sumPower.test.js index b655fe974..7f48c8a8d 100644 --- a/test/sumPower/sumPower.test.js +++ b/test/sumPower.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const sumPower = require('./sumPower.js'); +const {sumPower} = require('./_30s.js'); test('sumPower is a Function', () => { expect(sumPower).toBeInstanceOf(Function); diff --git a/test/sumPower/sumPower.js b/test/sumPower/sumPower.js deleted file mode 100644 index 3537e8825..000000000 --- a/test/sumPower/sumPower.js +++ /dev/null @@ -1,6 +0,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); -module.exports = sumPower; diff --git a/test/symmetricDifference/symmetricDifference.test.js b/test/symmetricDifference.test.js similarity index 86% rename from test/symmetricDifference/symmetricDifference.test.js rename to test/symmetricDifference.test.js index c96e3b5a6..7a8ed8607 100644 --- a/test/symmetricDifference/symmetricDifference.test.js +++ b/test/symmetricDifference.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const symmetricDifference = require('./symmetricDifference.js'); +const {symmetricDifference} = require('./_30s.js'); test('symmetricDifference is a Function', () => { expect(symmetricDifference).toBeInstanceOf(Function); diff --git a/test/symmetricDifference/symmetricDifference.js b/test/symmetricDifference/symmetricDifference.js deleted file mode 100644 index f84ccc299..000000000 --- a/test/symmetricDifference/symmetricDifference.js +++ /dev/null @@ -1,6 +0,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))]; -}; -module.exports = symmetricDifference; diff --git a/test/symmetricDifferenceBy/symmetricDifferenceBy.test.js b/test/symmetricDifferenceBy.test.js similarity index 84% rename from test/symmetricDifferenceBy/symmetricDifferenceBy.test.js rename to test/symmetricDifferenceBy.test.js index 526ed9f50..064ad28cc 100644 --- a/test/symmetricDifferenceBy/symmetricDifferenceBy.test.js +++ b/test/symmetricDifferenceBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const symmetricDifferenceBy = require('./symmetricDifferenceBy.js'); +const {symmetricDifferenceBy} = require('./_30s.js'); test('symmetricDifferenceBy is a Function', () => { expect(symmetricDifferenceBy).toBeInstanceOf(Function); diff --git a/test/symmetricDifferenceBy/symmetricDifferenceBy.js b/test/symmetricDifferenceBy/symmetricDifferenceBy.js deleted file mode 100644 index e2eef5b34..000000000 --- a/test/symmetricDifferenceBy/symmetricDifferenceBy.js +++ /dev/null @@ -1,6 +0,0 @@ -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)))]; -}; -module.exports = symmetricDifferenceBy; diff --git a/test/symmetricDifferenceWith/symmetricDifferenceWith.test.js b/test/symmetricDifferenceWith.test.js similarity index 85% rename from test/symmetricDifferenceWith/symmetricDifferenceWith.test.js rename to test/symmetricDifferenceWith.test.js index 44c7a4a3c..8d50e4e46 100644 --- a/test/symmetricDifferenceWith/symmetricDifferenceWith.test.js +++ b/test/symmetricDifferenceWith.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const symmetricDifferenceWith = require('./symmetricDifferenceWith.js'); +const {symmetricDifferenceWith} = require('./_30s.js'); test('symmetricDifferenceWith is a Function', () => { expect(symmetricDifferenceWith).toBeInstanceOf(Function); diff --git a/test/symmetricDifferenceWith/symmetricDifferenceWith.js b/test/symmetricDifferenceWith/symmetricDifferenceWith.js deleted file mode 100644 index 15e99a32f..000000000 --- a/test/symmetricDifferenceWith/symmetricDifferenceWith.js +++ /dev/null @@ -1,5 +0,0 @@ -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) -]; -module.exports = symmetricDifferenceWith; diff --git a/test/tail/tail.test.js b/test/tail.test.js similarity index 87% rename from test/tail/tail.test.js rename to test/tail.test.js index e38eb7d37..e71cdcf10 100644 --- a/test/tail/tail.test.js +++ b/test/tail.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const tail = require('./tail.js'); +const {tail} = require('./_30s.js'); test('tail is a Function', () => { expect(tail).toBeInstanceOf(Function); diff --git a/test/tail/tail.js b/test/tail/tail.js deleted file mode 100644 index 25b3a5fd1..000000000 --- a/test/tail/tail.js +++ /dev/null @@ -1,2 +0,0 @@ -const tail = arr => (arr.length > 1 ? arr.slice(1) : arr); -module.exports = tail; diff --git a/test/take/take.test.js b/test/take.test.js similarity index 90% rename from test/take/take.test.js rename to test/take.test.js index 6621a5176..7506eea2d 100644 --- a/test/take/take.test.js +++ b/test/take.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const take = require('./take.js'); +const {take} = require('./_30s.js'); test('take is a Function', () => { expect(take).toBeInstanceOf(Function); diff --git a/test/take/take.js b/test/take/take.js deleted file mode 100644 index d6057a021..000000000 --- a/test/take/take.js +++ /dev/null @@ -1,2 +0,0 @@ -const take = (arr, n = 1) => arr.slice(0, n); -module.exports = take; diff --git a/test/takeRight/takeRight.test.js b/test/takeRight.test.js similarity index 89% rename from test/takeRight/takeRight.test.js rename to test/takeRight.test.js index b31c99d8d..075ca4bdd 100644 --- a/test/takeRight/takeRight.test.js +++ b/test/takeRight.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const takeRight = require('./takeRight.js'); +const {takeRight} = require('./_30s.js'); test('takeRight is a Function', () => { expect(takeRight).toBeInstanceOf(Function); diff --git a/test/takeRight/takeRight.js b/test/takeRight/takeRight.js deleted file mode 100644 index d847cc73b..000000000 --- a/test/takeRight/takeRight.js +++ /dev/null @@ -1,2 +0,0 @@ -const takeRight = (arr, n = 1) => arr.slice(arr.length - n, arr.length); -module.exports = takeRight; diff --git a/test/takeRightWhile/takeRightWhile.test.js b/test/takeRightWhile.test.js similarity index 83% rename from test/takeRightWhile/takeRightWhile.test.js rename to test/takeRightWhile.test.js index 9730677d9..90f52e510 100644 --- a/test/takeRightWhile/takeRightWhile.test.js +++ b/test/takeRightWhile.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const takeRightWhile = require('./takeRightWhile.js'); +const {takeRightWhile} = require('./_30s.js'); test('takeRightWhile is a Function', () => { expect(takeRightWhile).toBeInstanceOf(Function); diff --git a/test/takeRightWhile/takeRightWhile.js b/test/takeRightWhile/takeRightWhile.js deleted file mode 100644 index b01512663..000000000 --- a/test/takeRightWhile/takeRightWhile.js +++ /dev/null @@ -1,3 +0,0 @@ -const takeRightWhile = (arr, func) => - arr.reduceRight((acc, el) => (func(el) ? acc : [el, ...acc]), []); -module.exports = takeRightWhile; diff --git a/test/takeWhile/takeWhile.test.js b/test/takeWhile.test.js similarity index 85% rename from test/takeWhile/takeWhile.test.js rename to test/takeWhile.test.js index bdc14c586..b726f5e6e 100644 --- a/test/takeWhile/takeWhile.test.js +++ b/test/takeWhile.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const takeWhile = require('./takeWhile.js'); +const {takeWhile} = require('./_30s.js'); test('takeWhile is a Function', () => { expect(takeWhile).toBeInstanceOf(Function); diff --git a/test/takeWhile/takeWhile.js b/test/takeWhile/takeWhile.js deleted file mode 100644 index 2263afeec..000000000 --- a/test/takeWhile/takeWhile.js +++ /dev/null @@ -1,5 +0,0 @@ -const takeWhile = (arr, func) => { - for (const [i, val] of arr.entries()) if (func(val)) return arr.slice(0, i); - return arr; -}; -module.exports = takeWhile; diff --git a/test/throttle/throttle.test.js b/test/throttle.test.js similarity index 74% rename from test/throttle/throttle.test.js rename to test/throttle.test.js index 6f73087c6..646e93fa3 100644 --- a/test/throttle/throttle.test.js +++ b/test/throttle.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const throttle = require('./throttle.js'); +const {throttle} = require('./_30s.js'); test('throttle is a Function', () => { expect(throttle).toBeInstanceOf(Function); diff --git a/test/throttle/throttle.js b/test/throttle/throttle.js deleted file mode 100644 index 052a3da47..000000000 --- a/test/throttle/throttle.js +++ /dev/null @@ -1,21 +0,0 @@ -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)); - } - }; -}; -module.exports = throttle; diff --git a/test/timeTaken/timeTaken.test.js b/test/timeTaken.test.js similarity index 73% rename from test/timeTaken/timeTaken.test.js rename to test/timeTaken.test.js index fe67c4284..72436f8b6 100644 --- a/test/timeTaken/timeTaken.test.js +++ b/test/timeTaken.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const timeTaken = require('./timeTaken.js'); +const {timeTaken} = require('./_30s.js'); test('timeTaken is a Function', () => { expect(timeTaken).toBeInstanceOf(Function); diff --git a/test/timeTaken/timeTaken.js b/test/timeTaken/timeTaken.js deleted file mode 100644 index 96cab458b..000000000 --- a/test/timeTaken/timeTaken.js +++ /dev/null @@ -1,7 +0,0 @@ -const timeTaken = callback => { - console.time('timeTaken'); - const r = callback(); - console.timeEnd('timeTaken'); - return r; -}; -module.exports = timeTaken; diff --git a/test/times/times.test.js b/test/times.test.js similarity index 87% rename from test/times/times.test.js rename to test/times.test.js index e5108af66..c5c9c2ca8 100644 --- a/test/times/times.test.js +++ b/test/times.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const times = require('./times.js'); +const {times} = require('./_30s.js'); test('times is a Function', () => { expect(times).toBeInstanceOf(Function); diff --git a/test/times/times.js b/test/times/times.js deleted file mode 100644 index cb1402553..000000000 --- a/test/times/times.js +++ /dev/null @@ -1,5 +0,0 @@ -const times = (n, fn, context = undefined) => { - let i = 0; - while (fn.call(context, i) !== false && ++i < n) {} -}; -module.exports = times; diff --git a/test/toCamelCase/toCamelCase.test.js b/test/toCamelCase.test.js similarity index 97% rename from test/toCamelCase/toCamelCase.test.js rename to test/toCamelCase.test.js index 4681dbe9c..1e01c70ad 100644 --- a/test/toCamelCase/toCamelCase.test.js +++ b/test/toCamelCase.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const toCamelCase = require('./toCamelCase.js'); +const {toCamelCase} = require('./_30s.js'); test('toCamelCase is a Function', () => { expect(toCamelCase).toBeInstanceOf(Function); diff --git a/test/toCamelCase/toCamelCase.js b/test/toCamelCase/toCamelCase.js deleted file mode 100644 index edc309d0f..000000000 --- a/test/toCamelCase/toCamelCase.js +++ /dev/null @@ -1,10 +0,0 @@ -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); -}; -module.exports = toCamelCase; diff --git a/test/toCurrency/toCurrency.test.js b/test/toCurrency.test.js similarity index 93% rename from test/toCurrency/toCurrency.test.js rename to test/toCurrency.test.js index 9f0aa3fdb..daa1624f3 100644 --- a/test/toCurrency/toCurrency.test.js +++ b/test/toCurrency.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const toCurrency = require('./toCurrency.js'); +const {toCurrency} = require('./_30s.js'); test('toCurrency is a Function', () => { expect(toCurrency).toBeInstanceOf(Function); diff --git a/test/toCurrency/toCurrency.js b/test/toCurrency/toCurrency.js deleted file mode 100644 index 698ad39f2..000000000 --- a/test/toCurrency/toCurrency.js +++ /dev/null @@ -1,3 +0,0 @@ -const toCurrency = (n, curr, LanguageFormat = undefined) => - Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n); -module.exports = toCurrency; diff --git a/test/toDecimalMark/toDecimalMark.test.js b/test/toDecimalMark.test.js similarity index 84% rename from test/toDecimalMark/toDecimalMark.test.js rename to test/toDecimalMark.test.js index 8b287fdbb..eafee7a46 100644 --- a/test/toDecimalMark/toDecimalMark.test.js +++ b/test/toDecimalMark.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const toDecimalMark = require('./toDecimalMark.js'); +const {toDecimalMark} = require('./_30s.js'); test('toDecimalMark is a Function', () => { expect(toDecimalMark).toBeInstanceOf(Function); diff --git a/test/toDecimalMark/toDecimalMark.js b/test/toDecimalMark/toDecimalMark.js deleted file mode 100644 index 839d2b25b..000000000 --- a/test/toDecimalMark/toDecimalMark.js +++ /dev/null @@ -1,2 +0,0 @@ -const toDecimalMark = num => num.toLocaleString('en-US'); -module.exports = toDecimalMark; diff --git a/test/toHash/toHash.test.js b/test/toHash.test.js similarity index 75% rename from test/toHash/toHash.test.js rename to test/toHash.test.js index 27c2b4e2a..7913d0591 100644 --- a/test/toHash/toHash.test.js +++ b/test/toHash.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const toHash = require('./toHash.js'); +const {toHash} = require('./_30s.js'); test('toHash is a Function', () => { expect(toHash).toBeInstanceOf(Function); diff --git a/test/toHash/toHash.js b/test/toHash/toHash.js deleted file mode 100644 index d2a89a847..000000000 --- a/test/toHash/toHash.js +++ /dev/null @@ -1,7 +0,0 @@ -const toHash = (object, key) => - Array.prototype.reduce.call( - object, - (acc, data, index) => ((acc[!key ? index : data[key]] = data), acc), - {} - ); -module.exports = toHash; diff --git a/test/toKebabCase/toKebabCase.test.js b/test/toKebabCase.test.js similarity index 97% rename from test/toKebabCase/toKebabCase.test.js rename to test/toKebabCase.test.js index 38017653e..96df7e01f 100644 --- a/test/toKebabCase/toKebabCase.test.js +++ b/test/toKebabCase.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const toKebabCase = require('./toKebabCase.js'); +const {toKebabCase} = require('./_30s.js'); test('toKebabCase is a Function', () => { expect(toKebabCase).toBeInstanceOf(Function); diff --git a/test/toKebabCase/toKebabCase.js b/test/toKebabCase/toKebabCase.js deleted file mode 100644 index 53e3c8c7f..000000000 --- a/test/toKebabCase/toKebabCase.js +++ /dev/null @@ -1,7 +0,0 @@ -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('-'); -module.exports = toKebabCase; diff --git a/test/toOrdinalSuffix/toOrdinalSuffix.test.js b/test/toOrdinalSuffix.test.js similarity index 90% rename from test/toOrdinalSuffix/toOrdinalSuffix.test.js rename to test/toOrdinalSuffix.test.js index 8bdcb11ac..20e3b7340 100644 --- a/test/toOrdinalSuffix/toOrdinalSuffix.test.js +++ b/test/toOrdinalSuffix.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const toOrdinalSuffix = require('./toOrdinalSuffix.js'); +const {toOrdinalSuffix} = require('./_30s.js'); test('toOrdinalSuffix is a Function', () => { expect(toOrdinalSuffix).toBeInstanceOf(Function); diff --git a/test/toOrdinalSuffix/toOrdinalSuffix.js b/test/toOrdinalSuffix/toOrdinalSuffix.js deleted file mode 100644 index 85dcb7b53..000000000 --- a/test/toOrdinalSuffix/toOrdinalSuffix.js +++ /dev/null @@ -1,11 +0,0 @@ -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]; -}; -module.exports = toOrdinalSuffix; diff --git a/test/toSafeInteger/toSafeInteger.test.js b/test/toSafeInteger.test.js similarity index 96% rename from test/toSafeInteger/toSafeInteger.test.js rename to test/toSafeInteger.test.js index 634d6484f..1706ec306 100644 --- a/test/toSafeInteger/toSafeInteger.test.js +++ b/test/toSafeInteger.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const toSafeInteger = require('./toSafeInteger.js'); +const {toSafeInteger} = require('./_30s.js'); test('toSafeInteger is a Function', () => { expect(toSafeInteger).toBeInstanceOf(Function); diff --git a/test/toSafeInteger/toSafeInteger.js b/test/toSafeInteger/toSafeInteger.js deleted file mode 100644 index f8408387f..000000000 --- a/test/toSafeInteger/toSafeInteger.js +++ /dev/null @@ -1,3 +0,0 @@ -const toSafeInteger = num => - Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER)); -module.exports = toSafeInteger; diff --git a/test/toSnakeCase/toSnakeCase.test.js b/test/toSnakeCase.test.js similarity index 97% rename from test/toSnakeCase/toSnakeCase.test.js rename to test/toSnakeCase.test.js index a07405ee0..53f3ec7d1 100644 --- a/test/toSnakeCase/toSnakeCase.test.js +++ b/test/toSnakeCase.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const toSnakeCase = require('./toSnakeCase.js'); +const {toSnakeCase} = require('./_30s.js'); test('toSnakeCase is a Function', () => { expect(toSnakeCase).toBeInstanceOf(Function); diff --git a/test/toSnakeCase/toSnakeCase.js b/test/toSnakeCase/toSnakeCase.js deleted file mode 100644 index 86c59cbb7..000000000 --- a/test/toSnakeCase/toSnakeCase.js +++ /dev/null @@ -1,7 +0,0 @@ -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('_'); -module.exports = toSnakeCase; diff --git a/test/toggleClass/toggleClass.test.js b/test/toggleClass.test.js similarity index 72% rename from test/toggleClass/toggleClass.test.js rename to test/toggleClass.test.js index 7c0be8524..2ec708391 100644 --- a/test/toggleClass/toggleClass.test.js +++ b/test/toggleClass.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const toggleClass = require('./toggleClass.js'); +const {toggleClass} = require('./_30s.js'); test('toggleClass is a Function', () => { expect(toggleClass).toBeInstanceOf(Function); diff --git a/test/toggleClass/toggleClass.js b/test/toggleClass/toggleClass.js deleted file mode 100644 index 61362e885..000000000 --- a/test/toggleClass/toggleClass.js +++ /dev/null @@ -1,2 +0,0 @@ -const toggleClass = (el, className) => el.classList.toggle(className); -module.exports = toggleClass; diff --git a/test/tomorrow/tomorrow.test.js b/test/tomorrow.test.js similarity index 92% rename from test/tomorrow/tomorrow.test.js rename to test/tomorrow.test.js index 4827289c8..96c2a15e2 100644 --- a/test/tomorrow/tomorrow.test.js +++ b/test/tomorrow.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const tomorrow = require('./tomorrow.js'); +const {tomorrow} = require('./_30s.js'); test('tomorrow is a Function', () => { expect(tomorrow).toBeInstanceOf(Function); diff --git a/test/tomorrow/tomorrow.js b/test/tomorrow/tomorrow.js deleted file mode 100644 index a78e50b47..000000000 --- a/test/tomorrow/tomorrow.js +++ /dev/null @@ -1,9 +0,0 @@ -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`; -}; -module.exports = tomorrow; diff --git a/test/transform/transform.test.js b/test/transform.test.js similarity index 89% rename from test/transform/transform.test.js rename to test/transform.test.js index 075e8345b..b134472f6 100644 --- a/test/transform/transform.test.js +++ b/test/transform.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const transform = require('./transform.js'); +const {transform} = require('./_30s.js'); test('transform is a Function', () => { expect(transform).toBeInstanceOf(Function); diff --git a/test/transform/transform.js b/test/transform/transform.js deleted file mode 100644 index 6381c797b..000000000 --- a/test/transform/transform.js +++ /dev/null @@ -1,2 +0,0 @@ -const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc); -module.exports = transform; diff --git a/test/triggerEvent/triggerEvent.test.js b/test/triggerEvent.test.js similarity index 71% rename from test/triggerEvent/triggerEvent.test.js rename to test/triggerEvent.test.js index 02f0a0e18..13df31d08 100644 --- a/test/triggerEvent/triggerEvent.test.js +++ b/test/triggerEvent.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const triggerEvent = require('./triggerEvent.js'); +const {triggerEvent} = require('./_30s.js'); test('triggerEvent is a Function', () => { expect(triggerEvent).toBeInstanceOf(Function); diff --git a/test/triggerEvent/triggerEvent.js b/test/triggerEvent/triggerEvent.js deleted file mode 100644 index 8c6b1afd6..000000000 --- a/test/triggerEvent/triggerEvent.js +++ /dev/null @@ -1,3 +0,0 @@ -const triggerEvent = (el, eventType, detail) => - el.dispatchEvent(new CustomEvent(eventType, { detail })); -module.exports = triggerEvent; diff --git a/test/truncateString/truncateString.test.js b/test/truncateString.test.js similarity index 82% rename from test/truncateString/truncateString.test.js rename to test/truncateString.test.js index bcbf57a6a..355547b84 100644 --- a/test/truncateString/truncateString.test.js +++ b/test/truncateString.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const truncateString = require('./truncateString.js'); +const {truncateString} = require('./_30s.js'); test('truncateString is a Function', () => { expect(truncateString).toBeInstanceOf(Function); diff --git a/test/truncateString/truncateString.js b/test/truncateString/truncateString.js deleted file mode 100644 index a251353e3..000000000 --- a/test/truncateString/truncateString.js +++ /dev/null @@ -1,3 +0,0 @@ -const truncateString = (str, num) => - str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str; -module.exports = truncateString; diff --git a/test/truthCheckCollection/truthCheckCollection.test.js b/test/truthCheckCollection.test.js similarity index 84% rename from test/truthCheckCollection/truthCheckCollection.test.js rename to test/truthCheckCollection.test.js index c25b5abdb..5f1ddfeb5 100644 --- a/test/truthCheckCollection/truthCheckCollection.test.js +++ b/test/truthCheckCollection.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const truthCheckCollection = require('./truthCheckCollection.js'); +const {truthCheckCollection} = require('./_30s.js'); test('truthCheckCollection is a Function', () => { expect(truthCheckCollection).toBeInstanceOf(Function); diff --git a/test/truthCheckCollection/truthCheckCollection.js b/test/truthCheckCollection/truthCheckCollection.js deleted file mode 100644 index 4308926ac..000000000 --- a/test/truthCheckCollection/truthCheckCollection.js +++ /dev/null @@ -1,2 +0,0 @@ -const truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]); -module.exports = truthCheckCollection; diff --git a/test/unary/unary.test.js b/test/unary.test.js similarity index 86% rename from test/unary/unary.test.js rename to test/unary.test.js index 791924bfc..6503aab98 100644 --- a/test/unary/unary.test.js +++ b/test/unary.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const unary = require('./unary.js'); +const {unary} = require('./_30s.js'); test('unary is a Function', () => { expect(unary).toBeInstanceOf(Function); diff --git a/test/unary/unary.js b/test/unary/unary.js deleted file mode 100644 index 9dda10708..000000000 --- a/test/unary/unary.js +++ /dev/null @@ -1,2 +0,0 @@ -const unary = fn => val => fn(val); -module.exports = unary; diff --git a/test/uncurry/uncurry.test.js b/test/uncurry.test.js similarity index 92% rename from test/uncurry/uncurry.test.js rename to test/uncurry.test.js index 8a5eb4751..8e298929a 100644 --- a/test/uncurry/uncurry.test.js +++ b/test/uncurry.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const uncurry = require('./uncurry.js'); +const {uncurry} = require('./_30s.js'); test('uncurry is a Function', () => { expect(uncurry).toBeInstanceOf(Function); diff --git a/test/uncurry/uncurry.js b/test/uncurry/uncurry.js deleted file mode 100644 index f3bd5e58a..000000000 --- a/test/uncurry/uncurry.js +++ /dev/null @@ -1,6 +0,0 @@ -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)); -}; -module.exports = uncurry; diff --git a/test/unescapeHTML/unescapeHTML.test.js b/test/unescapeHTML.test.js similarity index 85% rename from test/unescapeHTML/unescapeHTML.test.js rename to test/unescapeHTML.test.js index 10237de0b..99248c078 100644 --- a/test/unescapeHTML/unescapeHTML.test.js +++ b/test/unescapeHTML.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const unescapeHTML = require('./unescapeHTML.js'); +const {unescapeHTML} = require('./_30s.js'); test('unescapeHTML is a Function', () => { expect(unescapeHTML).toBeInstanceOf(Function); diff --git a/test/unescapeHTML/unescapeHTML.js b/test/unescapeHTML/unescapeHTML.js deleted file mode 100644 index 43ffa0bf9..000000000 --- a/test/unescapeHTML/unescapeHTML.js +++ /dev/null @@ -1,13 +0,0 @@ -const unescapeHTML = str => - str.replace( - /&|<|>|'|"/g, - tag => - ({ - '&': '&', - '<': '<', - '>': '>', - ''': "'", - '"': '"' - }[tag] || tag) - ); -module.exports = unescapeHTML; diff --git a/test/unflattenObject/unflattenObject.test.js b/test/unflattenObject.test.js similarity index 83% rename from test/unflattenObject/unflattenObject.test.js rename to test/unflattenObject.test.js index 743524974..170f07e0b 100644 --- a/test/unflattenObject/unflattenObject.test.js +++ b/test/unflattenObject.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const unflattenObject = require('./unflattenObject.js'); +const {unflattenObject} = require('./_30s.js'); test('unflattenObject is a Function', () => { expect(unflattenObject).toBeInstanceOf(Function); diff --git a/test/unflattenObject/unflattenObject.js b/test/unflattenObject/unflattenObject.js deleted file mode 100644 index 9b52bad26..000000000 --- a/test/unflattenObject/unflattenObject.js +++ /dev/null @@ -1,17 +0,0 @@ -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; - }, {}); -module.exports = unflattenObject; diff --git a/test/unfold/unfold.test.js b/test/unfold.test.js similarity index 88% rename from test/unfold/unfold.test.js rename to test/unfold.test.js index b8eb61ac7..619dc43d0 100644 --- a/test/unfold/unfold.test.js +++ b/test/unfold.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const unfold = require('./unfold.js'); +const {unfold} = require('./_30s.js'); test('unfold is a Function', () => { expect(unfold).toBeInstanceOf(Function); diff --git a/test/unfold/unfold.js b/test/unfold/unfold.js deleted file mode 100644 index 1f8d84437..000000000 --- a/test/unfold/unfold.js +++ /dev/null @@ -1,7 +0,0 @@ -const unfold = (fn, seed) => { - let result = [], - val = [null, seed]; - while ((val = fn(val[1]))) result.push(val[0]); - return result; -}; -module.exports = unfold; diff --git a/test/union/union.test.js b/test/union.test.js similarity index 97% rename from test/union/union.test.js rename to test/union.test.js index 40e0a690c..93baa5ac7 100644 --- a/test/union/union.test.js +++ b/test/union.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const union = require('./union.js'); +const {union} = require('./_30s.js'); test('union is a Function', () => { expect(union).toBeInstanceOf(Function); diff --git a/test/union/union.js b/test/union/union.js deleted file mode 100644 index c10144580..000000000 --- a/test/union/union.js +++ /dev/null @@ -1,2 +0,0 @@ -const union = (a, b) => Array.from(new Set([...a, ...b])); -module.exports = union; diff --git a/test/unionBy/unionBy.test.js b/test/unionBy.test.js similarity index 85% rename from test/unionBy/unionBy.test.js rename to test/unionBy.test.js index e4f5ed98b..e92e37715 100644 --- a/test/unionBy/unionBy.test.js +++ b/test/unionBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const unionBy = require('./unionBy.js'); +const {unionBy} = require('./_30s.js'); test('unionBy is a Function', () => { expect(unionBy).toBeInstanceOf(Function); diff --git a/test/unionBy/unionBy.js b/test/unionBy/unionBy.js deleted file mode 100644 index e03f9998b..000000000 --- a/test/unionBy/unionBy.js +++ /dev/null @@ -1,5 +0,0 @@ -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)))])); -}; -module.exports = unionBy; diff --git a/test/unionWith/unionWith.test.js b/test/unionWith.test.js similarity index 87% rename from test/unionWith/unionWith.test.js rename to test/unionWith.test.js index 4ad85edeb..f372b4ace 100644 --- a/test/unionWith/unionWith.test.js +++ b/test/unionWith.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const unionWith = require('./unionWith.js'); +const {unionWith} = require('./_30s.js'); test('unionWith is a Function', () => { expect(unionWith).toBeInstanceOf(Function); diff --git a/test/unionWith/unionWith.js b/test/unionWith/unionWith.js deleted file mode 100644 index 1faa0a847..000000000 --- a/test/unionWith/unionWith.js +++ /dev/null @@ -1,3 +0,0 @@ -const unionWith = (a, b, comp) => - Array.from(new Set([...a, ...b.filter(x => a.findIndex(y => comp(x, y)) === -1)])); -module.exports = unionWith; diff --git a/test/uniqueElements/uniqueElements.test.js b/test/uniqueElements.test.js similarity index 97% rename from test/uniqueElements/uniqueElements.test.js rename to test/uniqueElements.test.js index 9b28a5be9..52ae8bd3b 100644 --- a/test/uniqueElements/uniqueElements.test.js +++ b/test/uniqueElements.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const uniqueElements = require('./uniqueElements.js'); +const {uniqueElements} = require('./_30s.js'); test('uniqueElements is a Function', () => { expect(uniqueElements).toBeInstanceOf(Function); diff --git a/test/uniqueElements/uniqueElements.js b/test/uniqueElements/uniqueElements.js deleted file mode 100644 index 17da4091f..000000000 --- a/test/uniqueElements/uniqueElements.js +++ /dev/null @@ -1,2 +0,0 @@ -const uniqueElements = arr => [...new Set(arr)]; -module.exports = uniqueElements; diff --git a/test/uniqueElementsBy/uniqueElementsBy.test.js b/test/uniqueElementsBy.test.js similarity index 94% rename from test/uniqueElementsBy/uniqueElementsBy.test.js rename to test/uniqueElementsBy.test.js index 5ff75d831..256eae523 100644 --- a/test/uniqueElementsBy/uniqueElementsBy.test.js +++ b/test/uniqueElementsBy.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const uniqueElementsBy = require('./uniqueElementsBy.js'); +const {uniqueElementsBy} = require('./_30s.js'); test('uniqueElementsBy is a Function', () => { expect(uniqueElementsBy).toBeInstanceOf(Function); diff --git a/test/uniqueElementsBy/uniqueElementsBy.js b/test/uniqueElementsBy/uniqueElementsBy.js deleted file mode 100644 index 151471448..000000000 --- a/test/uniqueElementsBy/uniqueElementsBy.js +++ /dev/null @@ -1,6 +0,0 @@ -const uniqueElementsBy = (arr, fn) => - arr.reduce((acc, v) => { - if (!acc.some(x => fn(v, x))) acc.push(v); - return acc; - }, []); -module.exports = uniqueElementsBy; diff --git a/test/uniqueElementsByRight/uniqueElementsByRight.test.js b/test/uniqueElementsByRight.test.js similarity index 93% rename from test/uniqueElementsByRight/uniqueElementsByRight.test.js rename to test/uniqueElementsByRight.test.js index 9e324ef1f..4340dd2b1 100644 --- a/test/uniqueElementsByRight/uniqueElementsByRight.test.js +++ b/test/uniqueElementsByRight.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const uniqueElementsByRight = require('./uniqueElementsByRight.js'); +const {uniqueElementsByRight} = require('./_30s.js'); test('uniqueElementsByRight is a Function', () => { expect(uniqueElementsByRight).toBeInstanceOf(Function); diff --git a/test/uniqueElementsByRight/uniqueElementsByRight.js b/test/uniqueElementsByRight/uniqueElementsByRight.js deleted file mode 100644 index 8f114ebf9..000000000 --- a/test/uniqueElementsByRight/uniqueElementsByRight.js +++ /dev/null @@ -1,6 +0,0 @@ -const uniqueElementsByRight = (arr, fn) => - arr.reduceRight((acc, v) => { - if (!acc.some(x => fn(v, x))) acc.push(v); - return acc; - }, []); -module.exports = uniqueElementsByRight; diff --git a/test/uniqueSymmetricDifference/uniqueSymmetricDifference.test.js b/test/uniqueSymmetricDifference.test.js similarity index 85% rename from test/uniqueSymmetricDifference/uniqueSymmetricDifference.test.js rename to test/uniqueSymmetricDifference.test.js index 788d1f65e..d9fa598b6 100644 --- a/test/uniqueSymmetricDifference/uniqueSymmetricDifference.test.js +++ b/test/uniqueSymmetricDifference.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const uniqueSymmetricDifference = require('./uniqueSymmetricDifference.js'); +const {uniqueSymmetricDifference} = require('./_30s.js'); test('uniqueSymmetricDifference is a Function', () => { expect(uniqueSymmetricDifference).toBeInstanceOf(Function); diff --git a/test/uniqueSymmetricDifference/uniqueSymmetricDifference.js b/test/uniqueSymmetricDifference/uniqueSymmetricDifference.js deleted file mode 100644 index 62cb18a5f..000000000 --- a/test/uniqueSymmetricDifference/uniqueSymmetricDifference.js +++ /dev/null @@ -1,4 +0,0 @@ -const uniqueSymmetricDifference = (a, b) => [ - ...new Set([...a.filter(v => !b.includes(v)), ...b.filter(v => !a.includes(v))]) -]; -module.exports = uniqueSymmetricDifference; diff --git a/test/untildify/untildify.test.js b/test/untildify.test.js similarity index 91% rename from test/untildify/untildify.test.js rename to test/untildify.test.js index d8e3134e1..3e0c934c3 100644 --- a/test/untildify/untildify.test.js +++ b/test/untildify.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const untildify = require('./untildify.js'); +const {untildify} = require('./_30s.js'); test('untildify is a Function', () => { expect(untildify).toBeInstanceOf(Function); diff --git a/test/untildify/untildify.js b/test/untildify/untildify.js deleted file mode 100644 index 4dd64d3b1..000000000 --- a/test/untildify/untildify.js +++ /dev/null @@ -1,2 +0,0 @@ -const untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`); -module.exports = untildify; diff --git a/test/unzip/unzip.test.js b/test/unzip.test.js similarity index 92% rename from test/unzip/unzip.test.js rename to test/unzip.test.js index b8c67f6e7..770cec738 100644 --- a/test/unzip/unzip.test.js +++ b/test/unzip.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const unzip = require('./unzip.js'); +const {unzip} = require('./_30s.js'); test('unzip is a Function', () => { expect(unzip).toBeInstanceOf(Function); diff --git a/test/unzip/unzip.js b/test/unzip/unzip.js deleted file mode 100644 index 4aa9c5965..000000000 --- a/test/unzip/unzip.js +++ /dev/null @@ -1,8 +0,0 @@ -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 => []) - ); -module.exports = unzip; diff --git a/test/unzipWith/unzipWith.test.js b/test/unzipWith.test.js similarity index 89% rename from test/unzipWith/unzipWith.test.js rename to test/unzipWith.test.js index 8a439000c..9ba060eb8 100644 --- a/test/unzipWith/unzipWith.test.js +++ b/test/unzipWith.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const unzipWith = require('./unzipWith.js'); +const {unzipWith} = require('./_30s.js'); test('unzipWith is a Function', () => { expect(unzipWith).toBeInstanceOf(Function); diff --git a/test/unzipWith/unzipWith.js b/test/unzipWith/unzipWith.js deleted file mode 100644 index 7c94b6875..000000000 --- a/test/unzipWith/unzipWith.js +++ /dev/null @@ -1,10 +0,0 @@ -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)); -module.exports = unzipWith; diff --git a/test/validateNumber/validateNumber.test.js b/test/validateNumber.test.js similarity index 96% rename from test/validateNumber/validateNumber.test.js rename to test/validateNumber.test.js index 2d009afae..c50b6f578 100644 --- a/test/validateNumber/validateNumber.test.js +++ b/test/validateNumber.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const validateNumber = require('./validateNumber.js'); +const {validateNumber} = require('./_30s.js'); test('validateNumber is a Function', () => { expect(validateNumber).toBeInstanceOf(Function); diff --git a/test/validateNumber/validateNumber.js b/test/validateNumber/validateNumber.js deleted file mode 100644 index 691081f8e..000000000 --- a/test/validateNumber/validateNumber.js +++ /dev/null @@ -1,2 +0,0 @@ -const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; -module.exports = validateNumber; diff --git a/test/when/when.test.js b/test/when.test.js similarity index 90% rename from test/when/when.test.js rename to test/when.test.js index 5ea4c3baf..d4da63014 100644 --- a/test/when/when.test.js +++ b/test/when.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const when = require('./when.js'); +const {when} = require('./_30s.js'); test('when is a Function', () => { expect(when).toBeInstanceOf(Function); diff --git a/test/when/when.js b/test/when/when.js deleted file mode 100644 index 57055511f..000000000 --- a/test/when/when.js +++ /dev/null @@ -1,2 +0,0 @@ -const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x); -module.exports = when; diff --git a/test/without/without.test.js b/test/without.test.js similarity index 96% rename from test/without/without.test.js rename to test/without.test.js index 21a9684df..72e0f3b2a 100644 --- a/test/without/without.test.js +++ b/test/without.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const without = require('./without.js'); +const {without} = require('./_30s.js'); test('without is a Function', () => { expect(without).toBeInstanceOf(Function); diff --git a/test/without/without.js b/test/without/without.js deleted file mode 100644 index c17d28369..000000000 --- a/test/without/without.js +++ /dev/null @@ -1,2 +0,0 @@ -const without = (arr, ...args) => arr.filter(v => !args.includes(v)); -module.exports = without; diff --git a/test/words/words.test.js b/test/words.test.js similarity index 96% rename from test/words/words.test.js rename to test/words.test.js index 4ed2c9e9f..18f675e33 100644 --- a/test/words/words.test.js +++ b/test/words.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const words = require('./words.js'); +const {words} = require('./_30s.js'); test('words is a Function', () => { expect(words).toBeInstanceOf(Function); diff --git a/test/words/words.js b/test/words/words.js deleted file mode 100644 index f7a51417a..000000000 --- a/test/words/words.js +++ /dev/null @@ -1,2 +0,0 @@ -const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); -module.exports = words; diff --git a/test/xProd/xProd.test.js b/test/xProd.test.js similarity index 88% rename from test/xProd/xProd.test.js rename to test/xProd.test.js index 2b6f00116..ce283f333 100644 --- a/test/xProd/xProd.test.js +++ b/test/xProd.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const xProd = require('./xProd.js'); +const {xProd} = require('./_30s.js'); test('xProd is a Function', () => { expect(xProd).toBeInstanceOf(Function); diff --git a/test/xProd/xProd.js b/test/xProd/xProd.js deleted file mode 100644 index b98865854..000000000 --- a/test/xProd/xProd.js +++ /dev/null @@ -1,2 +0,0 @@ -const xProd = (a, b) => a.reduce((acc, x) => acc.concat(b.map(y => [x, y])), []); -module.exports = xProd; diff --git a/test/yesNo/yesNo.test.js b/test/yesNo.test.js similarity index 96% rename from test/yesNo/yesNo.test.js rename to test/yesNo.test.js index 9bc825531..650518033 100644 --- a/test/yesNo/yesNo.test.js +++ b/test/yesNo.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const yesNo = require('./yesNo.js'); +const {yesNo} = require('./_30s.js'); test('yesNo is a Function', () => { expect(yesNo).toBeInstanceOf(Function); diff --git a/test/yesNo/yesNo.js b/test/yesNo/yesNo.js deleted file mode 100644 index 5e318eec4..000000000 --- a/test/yesNo/yesNo.js +++ /dev/null @@ -1,3 +0,0 @@ -const yesNo = (val, def = false) => - /^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def; -module.exports = yesNo; diff --git a/test/zip/zip.test.js b/test/zip.test.js similarity index 96% rename from test/zip/zip.test.js rename to test/zip.test.js index 90a291cb2..37ecb8053 100644 --- a/test/zip/zip.test.js +++ b/test/zip.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const zip = require('./zip.js'); +const {zip} = require('./_30s.js'); test('zip is a Function', () => { expect(zip).toBeInstanceOf(Function); diff --git a/test/zip/zip.js b/test/zip/zip.js deleted file mode 100644 index 29dd6e79c..000000000 --- a/test/zip/zip.js +++ /dev/null @@ -1,7 +0,0 @@ -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]); - }); -}; -module.exports = zip; diff --git a/test/zipObject/zipObject.test.js b/test/zipObject.test.js similarity index 96% rename from test/zipObject/zipObject.test.js rename to test/zipObject.test.js index abdc07d77..f8cc69864 100644 --- a/test/zipObject/zipObject.test.js +++ b/test/zipObject.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const zipObject = require('./zipObject.js'); +const {zipObject} = require('./_30s.js'); test('zipObject is a Function', () => { expect(zipObject).toBeInstanceOf(Function); diff --git a/test/zipObject/zipObject.js b/test/zipObject/zipObject.js deleted file mode 100644 index 3a670fefa..000000000 --- a/test/zipObject/zipObject.js +++ /dev/null @@ -1,3 +0,0 @@ -const zipObject = (props, values) => - props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {}); -module.exports = zipObject; diff --git a/test/zipWith/zipWith.test.js b/test/zipWith.test.js similarity index 74% rename from test/zipWith/zipWith.test.js rename to test/zipWith.test.js index 3cffd0a46..663be4604 100644 --- a/test/zipWith/zipWith.test.js +++ b/test/zipWith.test.js @@ -1,5 +1,5 @@ const expect = require('expect'); -const zipWith = require('./zipWith.js'); +const {zipWith} = require('./_30s.js'); test('zipWith is a Function', () => { expect(zipWith).toBeInstanceOf(Function); diff --git a/test/zipWith/zipWith.js b/test/zipWith/zipWith.js deleted file mode 100644 index 9a6a1e926..000000000 --- a/test/zipWith/zipWith.js +++ /dev/null @@ -1,8 +0,0 @@ -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 = zipWith;