diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fc5760ff8..a44c16ba7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,14 +38,17 @@ Here's what you can do to help: - You can start creating a new snippet, by using the [snippet template](snippet-template.md) to format your snippets. ### Writing tests -- Before writing any tests run `npm run tdd` script. It will update test directory to include new snippets as well as update old ones if needed. +- Before writing any tests run `npm run tester` script. It will update test directory to include new snippets as well as update old ones if needed. - **DO NOT MODIFY THE snippetName.js files** under test directory. - We are using [tape](https://github.com/substack/tape) for testing. - Write tests under `snippetName.test.js` file. If you have trouble doing so, check out tests of other snippets. - Be sure to run `npm run test`. It is going to run all tests for all snippets. - Make a new pull request **only if all the tests are passing**. - +#### Browser specific tests +- If your snippet belongs to `browser` category, then you will need to modify the tests to make them work. +- By default, `Node.js` isn't browser environment. That said we have to use an external package to help us simulate the browser for our tests. +- We use [jsdom](https://www.npmjs.com/package/jsdom) for our browser specific tests. You can find their [documentation](https://github.com/jsdom/jsdom) on GitHub as well. ### Additional guidelines and conventions regarding snippets diff --git a/README.md b/README.md index 92f8a301f..923e59745 100644 --- a/README.md +++ b/README.md @@ -82,8 +82,11 @@ average(1, 2, 3); * [`collectInto`](#collectinto) * [`flip`](#flip) * [`over`](#over) +* [`overArgs`](#overargs) +* [`pipeAsyncFunctions`](#pipeasyncfunctions) * [`pipeFunctions`](#pipefunctions) * [`promisify`](#promisify) +* [`rearg`](#rearg) * [`spreadOver`](#spreadover) * [`unary`](#unary) @@ -219,12 +222,14 @@ average(1, 2, 3);
View contents +* [`attempt`](#attempt) * [`bind`](#bind) * [`bindKey`](#bindkey) * [`chainAsync`](#chainasync) * [`compose`](#compose) * [`composeRight`](#composeright) * [`curry`](#curry) +* [`debounce`](#debounce) * [`defer`](#defer) * [`delay`](#delay) * [`functionName`](#functionname) @@ -235,6 +240,7 @@ average(1, 2, 3); * [`partialRight`](#partialright) * [`runPromisesInSeries`](#runpromisesinseries) * [`sleep`](#sleep) +* [`throttle`](#throttle) * [`times`](#times) * [`unfold`](#unfold) @@ -495,7 +501,7 @@ const Pall = collectInto(Promise.all.bind(Promise)); let p1 = Promise.resolve(1); let p2 = Promise.resolve(2); let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3)); -Pall(p1, p2, p3).then(console.log); +Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds) ```
@@ -554,6 +560,66 @@ minMax(1, 2, 3, 4, 5); // [1,5]
[⬆ Back to top](#table-of-contents) +### overArgs + +Creates a function that invokes the provided function with its arguments transformed. + +Use `Array.map()` to apply `transforms` to `args` in combination with the spread operator (`...`) to pass the transformed arguments to `fn`. + +```js +const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val))); +``` + +
+Examples + +```js +var func = overArgs( + function(x, y) { + return [x, y]; + }, + [square, doubled] +); +func(9, 3); // [81, 6] +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + +### pipeAsyncFunctions + +Performs left-to-right function composition for asynchronous functions. + +Use `Array.reduce()` with the spread operator (`...`) to perform left-to-right function composition using `Promise.then()`. +The functions can return a combination of: simple values, `Promise`'s, or they can be defined as `async` ones returning through `await`. +All functions must be unary. + +```js +const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg)); +``` + +
+Examples + +```js +const sum = pipeAsyncFunctions( + x => x + 1, + x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)), + x => x + 3, + async x => (await x) + 4 +); +(async () => { + console.log(await sum(5)); // 15 (after one second) +})(); +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### pipeFunctions Performs left-to-right function composition. @@ -609,6 +675,40 @@ delay(2000).then(() => console.log('Hi!')); // // Promise resolves after 2s
[⬆ Back to top](#table-of-contents) +### rearg + +Creates a function that invokes the provided function with its arguments arranged according to the specified indexes. + +Use `Array.reduce()` and `Array.indexOf()` to reorder arguments based on `indexes` in combination with the spread operator (`...`) to pass the transformed arguments to `fn`. + +```js +const rearg = (fn, indexes) => (...args) => + fn( + ...args.reduce( + (acc, val, i) => ((acc[indexes.indexOf(i)] = val), acc), + Array.from({ length: indexes.length }) + ) + ); +``` + +
+Examples + +```js +var rearged = rearg( + function(a, b, c) { + return [a, b, c]; + }, + [2, 0, 1] +); +rearged('b', 'c', 'a'); // ['a', 'b', 'c'] +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### spreadOver Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. @@ -3432,6 +3532,37 @@ tomorrow(); // 2017-12-27 (if current date is 2017-12-26) --- ## 🎛️ Function +### attempt + +Attempts to invoke a function with the provided arguments, returning either the result or the caught error object. + +Use a `try... catch` block to return either the result of the function or an appropriate error. + +```js +const attempt = (fn, ...args) => { + try { + return fn(args); + } catch (e) { + return e instanceof Error ? e : new Error(e); + } +}; +``` + +
+Examples + +```js +var elements = attempt(function(selector) { + return document.querySelectorAll(selector); +}, '>_>'); +if (elements instanceof Error) elements = []; // elements = [] +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### bind Creates a function that invokes `fn` with a given context, optionally adding any additional supplied parameters to the beginning of the arguments. @@ -3609,6 +3740,44 @@ curry(Math.min, 3)(10)(50)(2); // 2
[⬆ Back to top](#table-of-contents) +### debounce + +Creates a debounced function that delays invoking the provided function until after `wait` milliseconds have elapsed since the last time the debounced function was invoked. + +Use `setTimeout()` and `clearTimeout()` to debounce the given method, `fn`. +Use `Function.apply()` to apply the `this` context to the function and provide the necessary `arguments`. +Omit the second argument, `wait`, to set the timeout at a default of 0 ms. + +```js +const debounce = (fn, wait = 0) => { + let inDebounce; + return function() { + const context = this, + args = arguments; + clearTimeout(inDebounce); + inDebounce = setTimeout(() => fn.apply(context, args), wait); + }; +}; +``` + +
+Examples + +```js +window.addEventListener( + 'resize', + debounce(function(evt) { + console.log(window.innerWidth); + console.log(window.innerHeight); + }, 250) +); // Will log the window dimensions at most every 250ms +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### defer Defers invoking a function until the current call stack has cleared. @@ -3879,6 +4048,56 @@ async function sleepyWork() {
[⬆ Back to top](#table-of-contents) +### throttle + +Creates a throttled function that only invokes the provided function at most once per every `wait` milliseconds + +Use `setTimeout()` and `clearTimeout()` to throttle the given method, `fn`. +Use `Function.apply()` to apply the `this` context to the function and provide the necessary `arguments`. +Use `Date.now()` to keep track of the last time the throttled function was invoked. +Omit the second argument, `wait`, to set the timeout at a default of 0 ms. + +```js +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)); + } + }; +}; +``` + +
+Examples + +```js +window.addEventListener( + 'resize', + throttle(function(evt) { + console.log(window.innerWidth); + console.log(window.innerHeight); + }, 250) +); // Will log the window dimensions at most every 250ms +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### times Iterates over a callback `n` times @@ -5095,17 +5314,17 @@ UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc' ### bindAll -Explain briefly what the snippet does. - Use `Array.forEach()` to return a `function` that uses `Function.apply()` to apply the given context (`obj`) to `fn` for each function specified. ```js const bindAll = (obj, ...fns) => fns.forEach( - fn => + fn => ( + (f = obj[fn]), (obj[fn] = function() { - return fn.apply(obj); + return f.apply(obj); }) + ) ); ``` diff --git a/dist/_30s.es5.js b/dist/_30s.es5.js index 11b8b485c..8678bbec3 100644 --- a/dist/_30s.es5.js +++ b/dist/_30s.es5.js @@ -65,6 +65,18 @@ var atob = function atob(str) { return new Buffer(str, 'base64').toString('binary'); }; +var attempt = function attempt(fn) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + try { + return fn(args); + } catch (e) { + return e instanceof Error ? e : new Error(e); + } +}; + var average = function average() { for (var _len = arguments.length, nums = Array(_len), _key = 0; _key < _len; _key++) { nums[_key] = arguments[_key]; @@ -99,8 +111,8 @@ var bindAll = function bindAll(obj) { } return fns.forEach(function (fn) { - return obj[fn] = function () { - return fn.apply(obj); + return f = obj[fn], obj[fn] = function () { + return f.apply(obj); }; }); }; @@ -335,6 +347,20 @@ var curry = function curry(fn) { return arity <= args.length ? fn.apply(undefined, args) : curry.bind.apply(curry, [null, fn, arity].concat(args)); }; +var debounce = function debounce(fn) { + var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + + var inDebounce = void 0; + return function () { + var context = this, + args = arguments; + clearTimeout(inDebounce); + inDebounce = setTimeout(function () { + return fn.apply(context, args); + }, wait); + }; +}; + function _toArray$1(arr) { return Array.isArray(arr) ? arr : Array.from(arr); } var decapitalize = function decapitalize(_ref) { @@ -1376,6 +1402,20 @@ var over = function over() { }; }; +function _toConsumableArray$13(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var overArgs = function overArgs(fn, transforms) { + return function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return fn.apply(undefined, _toConsumableArray$13(args.map(function (val, i) { + return transforms[i](val); + }))); + }; +}; + var palindrome = function palindrome(str) { var s = str.toLowerCase().replace(/[\W_]/g, ''); return s === s.split('').reverse().join(''); @@ -1445,6 +1485,18 @@ var pickBy = function pickBy(obj, fn) { }, {}); }; +var pipeAsyncFunctions = function pipeAsyncFunctions() { + for (var _len = arguments.length, fns = Array(_len), _key = 0; _key < _len; _key++) { + fns[_key] = arguments[_key]; + } + + return function (arg) { + return fns.reduce(function (p, f) { + return p.then(f); + }, Promise.resolve(arg)); + }; +}; + var pipeFunctions = function pipeFunctions() { for (var _len = arguments.length, fns = Array(_len), _key = 0; _key < _len; _key++) { fns[_key] = arguments[_key]; @@ -1610,6 +1662,20 @@ var readFileLines = function readFileLines(filename) { return fs$1.readFileSync(filename).toString('UTF8').split('\n'); }; +function _toConsumableArray$14(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var rearg = function rearg(fn, indexes) { + return function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return fn.apply(undefined, _toConsumableArray$14(args.reduce(function (acc, val, i) { + return acc[indexes.indexOf(i)] = val, acc; + }, Array.from({ length: indexes.length })))); + }; +}; + var redirect = function redirect(url) { var asLink = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; return asLink ? window.location.href = url : window.location.replace(url); @@ -1650,10 +1716,10 @@ var removeNonASCII = function removeNonASCII(str) { return str.replace(/[^\x20-\x7E]/g, ''); }; -function _toConsumableArray$13(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$15(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var reverseString = function reverseString(str) { - return [].concat(_toConsumableArray$13(str)).reverse().join(''); + return [].concat(_toConsumableArray$15(str)).reverse().join(''); }; var round = function round(n) { @@ -1777,10 +1843,10 @@ var sleep = function sleep(ms) { }); }; -function _toConsumableArray$14(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$16(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var sortCharactersInString = function sortCharactersInString(str) { - return [].concat(_toConsumableArray$14(str)).sort(function (a, b) { + return [].concat(_toConsumableArray$16(str)).sort(function (a, b) { return a.localeCompare(b); }).join(''); }; @@ -1827,11 +1893,11 @@ var splitLines = function splitLines(str) { return str.split(/\r?\n/); }; -function _toConsumableArray$15(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$17(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var spreadOver = function spreadOver(fn) { return function (argsArr) { - return fn.apply(undefined, _toConsumableArray$15(argsArr)); + return fn.apply(undefined, _toConsumableArray$17(argsArr)); }; }; @@ -1880,19 +1946,19 @@ var sumPower = function sumPower(end) { }, 0); }; -function _toConsumableArray$16(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$18(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var symmetricDifference = function symmetricDifference(a, b) { var sA = new Set(a), sB = new Set(b); - return [].concat(_toConsumableArray$16(a.filter(function (x) { + return [].concat(_toConsumableArray$18(a.filter(function (x) { return !sB.has(x); - })), _toConsumableArray$16(b.filter(function (x) { + })), _toConsumableArray$18(b.filter(function (x) { return !sA.has(x); }))); }; -function _toConsumableArray$17(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$19(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var symmetricDifferenceBy = function symmetricDifferenceBy(a, b, fn) { var sA = new Set(a.map(function (v) { @@ -1901,21 +1967,21 @@ var symmetricDifferenceBy = function symmetricDifferenceBy(a, b, fn) { sB = new Set(b.map(function (v) { return fn(v); })); - return [].concat(_toConsumableArray$17(a.filter(function (x) { + return [].concat(_toConsumableArray$19(a.filter(function (x) { return !sB.has(fn(x)); - })), _toConsumableArray$17(b.filter(function (x) { + })), _toConsumableArray$19(b.filter(function (x) { return !sA.has(fn(x)); }))); }; -function _toConsumableArray$18(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$20(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var symmetricDifferenceWith = function symmetricDifferenceWith(arr, val, comp) { - return [].concat(_toConsumableArray$18(arr.filter(function (a) { + return [].concat(_toConsumableArray$20(arr.filter(function (a) { return val.findIndex(function (b) { return comp(a, b); }) === -1; - })), _toConsumableArray$18(val.filter(function (a) { + })), _toConsumableArray$20(val.filter(function (a) { return arr.findIndex(function (b) { return comp(a, b); }) === -1; @@ -1993,6 +2059,29 @@ var takeWhile = function takeWhile(arr, func) { return arr; }; +var throttle = function throttle(fn, wait) { + var inThrottle = void 0, + lastFn = void 0, + lastTime = void 0; + return function () { + var 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)); + } + }; +}; + var timeTaken = function timeTaken(callback) { console.time('timeTaken'); var r = callback(); @@ -2095,44 +2184,44 @@ var unfold = function unfold(fn, seed) { }return result; }; -function _toConsumableArray$19(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$21(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var union = function union(a, b) { - return Array.from(new Set([].concat(_toConsumableArray$19(a), _toConsumableArray$19(b)))); + return Array.from(new Set([].concat(_toConsumableArray$21(a), _toConsumableArray$21(b)))); }; -function _toConsumableArray$20(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$22(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var unionBy = function unionBy(a, b, fn) { var s = new Set(a.map(function (v) { return fn(v); })); - return Array.from(new Set([].concat(_toConsumableArray$20(a), _toConsumableArray$20(b.filter(function (x) { + return Array.from(new Set([].concat(_toConsumableArray$22(a), _toConsumableArray$22(b.filter(function (x) { return !s.has(fn(x)); }))))); }; -function _toConsumableArray$21(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$23(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var unionWith = function unionWith(a, b, comp) { - return Array.from(new Set([].concat(_toConsumableArray$21(a), _toConsumableArray$21(b.filter(function (x) { + return Array.from(new Set([].concat(_toConsumableArray$23(a), _toConsumableArray$23(b.filter(function (x) { return a.findIndex(function (y) { return comp(x, y); }) === -1; }))))); }; -function _toConsumableArray$22(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$24(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var uniqueElements = function uniqueElements(arr) { - return [].concat(_toConsumableArray$22(new Set(arr))); + return [].concat(_toConsumableArray$24(new Set(arr))); }; var untildify = function untildify(str) { return str.replace(/^~($|\/|\\)/, (typeof require !== "undefined" && require('os').homedir()) + "$1"); }; -function _toConsumableArray$23(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$25(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var unzip = function unzip(arr) { return arr.reduce(function (acc, val) { @@ -2140,7 +2229,7 @@ var unzip = function unzip(arr) { return acc[i].push(v); }), acc; }, Array.from({ - length: Math.max.apply(Math, _toConsumableArray$23(arr.map(function (x) { + length: Math.max.apply(Math, _toConsumableArray$25(arr.map(function (x) { return x.length; }))) }).map(function (x) { @@ -2148,7 +2237,7 @@ var unzip = function unzip(arr) { })); }; -function _toConsumableArray$24(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$26(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var unzipWith = function unzipWith(arr, fn) { return arr.reduce(function (acc, val) { @@ -2156,13 +2245,13 @@ var unzipWith = function unzipWith(arr, fn) { return acc[i].push(v); }), acc; }, Array.from({ - length: Math.max.apply(Math, _toConsumableArray$24(arr.map(function (x) { + length: Math.max.apply(Math, _toConsumableArray$26(arr.map(function (x) { return x.length; }))) }).map(function (x) { return []; })).map(function (val) { - return fn.apply(undefined, _toConsumableArray$24(val)); + return fn.apply(undefined, _toConsumableArray$26(val)); }); }; @@ -2199,14 +2288,14 @@ var yesNo = function yesNo(val) { ); }; -function _toConsumableArray$25(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$27(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var zip = function zip() { for (var _len = arguments.length, arrays = Array(_len), _key = 0; _key < _len; _key++) { arrays[_key] = arguments[_key]; } - var maxLength = Math.max.apply(Math, _toConsumableArray$25(arrays.map(function (x) { + var maxLength = Math.max.apply(Math, _toConsumableArray$27(arrays.map(function (x) { return x.length; }))); return Array.from({ length: maxLength }).map(function (_, i) { @@ -2222,7 +2311,7 @@ var zipObject = function zipObject(props, values) { }, {}); }; -function _toConsumableArray$26(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$28(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var zipWith = function zipWith() { for (var _len = arguments.length, arrays = Array(_len), _key = 0; _key < _len; _key++) { @@ -2232,7 +2321,7 @@ var zipWith = function zipWith() { var length = arrays.length; var fn = length > 1 ? arrays[length - 1] : undefined; fn = typeof fn == 'function' ? (arrays.pop(), fn) : undefined; - var maxLength = Math.max.apply(Math, _toConsumableArray$26(arrays.map(function (x) { + var maxLength = Math.max.apply(Math, _toConsumableArray$28(arrays.map(function (x) { return x.length; }))); var result = Array.from({ length: maxLength }).map(function (_, i) { @@ -2241,11 +2330,11 @@ var zipWith = function zipWith() { }); }); return fn ? result.map(function (arr) { - return fn.apply(undefined, _toConsumableArray$26(arr)); + return fn.apply(undefined, _toConsumableArray$28(arr)); }) : result; }; -var imports = { JSONToFile: JSONToFile, RGBToHex: RGBToHex, URLJoin: URLJoin, UUIDGeneratorBrowser: UUIDGeneratorBrowser, UUIDGeneratorNode: UUIDGeneratorNode, anagrams: anagrams, arrayToHtmlList: arrayToHtmlList, ary: ary, atob: atob, average: average, averageBy: averageBy, bind: bind, bindAll: bindAll, bindKey: bindKey, 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, copyToClipboard: copyToClipboard, countBy: countBy, countOccurrences: countOccurrences, createElement: createElement, createEventHub: createEventHub, currentURL: currentURL, curry: curry, decapitalize: decapitalize, deepClone: deepClone, deepFlatten: deepFlatten, defaults: defaults, defer: defer, delay: delay, detectDeviceType: detectDeviceType, difference: difference, differenceBy: differenceBy, differenceWith: differenceWith, digitize: digitize, distance: distance, drop: drop, dropRight: dropRight, dropRightWhile: dropRightWhile, dropWhile: dropWhile, elementIsVisibleInViewport: elementIsVisibleInViewport, elo: elo, equals: equals, escapeHTML: escapeHTML, escapeRegExp: escapeRegExp, everyNth: everyNth, extendHex: extendHex, factorial: factorial, fibonacci: fibonacci, filterNonUnique: filterNonUnique, findKey: findKey, findLast: findLast, findLastIndex: findLastIndex, findLastKey: findLastKey, flatten: flatten, flip: flip, forEachRight: forEachRight, forOwn: forOwn, forOwnRight: forOwnRight, formatDuration: formatDuration, fromCamelCase: fromCamelCase, functionName: functionName, functions: functions, gcd: gcd, geometricProgression: geometricProgression, get: get, getDaysDiffBetweenDates: getDaysDiffBetweenDates, 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, inRange: inRange, indexOfAll: indexOfAll, initial: initial, initialize2DArray: initialize2DArray, initializeArrayWithRange: initializeArrayWithRange, initializeArrayWithRangeRight: initializeArrayWithRangeRight, initializeArrayWithValues: initializeArrayWithValues, intersection: intersection, intersectionBy: intersectionBy, intersectionWith: intersectionWith, invertKeyValues: invertKeyValues, is: is, isAbsoluteURL: isAbsoluteURL, isArrayLike: isArrayLike, isBoolean: isBoolean, isDivisible: isDivisible, 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, isSorted: isSorted, isString: isString, isSymbol: isSymbol, isTravisCI: isTravisCI, isUndefined: isUndefined, isUpperCase: isUpperCase, isValidJSON: isValidJSON, join: join, last: last, lcm: lcm, longestItem: longestItem, lowercaseKeys: lowercaseKeys, luhnCheck: luhnCheck, mapKeys: mapKeys, mapObject: mapObject, mapValues: mapValues, mask: mask, matches: matches, matchesWith: matchesWith, maxBy: maxBy, maxN: maxN, median: median, memoize: memoize, merge: merge, minBy: minBy, minN: minN, negate: negate, nthArg: nthArg, nthElement: nthElement, objectFromPairs: objectFromPairs, objectToPairs: objectToPairs, observeMutations: observeMutations, off: off, omit: omit, omitBy: omitBy, on: on, onUserInputChange: onUserInputChange, once: once, orderBy: orderBy, over: over, palindrome: palindrome, parseCookie: parseCookie, partial: partial, partialRight: partialRight, partition: partition, percentile: percentile, pick: pick, pickBy: pickBy, pipeFunctions: pipeFunctions, pluralize: pluralize, powerset: powerset, prettyBytes: prettyBytes, primes: primes, promisify: promisify, pull: pull, pullAtIndex: pullAtIndex, pullAtValue: pullAtValue, pullBy: pullBy, randomHexColorCode: randomHexColorCode, randomIntArrayInRange: randomIntArrayInRange, randomIntegerInRange: randomIntegerInRange, randomNumberInRange: randomNumberInRange, readFileLines: readFileLines, redirect: redirect, reduceSuccessive: reduceSuccessive, reduceWhich: reduceWhich, reducedFilter: reducedFilter, remove: remove, removeNonASCII: removeNonASCII, reverseString: reverseString, round: round, runAsync: runAsync, runPromisesInSeries: runPromisesInSeries, sample: sample, sampleSize: sampleSize, scrollToTop: scrollToTop, sdbm: sdbm, serializeCookie: serializeCookie, setStyle: setStyle, shallowClone: shallowClone, show: show, shuffle: shuffle, similarity: similarity, size: size, sleep: sleep, sortCharactersInString: sortCharactersInString, sortedIndex: sortedIndex, sortedIndexBy: sortedIndexBy, sortedLastIndex: sortedLastIndex, sortedLastIndexBy: sortedLastIndexBy, splitLines: splitLines, spreadOver: spreadOver, standardDeviation: standardDeviation, stripHTMLTags: stripHTMLTags, sum: sum, sumBy: sumBy, sumPower: sumPower, symmetricDifference: symmetricDifference, symmetricDifferenceBy: symmetricDifferenceBy, symmetricDifferenceWith: symmetricDifferenceWith, tail: tail, take: take, takeRight: takeRight, takeRightWhile: takeRightWhile, takeWhile: takeWhile, timeTaken: timeTaken, times: times, toCamelCase: toCamelCase, toDecimalMark: toDecimalMark, toKebabCase: toKebabCase, toOrdinalSuffix: toOrdinalSuffix, toSafeInteger: toSafeInteger, toSnakeCase: toSnakeCase, toggleClass: toggleClass, tomorrow: tomorrow, transform: transform, truncateString: truncateString, truthCheckCollection: truthCheckCollection, unary: unary, unescapeHTML: unescapeHTML, unfold: unfold, union: union, unionBy: unionBy, unionWith: unionWith, uniqueElements: uniqueElements, untildify: untildify, unzip: unzip, unzipWith: unzipWith, validateNumber: validateNumber, without: without, words: words, xProd: xProd, yesNo: yesNo, zip: zip, zipObject: zipObject, zipWith: zipWith }; +var imports = { JSONToFile: JSONToFile, RGBToHex: RGBToHex, URLJoin: URLJoin, UUIDGeneratorBrowser: UUIDGeneratorBrowser, UUIDGeneratorNode: UUIDGeneratorNode, anagrams: anagrams, arrayToHtmlList: arrayToHtmlList, ary: ary, atob: atob, attempt: attempt, average: average, averageBy: averageBy, bind: bind, bindAll: bindAll, bindKey: bindKey, 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, copyToClipboard: copyToClipboard, countBy: countBy, countOccurrences: countOccurrences, createElement: createElement, createEventHub: createEventHub, currentURL: currentURL, curry: curry, debounce: debounce, decapitalize: decapitalize, deepClone: deepClone, deepFlatten: deepFlatten, defaults: defaults, defer: defer, delay: delay, detectDeviceType: detectDeviceType, difference: difference, differenceBy: differenceBy, differenceWith: differenceWith, digitize: digitize, distance: distance, drop: drop, dropRight: dropRight, dropRightWhile: dropRightWhile, dropWhile: dropWhile, elementIsVisibleInViewport: elementIsVisibleInViewport, elo: elo, equals: equals, escapeHTML: escapeHTML, escapeRegExp: escapeRegExp, everyNth: everyNth, extendHex: extendHex, factorial: factorial, fibonacci: fibonacci, filterNonUnique: filterNonUnique, findKey: findKey, findLast: findLast, findLastIndex: findLastIndex, findLastKey: findLastKey, flatten: flatten, flip: flip, forEachRight: forEachRight, forOwn: forOwn, forOwnRight: forOwnRight, formatDuration: formatDuration, fromCamelCase: fromCamelCase, functionName: functionName, functions: functions, gcd: gcd, geometricProgression: geometricProgression, get: get, getDaysDiffBetweenDates: getDaysDiffBetweenDates, 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, inRange: inRange, indexOfAll: indexOfAll, initial: initial, initialize2DArray: initialize2DArray, initializeArrayWithRange: initializeArrayWithRange, initializeArrayWithRangeRight: initializeArrayWithRangeRight, initializeArrayWithValues: initializeArrayWithValues, intersection: intersection, intersectionBy: intersectionBy, intersectionWith: intersectionWith, invertKeyValues: invertKeyValues, is: is, isAbsoluteURL: isAbsoluteURL, isArrayLike: isArrayLike, isBoolean: isBoolean, isDivisible: isDivisible, 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, isSorted: isSorted, isString: isString, isSymbol: isSymbol, isTravisCI: isTravisCI, isUndefined: isUndefined, isUpperCase: isUpperCase, isValidJSON: isValidJSON, join: join, last: last, lcm: lcm, longestItem: longestItem, lowercaseKeys: lowercaseKeys, luhnCheck: luhnCheck, mapKeys: mapKeys, mapObject: mapObject, mapValues: mapValues, mask: mask, matches: matches, matchesWith: matchesWith, maxBy: maxBy, maxN: maxN, median: median, memoize: memoize, merge: merge, minBy: minBy, minN: minN, negate: negate, nthArg: nthArg, nthElement: nthElement, objectFromPairs: objectFromPairs, objectToPairs: objectToPairs, observeMutations: observeMutations, off: off, omit: omit, omitBy: omitBy, on: on, onUserInputChange: onUserInputChange, once: once, orderBy: orderBy, over: over, overArgs: overArgs, palindrome: palindrome, parseCookie: parseCookie, partial: partial, partialRight: partialRight, partition: partition, percentile: percentile, pick: pick, pickBy: pickBy, pipeAsyncFunctions: pipeAsyncFunctions, pipeFunctions: pipeFunctions, pluralize: pluralize, powerset: powerset, prettyBytes: prettyBytes, primes: primes, promisify: promisify, pull: pull, pullAtIndex: pullAtIndex, pullAtValue: pullAtValue, pullBy: pullBy, randomHexColorCode: randomHexColorCode, randomIntArrayInRange: randomIntArrayInRange, randomIntegerInRange: randomIntegerInRange, randomNumberInRange: randomNumberInRange, readFileLines: readFileLines, rearg: rearg, redirect: redirect, reduceSuccessive: reduceSuccessive, reduceWhich: reduceWhich, reducedFilter: reducedFilter, remove: remove, removeNonASCII: removeNonASCII, reverseString: reverseString, round: round, runAsync: runAsync, runPromisesInSeries: runPromisesInSeries, sample: sample, sampleSize: sampleSize, scrollToTop: scrollToTop, sdbm: sdbm, serializeCookie: serializeCookie, setStyle: setStyle, shallowClone: shallowClone, show: show, shuffle: shuffle, similarity: similarity, size: size, sleep: sleep, sortCharactersInString: sortCharactersInString, sortedIndex: sortedIndex, sortedIndexBy: sortedIndexBy, sortedLastIndex: sortedLastIndex, sortedLastIndexBy: sortedLastIndexBy, splitLines: splitLines, spreadOver: spreadOver, standardDeviation: standardDeviation, 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, timeTaken: timeTaken, times: times, toCamelCase: toCamelCase, toDecimalMark: toDecimalMark, toKebabCase: toKebabCase, toOrdinalSuffix: toOrdinalSuffix, toSafeInteger: toSafeInteger, toSnakeCase: toSnakeCase, toggleClass: toggleClass, tomorrow: tomorrow, transform: transform, truncateString: truncateString, truthCheckCollection: truthCheckCollection, unary: unary, unescapeHTML: unescapeHTML, unfold: unfold, union: union, unionBy: unionBy, unionWith: unionWith, uniqueElements: uniqueElements, untildify: untildify, unzip: unzip, unzipWith: unzipWith, validateNumber: validateNumber, without: without, words: words, xProd: xProd, yesNo: yesNo, zip: zip, zipObject: zipObject, zipWith: zipWith }; return imports; diff --git a/dist/_30s.es5.min.js b/dist/_30s.es5.min.js index bf86404d3..7d1ad7163 100644 --- a/dist/_30s.es5.min.js +++ b/dist/_30s.es5.min.js @@ -1 +1 @@ -(function(e,t){'object'==typeof exports&&'undefined'!=typeof module?module.exports=t():'function'==typeof define&&define.amd?define(t):e._30s=t()})(this,function(){'use strict';function e(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t>e/4).toString(16)})},UUIDGeneratorNode:function(){return'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,function(e){return(e^W.randomBytes(1)[0]&15>>e/4).toString(16)})},anagrams:function e(t){return 2>=t.length?2===t.length?[t,t[1]+t[0]]:[t]:t.split('').reduce(function(n,r,l){return n.concat(e(t.slice(0,l)+t.slice(l+1)).map(function(e){return r+e}))},[])},arrayToHtmlList:function(e,t){return e.map(function(e){return document.querySelector('#'+t).innerHTML+='
  • '+e+'
  • '})},ary:function(t,i){return function(){for(var n=arguments.length,r=Array(n),l=0;l=(document.documentElement.scrollHeight||document.documentElement.clientHeight)},btoa:function(e){return new Buffer(e,'binary').toString('base64')},byteSize:function(e){return new Blob([e]).size},call:function(e){for(var t=arguments.length,n=Array(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:O(e/8.64e7),hour:O(e/3.6e6)%24,minute:O(e/6e4)%60,second:O(e/1e3)%60,millisecond:O(e)%1e3};return Object.entries(t).filter(function(e){return 0!==e[1]}).map(function(e){return e[1]+' '+(1===e[1]?e[0]:e[0]+'s')}).join(', ')},fromCamelCase:function(e){var t=1>>(t?24:16))+', '+((n&(t?16711680:65280))>>>(t?16:8))+', '+((n&(t?65280:255))>>>(t?8:0))+(t?', '+(255&n):'')+')'},hide:function(){for(var e=arguments.length,t=Array(e),n=0;nn&&(n=t),null==n?0<=e&&e=t&&ee[1]?-1:1,r=!0,l=!1;try{for(var o,a=e.entries()[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var s=o.value,c=Y(s,2),d=c[0],i=c[1];if(d===e.length-1)return n;if(0<(i-e[d+1])*n)return 0}}catch(e){l=!0,t=e}finally{try{!r&&a.return&&a.return()}finally{if(l)throw t}}},isString:function(e){return'string'==typeof e},isSymbol:function(e){return'symbol'===('undefined'==typeof e?'undefined':J(e))},isTravisCI:function(){return'TRAVIS'in process.env&&'CI'in process.env},isUndefined:function(e){return e===void 0},isUpperCase:function(e){return e===e.toUpperCase()},isValidJSON:function(e){try{return JSON.parse(e),!0}catch(t){return!1}},join:function(e){var t=1r-n&&(t='mouse',e(t),document.removeEventListener('mousemove',i)),n=r};document.addEventListener('touchstart',function(){'touch'==t||(t='touch',e(t),document.addEventListener('mousemove',i))})},once:function(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,i=Array(n),r=0;rc?1:sMath.abs(e))return e+(i?' ':'')+r[0];var l=N(O(Math.log10(0>e?-e:e)/3),r.length-1),o=+((0>e?-e:e)/z(1e3,l)).toPrecision(t);return(0>e?'-':'')+o+(i?' ':'')+r[l]},primes:function(e){var t=Array.from({length:e-1}).map(function(e,t){return t+2}),n=O(T(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),l=e.findIndex(function(e){return i?r>=n(e):r<=n(e)});return-1===l?e.length:l},sortedLastIndex:function(e,t){var n=e[0]>e[e.length-1],i=e.map(function(e,t){return[t,e]}).reverse().findIndex(function(e){return n?t<=e[1]:t>=e[1]});return-1===i?0:e.length-i-1},sortedLastIndexBy:function(e,t,n){var i=n(e[0])>n(e[e.length-1]),r=n(t),l=e.map(function(e,t){return[t,n(e)]}).reverse().findIndex(function(e){return i?r<=e[1]:r>=e[1]});return-1===l?0:e.length-l},splitLines:function(e){return e.split(/\r?\n/)},spreadOver:function(e){return function(t){return e.apply(void 0,v(t))}},standardDeviation:function(e){var t=1]*>/g,'')},sum:function(){for(var e=arguments.length,t=Array(e),n=0;nt?e.slice(0,3',"'":'\'',""":'"'}[e]||e})},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([].concat(C(e),C(t))))},unionBy:function(e,t,n){var i=new Set(e.map(function(e){return n(e)}));return Array.from(new Set([].concat(x(e),x(t.filter(function(e){return!i.has(n(e))})))))},unionWith:function(e,t,n){return Array.from(new Set([].concat(E(e),E(t.filter(function(t){return-1===e.findIndex(function(e){return n(t,e)})})))))},uniqueElements:function(e){return[].concat(S(new Set(e)))},untildify:function(e){return e.replace(/^~($|\/|\\)/,('undefined'!=typeof require&&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:D.apply(Math,L(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:D.apply(Math,I(e.map(function(e){return e.length})))}).map(function(){return[]})).map(function(e){return t.apply(void 0,I(e))})},validateNumber:function(e){return!isNaN(parseFloat(e))&&isFinite(e)&&+e==e},without:function(e){for(var t=arguments.length,n=Array(1>e/4).toString(16)})},UUIDGeneratorNode:function(){return'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,function(e){return(e^M.randomBytes(1)[0]&15>>e/4).toString(16)})},anagrams:function e(t){return 2>=t.length?2===t.length?[t,t[1]+t[0]]:[t]:t.split('').reduce(function(n,r,l){return n.concat(e(t.slice(0,l)+t.slice(l+1)).map(function(e){return r+e}))},[])},arrayToHtmlList:function(e,t){return e.map(function(e){return document.querySelector('#'+t).innerHTML+='
  • '+e+'
  • '})},ary:function(t,r){return function(){for(var n=arguments.length,i=Array(n),l=0;l=(document.documentElement.scrollHeight||document.documentElement.clientHeight)},btoa:function(e){return new Buffer(e,'binary').toString('base64')},byteSize:function(e){return new Blob([e]).size},call:function(e){for(var t=arguments.length,n=Array(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:U(e/8.64e7),hour:U(e/3.6e6)%24,minute:U(e/6e4)%60,second:U(e/1e3)%60,millisecond:U(e)%1e3};return Object.entries(t).filter(function(e){return 0!==e[1]}).map(function(e){return e[1]+' '+(1===e[1]?e[0]:e[0]+'s')}).join(', ')},fromCamelCase:function(e){var t=1>>(t?24:16))+', '+((n&(t?16711680:65280))>>>(t?16:8))+', '+((n&(t?65280:255))>>>(t?8:0))+(t?', '+(255&n):'')+')'},hide:function(){for(var e=arguments.length,t=Array(e),n=0;nn&&(n=t),null==n?0<=e&&e=t&&ee[1]?-1:1,r=!0,l=!1;try{for(var o,a=e.entries()[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var s=o.value,c=Z(s,2),d=c[0],i=c[1];if(d===e.length-1)return n;if(0<(i-e[d+1])*n)return 0}}catch(e){l=!0,t=e}finally{try{!r&&a.return&&a.return()}finally{if(l)throw t}}},isString:function(e){return'string'==typeof e},isSymbol:function(e){return'symbol'===('undefined'==typeof e?'undefined':Q(e))},isTravisCI:function(){return'TRAVIS'in process.env&&'CI'in process.env},isUndefined:function(e){return e===void 0},isUpperCase:function(e){return e===e.toUpperCase()},isValidJSON:function(e){try{return JSON.parse(e),!0}catch(t){return!1}},join:function(e){var t=1i-n&&(t='mouse',e(t),document.removeEventListener('mousemove',r)),n=i};document.addEventListener('touchstart',function(){'touch'==t||(t='touch',e(t),document.addEventListener('mousemove',r))})},once:function(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=Array(n),i=0;ic?1:sMath.abs(e))return e+(r?' ':'')+i[0];var l=P(U(Math.log10(0>e?-e:e)/3),i.length-1),o=+((0>e?-e:e)/D(1e3,l)).toPrecision(t);return(0>e?'-':'')+o+(r?' ':'')+i[l]},primes:function(e){var t=Array.from({length:e-1}).map(function(e,t){return t+2}),n=U(N(e)),r=Array.from({length:n-1}).map(function(e,t){return t+2});return r.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),r=0;re[e.length-1],r=e.findIndex(function(e){return n?t>=e:t<=e});return-1===r?e.length:r},sortedIndexBy:function(e,t,n){var r=n(e[0])>n(e[e.length-1]),i=n(t),l=e.findIndex(function(e){return r?i>=n(e):i<=n(e)});return-1===l?e.length:l},sortedLastIndex:function(e,t){var n=e[0]>e[e.length-1],r=e.map(function(e,t){return[t,e]}).reverse().findIndex(function(e){return n?t<=e[1]:t>=e[1]});return-1===r?0:e.length-r-1},sortedLastIndexBy:function(e,t,n){var r=n(e[0])>n(e[e.length-1]),i=n(t),l=e.map(function(e,t){return[t,n(e)]}).reverse().findIndex(function(e){return r?i<=e[1]:i>=e[1]});return-1===l?0:e.length-l},splitLines:function(e){return e.split(/\r?\n/)},spreadOver:function(e){return function(t){return e.apply(void 0,j(t))}},standardDeviation:function(e){var t=1]*>/g,'')},sum:function(){for(var e=arguments.length,t=Array(e),n=0;n=t&&(e.apply(l,o),i=Date.now())},t-(Date.now()-i))):(e.apply(l,o),i=Date.now(),n=!0)}},timeTaken:function(e){console.time('timeTaken');var t=e();return console.timeEnd('timeTaken'),t},times:function(e,t){for(var n=2t?e.slice(0,3',"'":'\'',""":'"'}[e]||e})},unfold:function(e,t){for(var n=[],r=[null,t];r=e(r[1]);)n.push(r[0]);return n},union:function(e,t){return Array.from(new Set([].concat(S(e),S(t))))},unionBy:function(e,t,n){var r=new Set(e.map(function(e){return n(e)}));return Array.from(new Set([].concat(L(e),L(t.filter(function(e){return!r.has(n(e))})))))},unionWith:function(e,t,n){return Array.from(new Set([].concat(I(e),I(t.filter(function(t){return-1===e.findIndex(function(e){return n(t,e)})})))))},uniqueElements:function(e){return[].concat(w(new Set(e)))},untildify:function(e){return e.replace(/^~($|\/|\\)/,('undefined'!=typeof require&&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:W.apply(Math,B(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:W.apply(Math,T(e.map(function(e){return e.length})))}).map(function(){return[]})).map(function(e){return t.apply(void 0,T(e))})},validateNumber:function(e){return!isNaN(parseFloat(e))&&isFinite(e)&&+e==e},without:function(e){for(var t=arguments.length,n=Array(1 (...args) => fn(...args.slice(0, n)); const atob = str => new Buffer(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) => @@ -56,9 +64,9 @@ const bind = (fn, context, ...args) => const bindAll = (obj, ...fns) => fns.forEach( - fn => - (obj[fn] = function() { - return fn.apply(obj); + fn => ( + f = obj[fn], obj[fn] = function() { + return f.apply(obj); }) ); @@ -182,6 +190,16 @@ const currentURL = () => window.location.href; const curry = (fn, arity = fn.length, ...args) => arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args); +const debounce = (fn, wait = 0) => { + let inDebounce; + return function() { + const context = this, + args = arguments; + clearTimeout(inDebounce); + inDebounce = setTimeout(() => fn.apply(context, args), wait); + }; +}; + const decapitalize = ([first, ...rest], upperRest = false) => first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join('')); @@ -803,6 +821,8 @@ const orderBy = (arr, props, orders) => 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 palindrome = str => { const s = str.toLowerCase().replace(/[\W_]/g, ''); return ( @@ -847,6 +867,8 @@ const pickBy = (obj, fn) => .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') => { @@ -934,6 +956,14 @@ const readFileLines = filename => .toString('UTF8') .split('\n'); +const rearg = (fn, indexes) => (...args) => + fn( + ...args.reduce( + (acc, val, i) => (acc[indexes.indexOf(i)] = val, acc), + Array.from({ length: indexes.length }) + ) + ); + const redirect = (url, asLink = true) => asLink ? (window.location.href = url) : window.location.replace(url); @@ -1133,6 +1163,27 @@ const takeWhile = (arr, func) => { 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(); @@ -1288,6 +1339,6 @@ const zipWith = (...arrays) => { return fn ? result.map(arr => fn(...arr)) : result; }; -var imports = {JSONToFile,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,ary,atob,average,averageBy,bind,bindAll,bindKey,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,composeRight,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,decapitalize,deepClone,deepFlatten,defaults,defer,delay,detectDeviceType,difference,differenceBy,differenceWith,digitize,distance,drop,dropRight,dropRightWhile,dropWhile,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findKey,findLast,findLastIndex,findLastKey,flatten,flip,forEachRight,forOwn,forOwnRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,intersection,intersectionBy,intersectionWith,invertKeyValues,is,isAbsoluteURL,isArrayLike,isBoolean,isDivisible,isEmpty,isEven,isFunction,isLowerCase,isNil,isNull,isNumber,isObject,isObjectLike,isPlainObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,matches,matchesWith,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,omit,omitBy,on,onUserInputChange,once,orderBy,over,palindrome,parseCookie,partial,partialRight,partition,percentile,pick,pickBy,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reduceSuccessive,reduceWhich,reducedFilter,remove,removeNonASCII,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,sortedIndexBy,sortedLastIndex,sortedLastIndexBy,splitLines,spreadOver,standardDeviation,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,timeTaken,times,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unary,unescapeHTML,unfold,union,unionBy,unionWith,uniqueElements,untildify,unzip,unzipWith,validateNumber,without,words,xProd,yesNo,zip,zipObject,zipWith,} +var imports = {JSONToFile,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,ary,atob,attempt,average,averageBy,bind,bindAll,bindKey,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,composeRight,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,debounce,decapitalize,deepClone,deepFlatten,defaults,defer,delay,detectDeviceType,difference,differenceBy,differenceWith,digitize,distance,drop,dropRight,dropRightWhile,dropWhile,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findKey,findLast,findLastIndex,findLastKey,flatten,flip,forEachRight,forOwn,forOwnRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,intersection,intersectionBy,intersectionWith,invertKeyValues,is,isAbsoluteURL,isArrayLike,isBoolean,isDivisible,isEmpty,isEven,isFunction,isLowerCase,isNil,isNull,isNumber,isObject,isObjectLike,isPlainObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,matches,matchesWith,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,omit,omitBy,on,onUserInputChange,once,orderBy,over,overArgs,palindrome,parseCookie,partial,partialRight,partition,percentile,pick,pickBy,pipeAsyncFunctions,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,rearg,redirect,reduceSuccessive,reduceWhich,reducedFilter,remove,removeNonASCII,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,sortedIndexBy,sortedLastIndex,sortedLastIndexBy,splitLines,spreadOver,standardDeviation,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,timeTaken,times,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unary,unescapeHTML,unfold,union,unionBy,unionWith,uniqueElements,untildify,unzip,unzipWith,validateNumber,without,words,xProd,yesNo,zip,zipObject,zipWith,} export default imports; diff --git a/dist/_30s.js b/dist/_30s.js index 39a0d8d74..08c57c21c 100644 --- a/dist/_30s.js +++ b/dist/_30s.js @@ -49,6 +49,14 @@ const ary = (fn, n) => (...args) => fn(...args.slice(0, n)); const atob = str => new Buffer(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) => @@ -62,9 +70,9 @@ const bind = (fn, context, ...args) => const bindAll = (obj, ...fns) => fns.forEach( - fn => - (obj[fn] = function() { - return fn.apply(obj); + fn => ( + f = obj[fn], obj[fn] = function() { + return f.apply(obj); }) ); @@ -188,6 +196,16 @@ const currentURL = () => window.location.href; const curry = (fn, arity = fn.length, ...args) => arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args); +const debounce = (fn, wait = 0) => { + let inDebounce; + return function() { + const context = this, + args = arguments; + clearTimeout(inDebounce); + inDebounce = setTimeout(() => fn.apply(context, args), wait); + }; +}; + const decapitalize = ([first, ...rest], upperRest = false) => first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join('')); @@ -809,6 +827,8 @@ const orderBy = (arr, props, orders) => 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 palindrome = str => { const s = str.toLowerCase().replace(/[\W_]/g, ''); return ( @@ -853,6 +873,8 @@ const pickBy = (obj, fn) => .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') => { @@ -940,6 +962,14 @@ const readFileLines = filename => .toString('UTF8') .split('\n'); +const rearg = (fn, indexes) => (...args) => + fn( + ...args.reduce( + (acc, val, i) => (acc[indexes.indexOf(i)] = val, acc), + Array.from({ length: indexes.length }) + ) + ); + const redirect = (url, asLink = true) => asLink ? (window.location.href = url) : window.location.replace(url); @@ -1139,6 +1169,27 @@ const takeWhile = (arr, func) => { 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(); @@ -1294,7 +1345,7 @@ const zipWith = (...arrays) => { return fn ? result.map(arr => fn(...arr)) : result; }; -var imports = {JSONToFile,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,ary,atob,average,averageBy,bind,bindAll,bindKey,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,composeRight,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,decapitalize,deepClone,deepFlatten,defaults,defer,delay,detectDeviceType,difference,differenceBy,differenceWith,digitize,distance,drop,dropRight,dropRightWhile,dropWhile,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findKey,findLast,findLastIndex,findLastKey,flatten,flip,forEachRight,forOwn,forOwnRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,intersection,intersectionBy,intersectionWith,invertKeyValues,is,isAbsoluteURL,isArrayLike,isBoolean,isDivisible,isEmpty,isEven,isFunction,isLowerCase,isNil,isNull,isNumber,isObject,isObjectLike,isPlainObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,matches,matchesWith,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,omit,omitBy,on,onUserInputChange,once,orderBy,over,palindrome,parseCookie,partial,partialRight,partition,percentile,pick,pickBy,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reduceSuccessive,reduceWhich,reducedFilter,remove,removeNonASCII,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,sortedIndexBy,sortedLastIndex,sortedLastIndexBy,splitLines,spreadOver,standardDeviation,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,timeTaken,times,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unary,unescapeHTML,unfold,union,unionBy,unionWith,uniqueElements,untildify,unzip,unzipWith,validateNumber,without,words,xProd,yesNo,zip,zipObject,zipWith,} +var imports = {JSONToFile,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,ary,atob,attempt,average,averageBy,bind,bindAll,bindKey,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,composeRight,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,debounce,decapitalize,deepClone,deepFlatten,defaults,defer,delay,detectDeviceType,difference,differenceBy,differenceWith,digitize,distance,drop,dropRight,dropRightWhile,dropWhile,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findKey,findLast,findLastIndex,findLastKey,flatten,flip,forEachRight,forOwn,forOwnRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,intersection,intersectionBy,intersectionWith,invertKeyValues,is,isAbsoluteURL,isArrayLike,isBoolean,isDivisible,isEmpty,isEven,isFunction,isLowerCase,isNil,isNull,isNumber,isObject,isObjectLike,isPlainObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,matches,matchesWith,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,omit,omitBy,on,onUserInputChange,once,orderBy,over,overArgs,palindrome,parseCookie,partial,partialRight,partition,percentile,pick,pickBy,pipeAsyncFunctions,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,rearg,redirect,reduceSuccessive,reduceWhich,reducedFilter,remove,removeNonASCII,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,sortedIndexBy,sortedLastIndex,sortedLastIndexBy,splitLines,spreadOver,standardDeviation,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,timeTaken,times,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unary,unescapeHTML,unfold,union,unionBy,unionWith,uniqueElements,untildify,unzip,unzipWith,validateNumber,without,words,xProd,yesNo,zip,zipObject,zipWith,} return imports; diff --git a/dist/_30s.min.js b/dist/_30s.min.js index babd1bc80..c49fc8838 100644 --- a/dist/_30s.min.js +++ b/dist/_30s.min.js @@ -1 +1 @@ -(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?module.exports=b():'function'==typeof define&&define.amd?define(b):a._30s=b()})(this,function(){'use strict';var a=Math.round,b=Math.sqrt,c=Math.log,d=Math.floor,e=Math.min,f=Math.max,g=Math.ceil;const h='undefined'!=typeof require&&require('fs'),i='undefined'!=typeof require&&require('crypto'),j=(a)=>2>=a.length?2===a.length?[a,a[1]+a[0]]:[a]:a.split('').reduce((b,c,d)=>b.concat(j(a.slice(0,d)+a.slice(d+1)).map((a)=>c+a)),[]),k=(a,b=a.length,...c)=>b<=c.length?a(...c):k.bind(null,a,b,...c),l=(a)=>{let b=Object.assign({},a);return Object.keys(b).forEach((c)=>b[c]='object'==typeof a[c]?l(a[c]):a[c]),b},m=(a)=>[].concat(...a.map((a)=>Array.isArray(a)?m(a):a)),n=([...c],d=32,e)=>{const[f,a]=c,b=(a,b)=>1/(1+10**((b-a)/400)),g=(c,g)=>(e||c)+d*(g-b(g?f:a,g?a:f));if(2===c.length)return[g(f,1),g(a,0)];for(let a,b=0;b{if(c===d)return!0;if(c instanceof Date&&d instanceof Date)return c.getTime()===d.getTime();if(!c||!d||'object'!=typeof c&&'object'!=typeof d)return c===d;if(null===c||void 0===c||null===d||void 0===d)return!1;if(c.prototype!==d.prototype)return!1;let e=Object.keys(c);return!(e.length!==Object.keys(d).length)&&e.every((a)=>o(c[a],d[a]))},p=(a)=>0>a?(()=>{throw new TypeError('Negative numbers are not allowed!')})():1>=a?1:a*p(a-1),q=(a,b=1)=>1==b?a.reduce((b,a)=>b.concat(a),[]):a.reduce((c,a)=>c.concat(Array.isArray(a)?q(a,b-1):a),[]),r=(...a)=>{const c=(a,b)=>b?r(b,a%b):a;return[...a].reduce((d,a)=>c(d,a))},s='undefined'!=typeof require&&require('crypto'),t='undefined'!=typeof require&&require('fs'),u=()=>{const a=document.documentElement.scrollTop||document.body.scrollTop;0h.writeFile(`${b}.json`,JSON.stringify(a,null,2)),RGBToHex:(a,c,d)=>((a<<16)+(c<<8)+d).toString(16).padStart(6,'0'),URLJoin:(...a)=>a.join('/').replace(/[\/]+/g,'/').replace(/^(.+):\//,'$1://').replace(/^file:/,'file:/').replace(/\/(\?|&|#[^!])/g,'$1').replace(/\?/g,'&').replace('&','?'),UUIDGeneratorBrowser:()=>'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,(a)=>(a^crypto.getRandomValues(new Uint8Array(1))[0]&15>>a/4).toString(16)),UUIDGeneratorNode:()=>'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,(a)=>(a^i.randomBytes(1)[0]&15>>a/4).toString(16)),anagrams:j,arrayToHtmlList:(a,b)=>a.map((a)=>document.querySelector('#'+b).innerHTML+=`
  • ${a}
  • `),ary:(a,b)=>(...c)=>a(...c.slice(0,b)),atob:(a)=>new Buffer(a,'base64').toString('binary'),average:(...a)=>[...a].reduce((a,b)=>a+b,0)/a.length,averageBy:(a,b)=>a.map('function'==typeof b?b:(a)=>a[b]).reduce((a,b)=>a+b,0)/a.length,bind:(a,b,...c)=>function(){return a.apply(b,c.concat(...arguments))},bindAll:(a,...b)=>b.forEach((b)=>a[b]=function(){return b.apply(a)}),bindKey:(a,b,...c)=>function(){return a[b].apply(a,c.concat(...arguments))},bottomVisible:()=>document.documentElement.clientHeight+window.scrollY>=(document.documentElement.scrollHeight||document.documentElement.clientHeight),btoa:(a)=>new Buffer(a,'binary').toString('base64'),byteSize:(a)=>new Blob([a]).size,call:(a,...b)=>(c)=>c[a](...b),capitalize:([a,...b],c=!1)=>a.toUpperCase()+(c?b.join('').toLowerCase():b.join('')),capitalizeEveryWord:(a)=>a.replace(/\b[a-z]/g,(a)=>a.toUpperCase()),castArray:(a)=>Array.isArray(a)?a:[a],chainAsync:(a)=>{let b=0;const c=()=>a[b++](c);c()},chunk:(a,b)=>Array.from({length:g(a.length/b)},(c,d)=>a.slice(d*b,d*b+b)),clampNumber:(c,d,a)=>f(e(c,f(d,a)),e(d,a)),cloneRegExp:(a)=>new RegExp(a.source,a.flags),coalesce:(...a)=>a.find((a)=>![void 0,null].includes(a)),coalesceFactory:(a)=>(...b)=>b.find(a),collectInto:(a)=>(...b)=>a(b),colorize:(...a)=>({black:`\x1b[30m${a.join(' ')}`,red:`\x1b[31m${a.join(' ')}`,green:`\x1b[32m${a.join(' ')}`,yellow:`\x1b[33m${a.join(' ')}`,blue:`\x1b[34m${a.join(' ')}`,magenta:`\x1b[35m${a.join(' ')}`,cyan:`\x1b[36m${a.join(' ')}`,white:`\x1b[37m${a.join(' ')}`,bgBlack:`\x1b[40m${a.join(' ')}\x1b[0m`,bgRed:`\x1b[41m${a.join(' ')}\x1b[0m`,bgGreen:`\x1b[42m${a.join(' ')}\x1b[0m`,bgYellow:`\x1b[43m${a.join(' ')}\x1b[0m`,bgBlue:`\x1b[44m${a.join(' ')}\x1b[0m`,bgMagenta:`\x1b[45m${a.join(' ')}\x1b[0m`,bgCyan:`\x1b[46m${a.join(' ')}\x1b[0m`,bgWhite:`\x1b[47m${a.join(' ')}\x1b[0m`}),compact:(a)=>a.filter(Boolean),compose:(...a)=>a.reduce((a,b)=>(...c)=>a(b(...c))),composeRight:(...a)=>a.reduce((a,b)=>(...c)=>b(a(...c))),copyToClipboard:(a)=>{const b=document.createElement('textarea');b.value=a,b.setAttribute('readonly',''),b.style.position='absolute',b.style.left='-9999px',document.body.appendChild(b);const c=!!(0a.map('function'==typeof b?b:(a)=>a[b]).reduce((a,b)=>(a[b]=(a[b]||0)+1,a),{}),countOccurrences:(a,b)=>a.reduce((c,a)=>a===b?c+1:c+0,0),createElement:(a)=>{const b=document.createElement('div');return b.innerHTML=a,b.firstElementChild},createEventHub:()=>({hub:Object.create(null),emit(a,b){(this.hub[a]||[]).forEach((a)=>a(b))},on(a,b){this.hub[a]||(this.hub[a]=[]),this.hub[a].push(b)},off(a,b){const c=(this.hub[a]||[]).findIndex((a)=>a===b);-1window.location.href,curry:k,decapitalize:([a,...b],c=!1)=>a.toLowerCase()+(c?b.join('').toUpperCase():b.join('')),deepClone:l,deepFlatten:m,defaults:(a,...b)=>Object.assign({},a,...b.reverse(),a),defer:(a,...b)=>setTimeout(a,1,...b),delay:(a,b,...c)=>setTimeout(a,b,...c),detectDeviceType:()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?'Mobile':'Desktop',difference:(c,a)=>{const b=new Set(a);return c.filter((a)=>!b.has(a))},differenceBy:(c,a,b)=>{const d=new Set(a.map((a)=>b(a)));return c.filter((a)=>!d.has(b(a)))},differenceWith:(a,b,c)=>a.filter((d)=>-1===b.findIndex((a)=>c(d,a))),digitize:(a)=>[...`${a}`].map((a)=>parseInt(a)),distance:(a,b,c,d)=>Math.hypot(c-a,d-b),drop:(a,b=1)=>a.slice(b),dropRight:(a,b=1)=>a.slice(0,-b),dropRightWhile:(a,b)=>{for(;0{for(;0{const{top:c,left:d,bottom:e,right:f}=a.getBoundingClientRect(),{innerHeight:g,innerWidth:h}=window;return b?(0a.replace(/[&<>'"]/g,(a)=>({"&":'&',"<":'<',">":'>',"'":''','"':'"'})[a]||a),escapeRegExp:(a)=>a.replace(/[.*+?^${}()|[\]\\]/g,'\\$&'),everyNth:(a,b)=>a.filter((a,c)=>c%b==b-1),extendHex:(a)=>'#'+a.slice(a.startsWith('#')?1:0).split('').map((a)=>a+a).join(''),factorial:p,fibonacci:(a)=>Array.from({length:a}).reduce((a,b,c)=>a.concat(1a.filter((b)=>a.indexOf(b)===a.lastIndexOf(b)),findKey:(a,b)=>Object.keys(a).find((c)=>b(a[c],c,a)),findLast:(a,b)=>a.filter(b).slice(-1)[0],findLastIndex:(a,b)=>a.map((a,b)=>[b,a]).filter((c)=>b(c[1],c[0],a)).slice(-1)[0][0],findLastKey:(a,b)=>Object.keys(a).reverse().find((c)=>b(a[c],c,a)),flatten:q,flip:(a)=>(b,...c)=>a(...c,b),forEachRight:(a,b)=>a.slice(0).reverse().forEach(b),forOwn:(a,b)=>Object.keys(a).forEach((c)=>b(a[c],c,a)),forOwnRight:(a,b)=>Object.keys(a).reverse().forEach((c)=>b(a[c],c,a)),formatDuration:(a)=>{0>a&&(a=-a);const b={day:d(a/8.64e7),hour:d(a/3.6e6)%24,minute:d(a/6e4)%60,second:d(a/1e3)%60,millisecond:d(a)%1e3};return Object.entries(b).filter((a)=>0!==a[1]).map((a)=>a[1]+' '+(1===a[1]?a[0]:a[0]+'s')).join(', ')},fromCamelCase:(a,b='_')=>a.replace(/([a-z\d])([A-Z])/g,'$1'+b+'$2').replace(/([A-Z]+)([A-Z][a-z\d]+)/g,'$1'+b+'$2').toLowerCase(),functionName:(a)=>(console.debug(a.name),a),functions:(a,b=!1)=>(b?[...Object.keys(a),...Object.keys(Object.getPrototypeOf(a))]:Object.keys(a)).filter((b)=>'function'==typeof a[b]),gcd:r,geometricProgression:(a,b=1,e=2)=>Array.from({length:d(c(a/b)/c(e))+1}).map((a,c)=>b*e**c),get:(a,...b)=>[...b].map((b)=>b.replace(/\[([^\[\]]*)\]/g,'.$1.').split('.').filter((a)=>''!==a).reduce((a,b)=>a&&a[b],a)),getDaysDiffBetweenDates:(a,b)=>(b-a)/86400000,getScrollPosition:(a=window)=>({x:a.pageXOffset===void 0?a.scrollLeft:a.pageXOffset,y:a.pageYOffset===void 0?a.scrollTop:a.pageYOffset}),getStyle:(a,b)=>getComputedStyle(a)[b],getType:(a)=>a===void 0?'undefined':null===a?'null':a.constructor.name.toLowerCase(),getURLParameters:(a)=>(a.match(/([^?=&]+)(=([^&]*))/g)||[]).reduce((b,a)=>(b[a.slice(0,a.indexOf('='))]=a.slice(a.indexOf('=')+1),b),{}),groupBy:(a,b)=>a.map('function'==typeof b?b:(a)=>a[b]).reduce((b,c,d)=>(b[c]=(b[c]||[]).concat(a[d]),b),{}),hammingDistance:(a,b)=>((a^b).toString(2).match(/1/g)||'').length,hasClass:(a,b)=>a.classList.contains(b),hasFlags:(...a)=>a.every((a)=>process.argv.includes(/^-{1,2}/.test(a)?a:'--'+a)),hashBrowser:(a)=>crypto.subtle.digest('SHA-256',new TextEncoder('utf-8').encode(a)).then((a)=>{let b=[],c=new DataView(a);for(let d=0;dnew Promise((b)=>setTimeout(()=>b(s.createHash('sha256').update(a).digest('hex')),0)),head:(a)=>a[0],hexToRGB:(a)=>{let b=!1,c=a.slice(a.startsWith('#')?1:0);return 3===c.length?c=[...c].map((a)=>a+a).join(''):8===c.length&&(b=!0),c=parseInt(c,16),'rgb'+(b?'a':'')+'('+(c>>>(b?24:16))+', '+((c&(b?16711680:65280))>>>(b?16:8))+', '+((c&(b?65280:255))>>>(b?8:0))+(b?`, ${255&c}`:'')+')'},hide:(...a)=>[...a].forEach((a)=>a.style.display='none'),httpGet:(a,b,c=console.error)=>{const d=new XMLHttpRequest;d.open('GET',a,!0),d.onload=()=>b(d.responseText),d.onerror=()=>c(d),d.send()},httpPost:(a,b,c,d=console.error)=>{const e=new XMLHttpRequest;e.open('POST',a,!0),e.setRequestHeader('Content-type','application/json; charset=utf-8'),e.onload=()=>c(e.responseText),e.onerror=()=>d(e),e.send(b)},httpsRedirect:()=>{'https:'!==location.protocol&&location.replace('https://'+location.href.split('//')[1])},inRange:(a,b,c=null)=>(c&&b>c&&(c=b),null==c?0<=a&&a=b&&a{const c=[];return a.forEach((a,d)=>a===b&&c.push(d)),c},initial:(a)=>a.slice(0,-1),initialize2DArray:(a,b,c=null)=>Array.from({length:b}).map(()=>Array.from({length:a}).fill(c)),initializeArrayWithRange:(a,b=0,c=1)=>Array.from({length:g((a+1-b)/c)}).map((a,d)=>d*c+b),initializeArrayWithRangeRight:(a,b=0,c=1)=>Array.from({length:g((a+1-b)/c)}).map((a,d,e)=>(e.length-d-1)*c+b),initializeArrayWithValues:(a,b=0)=>Array(a).fill(b),intersection:(c,a)=>{const b=new Set(a);return c.filter((a)=>b.has(a))},intersectionBy:(c,a,b)=>{const d=new Set(a.map((a)=>b(a)));return c.filter((a)=>d.has(b(a)))},intersectionWith:(c,a,b)=>c.filter((c)=>-1!==a.findIndex((a)=>b(c,a))),invertKeyValues:(a,b)=>Object.keys(a).reduce((c,d)=>{const e=b?b(a[d]):a[d];return c[e]=c[e]||[],c[e].push(d),c},{}),is:(a,b)=>b instanceof a,isAbsoluteURL:(a)=>/^[a-z][a-z0-9+.-]*:/.test(a),isArrayLike:(a)=>{try{return[...a],!0}catch(a){return!1}},isBoolean:(a)=>'boolean'==typeof a,isDivisible:(a,b)=>0==a%b,isEmpty:(a)=>null==a||!(Object.keys(a)||a).length,isEven:(a)=>0==a%2,isFunction:(a)=>'function'==typeof a,isLowerCase:(a)=>a===a.toLowerCase(),isNil:(a)=>a===void 0||null===a,isNull:(a)=>null===a,isNumber:(a)=>'number'==typeof a,isObject:(a)=>a===Object(a),isObjectLike:(a)=>null!==a&&'object'==typeof a,isPlainObject:(a)=>!!a&&'object'==typeof a&&a.constructor===Object,isPrime:(a)=>{const c=d(b(a));for(var e=2;e<=c;e++)if(0==a%e)return!1;return 2<=a},isPrimitive:(a)=>!['object','function'].includes(typeof a)||null===a,isPromiseLike:(a)=>null!==a&&('object'==typeof a||'function'==typeof a)&&'function'==typeof a.then,isSorted:(a)=>{const b=a[0]>a[1]?-1:1;for(let[c,d]of a.entries()){if(c===a.length-1)return b;if(0<(d-a[c+1])*b)return 0}},isString:(a)=>'string'==typeof a,isSymbol:(a)=>'symbol'==typeof a,isTravisCI:()=>'TRAVIS'in process.env&&'CI'in process.env,isUndefined:(a)=>a===void 0,isUpperCase:(a)=>a===a.toUpperCase(),isValidJSON:(a)=>{try{return JSON.parse(a),!0}catch(a){return!1}},join:(a,b=',',c=b)=>a.reduce((d,e,f)=>f==a.length-2?d+e+c:f==a.length-1?d+e:d+e+b,''),last:(a)=>a[a.length-1],lcm:(...a)=>{const b=(a,c)=>c?b(c,a%c):a,c=(a,c)=>a*c/b(a,c);return[...a].reduce((d,a)=>c(d,a))},longestItem:(...a)=>[...a].sort((c,a)=>a.length-c.length)[0],lowercaseKeys:(a)=>Object.keys(a).reduce((b,c)=>(b[c.toLowerCase()]=a[c],b),{}),luhnCheck:(a)=>{let b=(a+'').split('').reverse().map((a)=>parseInt(a)),c=b.splice(0,1)[0],d=b.reduce((a,b,c)=>0==c%2?a+2*b%9||9:a+b,0);return d+=c,0==d%10},mapKeys:(a,b)=>Object.keys(a).reduce((c,d)=>(c[b(a[d],d,a)]=a[d],c),{}),mapObject:(b,c)=>((d)=>(d=[b,b.map(c)],d[0].reduce((a,b,c)=>(a[b]=d[1][c],a),{})))(),mapValues:(a,b)=>Object.keys(a).reduce((c,d)=>(c[d]=b(a[d],d,a),c),{}),mask:(a,b=4,c='*')=>(''+a).slice(0,-b).replace(/./g,c)+(''+a).slice(-b),matches:(a,b)=>Object.keys(b).every((c)=>a.hasOwnProperty(c)&&a[c]===b[c]),matchesWith:(a,b,c)=>Object.keys(b).every((d)=>a.hasOwnProperty(d)&&c?c(a[d],b[d],d,a,b):a[d]==b[d]),maxBy:(a,b)=>f(...a.map('function'==typeof b?b:(a)=>a[b])),maxN:(a,b=1)=>[...a].sort((c,a)=>a-c).slice(0,b),median:(a)=>{const b=d(a.length/2),c=[...a].sort((c,a)=>c-a);return 0==a.length%2?(c[b-1]+c[b])/2:c[b]},memoize:(a)=>{const b=new Map,c=function(c){return b.has(c)?b.get(c):b.set(c,a.call(this,c))&&b.get(c)};return c.cache=b,c},merge:(...a)=>[...a].reduce((b,c)=>Object.keys(c).reduce((d,a)=>(b[a]=b.hasOwnProperty(a)?[].concat(b[a]).concat(c[a]):c[a],b),{}),{}),minBy:(a,b)=>e(...a.map('function'==typeof b?b:(a)=>a[b])),minN:(a,b=1)=>[...a].sort((c,a)=>c-a).slice(0,b),negate:(a)=>(...b)=>!a(...b),nthArg:(a)=>(...b)=>b.slice(a)[0],nthElement:(a,b=0)=>(0a.reduce((b,a)=>(b[a[0]]=a[1],b),{}),objectToPairs:(a)=>Object.keys(a).map((b)=>[b,a[b]]),observeMutations:(a,b,c)=>{const d=new MutationObserver((a)=>a.forEach((a)=>b(a)));return d.observe(a,Object.assign({childList:!0,attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,subtree:!0},c)),d},off:(a,b,c,d=!1)=>a.removeEventListener(b,c,d),omit:(a,b)=>Object.keys(a).filter((a)=>!b.includes(a)).reduce((b,c)=>(b[c]=a[c],b),{}),omitBy:(a,b)=>Object.keys(a).filter((c)=>!b(a[c],c)).reduce((b,c)=>(b[c]=a[c],b),{}),on:(a,b,c,d={})=>{const e=(a)=>a.target.matches(d.target)&&c.call(a.target,a);if(a.addEventListener(b,d.target?e:c,d.options||!1),d.target)return e},onUserInputChange:(a)=>{let b='mouse',c=0;const d=()=>{const e=performance.now();20>e-c&&(b='mouse',a(b),document.removeEventListener('mousemove',d)),c=e};document.addEventListener('touchstart',()=>{'touch'==b||(b='touch',a(b),document.addEventListener('mousemove',d))})},once:(a)=>{let b=!1;return function(...c){if(!b)return b=!0,a.apply(this,c)}},orderBy:(a,c,d)=>[...a].sort((e,a)=>c.reduce((b,c,f)=>{if(0===b){const[g,h]=d&&'desc'===d[f]?[a[c],e[c]]:[e[c],a[c]];b=g>h?1:g(...b)=>a.map((a)=>a.apply(null,b)),palindrome:(a)=>{const b=a.toLowerCase().replace(/[\W_]/g,'');return b===b.split('').reverse().join('')},parseCookie:(a)=>a.split(';').map((a)=>a.split('=')).reduce((a,b)=>(a[decodeURIComponent(b[0].trim())]=decodeURIComponent(b[1].trim()),a),{}),partial:(a,...b)=>(...c)=>a(...b,...c),partialRight:(a,...b)=>(...c)=>a(...c,...b),partition:(a,b)=>a.reduce((a,c,d,e)=>(a[b(c,d,e)?0:1].push(c),a),[[],[]]),percentile:(a,b)=>100*a.reduce((a,c)=>a+(cb.reduce((b,c)=>(c in a&&(b[c]=a[c]),b),{}),pickBy:(a,b)=>Object.keys(a).filter((c)=>b(a[c],c)).reduce((b,c)=>(b[c]=a[c],b),{}),pipeFunctions:(...a)=>a.reduce((a,b)=>(...c)=>b(a(...c))),pluralize:(a,b,c=b+'s')=>{const d=(a,b,c=b+'s')=>[1,-1].includes(+a)?b:c;return'object'==typeof a?(b,c)=>d(b,c,a[c]):d(a,b,c)},powerset:(a)=>a.reduce((b,a)=>b.concat(b.map((b)=>[a].concat(b))),[[]]),prettyBytes:(a,b=3,c=!0)=>{const f=['B','KB','MB','GB','TB','PB','EB','ZB','YB'];if(1>Math.abs(a))return a+(c?' ':'')+f[0];const g=e(d(Math.log10(0>a?-a:a)/3),f.length-1),h=+((0>a?-a:a)/1e3**g).toPrecision(b);return(0>a?'-':'')+h+(c?' ':'')+f[g]},primes:(a)=>{let c=Array.from({length:a-1}).map((a,b)=>b+2),e=d(b(a)),f=Array.from({length:e-1}).map((a,b)=>b+2);return f.forEach((a)=>c=c.filter((b)=>0!=b%a||b==a)),c},promisify:(a)=>(...b)=>new Promise((c,d)=>a(...b,(a,b)=>a?d(a):c(b))),pull:(a,...b)=>{let c=Array.isArray(b[0])?b[0]:b,d=a.filter((a)=>!c.includes(a));a.length=0,d.forEach((b)=>a.push(b))},pullAtIndex:(a,b)=>{let c=[],d=a.map((a,d)=>b.includes(d)?c.push(a):a).filter((a,c)=>!b.includes(c));return a.length=0,d.forEach((b)=>a.push(b)),c},pullAtValue:(a,b)=>{let c=[],d=a.forEach((a)=>b.includes(a)?c.push(a):a),e=a.filter((a)=>!b.includes(a));return a.length=0,e.forEach((b)=>a.push(b)),c},pullBy:(a,...b)=>{const c=b.length;let d=1d(a)),f=a.filter((a)=>!e.includes(d(a)));a.length=0,f.forEach((b)=>a.push(b))},randomHexColorCode:()=>{let a=(0|1048575*Math.random()).toString(16);return'#'+(6===a.length?a:(0|15*Math.random()).toString(16)+a)},randomIntArrayInRange:(a,b,c=1)=>Array.from({length:c},()=>d(Math.random()*(b-a+1))+a),randomIntegerInRange:(a,b)=>d(Math.random()*(b-a+1))+a,randomNumberInRange:(a,b)=>Math.random()*(b-a)+a,readFileLines:(a)=>t.readFileSync(a).toString('UTF8').split('\n'),redirect:(a,b=!0)=>b?window.location.href=a:window.location.replace(a),reduceSuccessive:(a,b,c)=>a.reduce((a,c,d,e)=>(a.push(b(a.slice(-1)[0],c,d,e)),a),[c]),reduceWhich:(a,c=(c,a)=>c-a)=>a.reduce((d,a)=>0<=c(d,a)?a:d),reducedFilter:(a,b,c)=>a.filter(c).map((a)=>b.reduce((b,c)=>(b[c]=a[c],b),{})),remove:(a,b)=>Array.isArray(a)?a.filter(b).reduce((b,c)=>(a.splice(a.indexOf(c),1),b.concat(c)),[]):[],removeNonASCII:(a)=>a.replace(/[^\x20-\x7E]/g,''),reverseString:(a)=>[...a].join(''),round:(b,c=0)=>+`${a(`${b}e${c}`)}e-${c}`,runAsync:(a)=>{const b=`var fn = ${a.toString()}; postMessage(fn());`,c=new Worker(URL.createObjectURL(new Blob([b]),{type:'application/javascript; charset=utf-8'}));return new Promise((a,b)=>{c.onmessage=({data:b})=>{a(b),c.terminate()},c.onerror=(a)=>{b(a),c.terminate()}})},runPromisesInSeries:(a)=>a.reduce((a,b)=>a.then(b),Promise.resolve()),sample:(a)=>a[d(Math.random()*a.length)],sampleSize:([...a],b=1)=>{for(let c=a.length;c;){const b=d(Math.random()*c--);[a[c],a[b]]=[a[b],a[c]]}return a.slice(0,b)},scrollToTop:u,sdbm:(a)=>{let b=a.split('');return b.reduce((a,b)=>a=b.charCodeAt(0)+(a<<6)+(a<<16)-a,0)},serializeCookie:(a,b)=>`${encodeURIComponent(a)}=${encodeURIComponent(b)}`,setStyle:(a,b,c)=>a.style[b]=c,shallowClone:(a)=>Object.assign({},a),show:(...a)=>[...a].forEach((a)=>a.style.display=''),shuffle:([...a])=>{for(let b=a.length;b;){const c=d(Math.random()*b--);[a[b],a[c]]=[a[c],a[b]]}return a},similarity:(a,b)=>a.filter((a)=>b.includes(a)),size:(a)=>Array.isArray(a)?a.length:a&&'object'==typeof a?a.size||a.length||Object.keys(a).length:'string'==typeof a?new Blob([a]).size:0,sleep:(a)=>new Promise((b)=>setTimeout(b,a)),sortCharactersInString:(a)=>[...a].sort((c,a)=>c.localeCompare(a)).join(''),sortedIndex:(a,b)=>{const c=a[0]>a[a.length-1],d=a.findIndex((a)=>c?b>=a:b<=a);return-1===d?a.length:d},sortedIndexBy:(a,b,c)=>{const d=c(a[0])>c(a[a.length-1]),e=c(b),f=a.findIndex((a)=>d?e>=c(a):e<=c(a));return-1===f?a.length:f},sortedLastIndex:(a,b)=>{const c=a[0]>a[a.length-1],d=a.map((a,b)=>[b,a]).reverse().findIndex((a)=>c?b<=a[1]:b>=a[1]);return-1===d?0:a.length-d-1},sortedLastIndexBy:(a,b,c)=>{const d=c(a[0])>c(a[a.length-1]),e=c(b),f=a.map((a,b)=>[b,c(a)]).reverse().findIndex((a)=>d?e<=a[1]:e>=a[1]);return-1===f?0:a.length-f},splitLines:(a)=>a.split(/\r?\n/),spreadOver:(a)=>(b)=>a(...b),standardDeviation:(a,c=!1)=>{const d=a.reduce((a,b)=>a+b,0)/a.length;return b(a.reduce((a,b)=>a.concat((b-d)**2),[]).reduce((a,b)=>a+b,0)/(a.length-(c?0:1)))},stripHTMLTags:(a)=>a.replace(/<[^>]*>/g,''),sum:(...a)=>[...a].reduce((a,b)=>a+b,0),sumBy:(a,b)=>a.map('function'==typeof b?b:(a)=>a[b]).reduce((a,b)=>a+b,0),sumPower:(a,b=2,c=1)=>Array(a+1-c).fill(0).map((a,d)=>(d+c)**b).reduce((c,a)=>c+a,0),symmetricDifference:(c,a)=>{const b=new Set(c),d=new Set(a);return[...c.filter((a)=>!d.has(a)),...a.filter((a)=>!b.has(a))]},symmetricDifferenceBy:(c,a,b)=>{const d=new Set(c.map((a)=>b(a))),e=new Set(a.map((a)=>b(a)));return[...c.filter((a)=>!e.has(b(a))),...a.filter((a)=>!d.has(b(a)))]},symmetricDifferenceWith:(b,c,d)=>[...b.filter((e)=>-1===c.findIndex((a)=>d(e,a))),...c.filter((c)=>-1===b.findIndex((a)=>d(c,a)))],tail:(a)=>1a.slice(0,b),takeRight:(a,b=1)=>a.slice(a.length-b,a.length),takeRightWhile:(a,b)=>{for(let c of a.reverse().keys())if(b(a[c]))return a.reverse().slice(a.length-c,a.length);return a},takeWhile:(a,b)=>{for(let c of a.keys())if(b(a[c]))return a.slice(0,c);return a},timeTaken:(a)=>{console.time('timeTaken');const b=a();return console.timeEnd('timeTaken'),b},times:(a,b,c=void 0)=>{for(let d=0;!1!==b.call(c,d)&&++d{let b=a&&a.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map((a)=>a.slice(0,1).toUpperCase()+a.slice(1).toLowerCase()).join('');return b.slice(0,1).toLowerCase()+b.slice(1)},toDecimalMark:(a)=>a.toLocaleString('en-US'),toKebabCase:(a)=>a&&a.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map((a)=>a.toLowerCase()).join('-'),toOrdinalSuffix:(a)=>{const b=parseInt(a),c=[b%10,b%100],d=['st','nd','rd','th'];return[1,2,3,4].includes(c[0])&&![11,12,13,14,15,16,17,18,19].includes(c[1])?b+d[c[0]-1]:b+d[3]},toSafeInteger:(b)=>a(f(e(b,Number.MAX_SAFE_INTEGER),Number.MIN_SAFE_INTEGER)),toSnakeCase:(a)=>a&&a.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map((a)=>a.toLowerCase()).join('_'),toggleClass:(a,b)=>a.classList.toggle(b),tomorrow:()=>{let a=new Date;return a.setDate(a.getDate()+1),`${a.getFullYear()}-${(a.getMonth()+1+'').padStart(2,'0')}-${(a.getDate()+'').padStart(2,'0')}`},transform:(b,c,a)=>Object.keys(b).reduce((d,a)=>c(d,b[a],a,b),a),truncateString:(a,b)=>a.length>b?a.slice(0,3a.every((a)=>a[b]),unary:(a)=>(b)=>a(b),unescapeHTML:(a)=>a.replace(/&|<|>|'|"/g,(a)=>({"&":'&',"<":'<',">":'>',"'":'\'',""":'"'})[a]||a),unfold:(a,b)=>{let c=[],d=[null,b];for(;d=a(d[1]);)c.push(d[0]);return c},union:(c,a)=>Array.from(new Set([...c,...a])),unionBy:(c,a,b)=>{const d=new Set(c.map((a)=>b(a)));return Array.from(new Set([...c,...a.filter((a)=>!d.has(b(a)))]))},unionWith:(c,a,b)=>Array.from(new Set([...c,...a.filter((a)=>-1===c.findIndex((c)=>b(a,c)))])),uniqueElements:(a)=>[...new Set(a)],untildify:(a)=>a.replace(/^~($|\/|\\)/,`${'undefined'!=typeof require&&require('os').homedir()}$1`),unzip:(a)=>a.reduce((a,b)=>(b.forEach((b,c)=>a[c].push(b)),a),Array.from({length:f(...a.map((a)=>a.length))}).map(()=>[])),unzipWith:(a,b)=>a.reduce((a,b)=>(b.forEach((b,c)=>a[c].push(b)),a),Array.from({length:f(...a.map((a)=>a.length))}).map(()=>[])).map((a)=>b(...a)),validateNumber:(a)=>!isNaN(parseFloat(a))&&isFinite(a)&&+a==a,without:(a,...b)=>a.filter((a)=>!b.includes(a)),words:(a,b=/[^a-zA-Z-]+/)=>a.split(b).filter(Boolean),xProd:(c,a)=>c.reduce((b,c)=>b.concat(a.map((a)=>[c,a])),[]),yesNo:(a,b=!1)=>!!/^(y|yes)$/i.test(a)||!/^(n|no)$/i.test(a)&&b,zip:(...a)=>{const b=f(...a.map((a)=>a.length));return Array.from({length:b}).map((b,c)=>Array.from({length:a.length},(b,d)=>a[d][c]))},zipObject:(a,b)=>a.reduce((a,c,d)=>(a[c]=b[d],a),{}),zipWith:(...a)=>{const b=a.length;let c=1a.length)),e=Array.from({length:d}).map((b,c)=>Array.from({length:a.length},(b,d)=>a[d][c]));return c?e.map((a)=>c(...a)):e}}}); +(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?module.exports=b():'function'==typeof define&&define.amd?define(b):a._30s=b()})(this,function(){'use strict';var a=Math.round,b=Math.sqrt,c=Math.log,d=Math.floor,e=Math.min,g=Math.max,h=Math.ceil;const i='undefined'!=typeof require&&require('fs'),j='undefined'!=typeof require&&require('crypto'),k=(a)=>2>=a.length?2===a.length?[a,a[1]+a[0]]:[a]:a.split('').reduce((b,c,d)=>b.concat(k(a.slice(0,d)+a.slice(d+1)).map((a)=>c+a)),[]),l=(a,b=a.length,...c)=>b<=c.length?a(...c):l.bind(null,a,b,...c),m=(a)=>{let b=Object.assign({},a);return Object.keys(b).forEach((c)=>b[c]='object'==typeof a[c]?m(a[c]):a[c]),b},n=(a)=>[].concat(...a.map((a)=>Array.isArray(a)?n(a):a)),o=([...c],d=32,e)=>{const[g,a]=c,b=(a,b)=>1/(1+10**((b-a)/400)),h=(c,h)=>(e||c)+d*(h-b(h?g:a,h?a:g));if(2===c.length)return[h(g,1),h(a,0)];for(let a,b=0;b{if(c===d)return!0;if(c instanceof Date&&d instanceof Date)return c.getTime()===d.getTime();if(!c||!d||'object'!=typeof c&&'object'!=typeof d)return c===d;if(null===c||void 0===c||null===d||void 0===d)return!1;if(c.prototype!==d.prototype)return!1;let e=Object.keys(c);return!(e.length!==Object.keys(d).length)&&e.every((a)=>p(c[a],d[a]))},q=(a)=>0>a?(()=>{throw new TypeError('Negative numbers are not allowed!')})():1>=a?1:a*q(a-1),r=(a,b=1)=>1==b?a.reduce((b,a)=>b.concat(a),[]):a.reduce((c,a)=>c.concat(Array.isArray(a)?r(a,b-1):a),[]),s=(...a)=>{const c=(a,b)=>b?s(b,a%b):a;return[...a].reduce((d,a)=>c(d,a))},t='undefined'!=typeof require&&require('crypto'),u='undefined'!=typeof require&&require('fs'),v=()=>{const a=document.documentElement.scrollTop||document.body.scrollTop;0i.writeFile(`${b}.json`,JSON.stringify(a,null,2)),RGBToHex:(a,c,d)=>((a<<16)+(c<<8)+d).toString(16).padStart(6,'0'),URLJoin:(...a)=>a.join('/').replace(/[\/]+/g,'/').replace(/^(.+):\//,'$1://').replace(/^file:/,'file:/').replace(/\/(\?|&|#[^!])/g,'$1').replace(/\?/g,'&').replace('&','?'),UUIDGeneratorBrowser:()=>'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,(a)=>(a^crypto.getRandomValues(new Uint8Array(1))[0]&15>>a/4).toString(16)),UUIDGeneratorNode:()=>'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,(a)=>(a^j.randomBytes(1)[0]&15>>a/4).toString(16)),anagrams:k,arrayToHtmlList:(a,b)=>a.map((a)=>document.querySelector('#'+b).innerHTML+=`
  • ${a}
  • `),ary:(a,b)=>(...c)=>a(...c.slice(0,b)),atob:(a)=>new Buffer(a,'base64').toString('binary'),attempt:(a,...b)=>{try{return a(b)}catch(a){return a instanceof Error?a:new Error(a)}},average:(...a)=>[...a].reduce((a,b)=>a+b,0)/a.length,averageBy:(a,b)=>a.map('function'==typeof b?b:(a)=>a[b]).reduce((a,b)=>a+b,0)/a.length,bind:(a,b,...c)=>function(){return a.apply(b,c.concat(...arguments))},bindAll:(a,...b)=>b.forEach((b)=>(f=a[b],a[b]=function(){return f.apply(a)})),bindKey:(a,b,...c)=>function(){return a[b].apply(a,c.concat(...arguments))},bottomVisible:()=>document.documentElement.clientHeight+window.scrollY>=(document.documentElement.scrollHeight||document.documentElement.clientHeight),btoa:(a)=>new Buffer(a,'binary').toString('base64'),byteSize:(a)=>new Blob([a]).size,call:(a,...b)=>(c)=>c[a](...b),capitalize:([a,...b],c=!1)=>a.toUpperCase()+(c?b.join('').toLowerCase():b.join('')),capitalizeEveryWord:(a)=>a.replace(/\b[a-z]/g,(a)=>a.toUpperCase()),castArray:(a)=>Array.isArray(a)?a:[a],chainAsync:(a)=>{let b=0;const c=()=>a[b++](c);c()},chunk:(a,b)=>Array.from({length:h(a.length/b)},(c,d)=>a.slice(d*b,d*b+b)),clampNumber:(c,d,a)=>g(e(c,g(d,a)),e(d,a)),cloneRegExp:(a)=>new RegExp(a.source,a.flags),coalesce:(...a)=>a.find((a)=>![void 0,null].includes(a)),coalesceFactory:(a)=>(...b)=>b.find(a),collectInto:(a)=>(...b)=>a(b),colorize:(...a)=>({black:`\x1b[30m${a.join(' ')}`,red:`\x1b[31m${a.join(' ')}`,green:`\x1b[32m${a.join(' ')}`,yellow:`\x1b[33m${a.join(' ')}`,blue:`\x1b[34m${a.join(' ')}`,magenta:`\x1b[35m${a.join(' ')}`,cyan:`\x1b[36m${a.join(' ')}`,white:`\x1b[37m${a.join(' ')}`,bgBlack:`\x1b[40m${a.join(' ')}\x1b[0m`,bgRed:`\x1b[41m${a.join(' ')}\x1b[0m`,bgGreen:`\x1b[42m${a.join(' ')}\x1b[0m`,bgYellow:`\x1b[43m${a.join(' ')}\x1b[0m`,bgBlue:`\x1b[44m${a.join(' ')}\x1b[0m`,bgMagenta:`\x1b[45m${a.join(' ')}\x1b[0m`,bgCyan:`\x1b[46m${a.join(' ')}\x1b[0m`,bgWhite:`\x1b[47m${a.join(' ')}\x1b[0m`}),compact:(a)=>a.filter(Boolean),compose:(...a)=>a.reduce((a,b)=>(...c)=>a(b(...c))),composeRight:(...a)=>a.reduce((a,b)=>(...c)=>b(a(...c))),copyToClipboard:(a)=>{const b=document.createElement('textarea');b.value=a,b.setAttribute('readonly',''),b.style.position='absolute',b.style.left='-9999px',document.body.appendChild(b);const c=!!(0a.map('function'==typeof b?b:(a)=>a[b]).reduce((a,b)=>(a[b]=(a[b]||0)+1,a),{}),countOccurrences:(a,b)=>a.reduce((c,a)=>a===b?c+1:c+0,0),createElement:(a)=>{const b=document.createElement('div');return b.innerHTML=a,b.firstElementChild},createEventHub:()=>({hub:Object.create(null),emit(a,b){(this.hub[a]||[]).forEach((a)=>a(b))},on(a,b){this.hub[a]||(this.hub[a]=[]),this.hub[a].push(b)},off(a,b){const c=(this.hub[a]||[]).findIndex((a)=>a===b);-1window.location.href,curry:l,debounce:(a,b=0)=>{let c;return function(){const d=this,e=arguments;clearTimeout(c),c=setTimeout(()=>a.apply(d,e),b)}},decapitalize:([a,...b],c=!1)=>a.toLowerCase()+(c?b.join('').toUpperCase():b.join('')),deepClone:m,deepFlatten:n,defaults:(a,...b)=>Object.assign({},a,...b.reverse(),a),defer:(a,...b)=>setTimeout(a,1,...b),delay:(a,b,...c)=>setTimeout(a,b,...c),detectDeviceType:()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?'Mobile':'Desktop',difference:(c,a)=>{const b=new Set(a);return c.filter((a)=>!b.has(a))},differenceBy:(c,a,b)=>{const d=new Set(a.map((a)=>b(a)));return c.filter((a)=>!d.has(b(a)))},differenceWith:(a,b,c)=>a.filter((d)=>-1===b.findIndex((a)=>c(d,a))),digitize:(a)=>[...`${a}`].map((a)=>parseInt(a)),distance:(a,b,c,d)=>Math.hypot(c-a,d-b),drop:(a,b=1)=>a.slice(b),dropRight:(a,b=1)=>a.slice(0,-b),dropRightWhile:(a,b)=>{for(;0{for(;0{const{top:c,left:d,bottom:e,right:g}=a.getBoundingClientRect(),{innerHeight:h,innerWidth:i}=window;return b?(0a.replace(/[&<>'"]/g,(a)=>({"&":'&',"<":'<',">":'>',"'":''','"':'"'})[a]||a),escapeRegExp:(a)=>a.replace(/[.*+?^${}()|[\]\\]/g,'\\$&'),everyNth:(a,b)=>a.filter((a,c)=>c%b==b-1),extendHex:(a)=>'#'+a.slice(a.startsWith('#')?1:0).split('').map((a)=>a+a).join(''),factorial:q,fibonacci:(a)=>Array.from({length:a}).reduce((a,b,c)=>a.concat(1a.filter((b)=>a.indexOf(b)===a.lastIndexOf(b)),findKey:(a,b)=>Object.keys(a).find((c)=>b(a[c],c,a)),findLast:(a,b)=>a.filter(b).slice(-1)[0],findLastIndex:(a,b)=>a.map((a,b)=>[b,a]).filter((c)=>b(c[1],c[0],a)).slice(-1)[0][0],findLastKey:(a,b)=>Object.keys(a).reverse().find((c)=>b(a[c],c,a)),flatten:r,flip:(a)=>(b,...c)=>a(...c,b),forEachRight:(a,b)=>a.slice(0).reverse().forEach(b),forOwn:(a,b)=>Object.keys(a).forEach((c)=>b(a[c],c,a)),forOwnRight:(a,b)=>Object.keys(a).reverse().forEach((c)=>b(a[c],c,a)),formatDuration:(a)=>{0>a&&(a=-a);const b={day:d(a/8.64e7),hour:d(a/3.6e6)%24,minute:d(a/6e4)%60,second:d(a/1e3)%60,millisecond:d(a)%1e3};return Object.entries(b).filter((a)=>0!==a[1]).map((a)=>a[1]+' '+(1===a[1]?a[0]:a[0]+'s')).join(', ')},fromCamelCase:(a,b='_')=>a.replace(/([a-z\d])([A-Z])/g,'$1'+b+'$2').replace(/([A-Z]+)([A-Z][a-z\d]+)/g,'$1'+b+'$2').toLowerCase(),functionName:(a)=>(console.debug(a.name),a),functions:(a,b=!1)=>(b?[...Object.keys(a),...Object.keys(Object.getPrototypeOf(a))]:Object.keys(a)).filter((b)=>'function'==typeof a[b]),gcd:s,geometricProgression:(a,b=1,e=2)=>Array.from({length:d(c(a/b)/c(e))+1}).map((a,c)=>b*e**c),get:(a,...b)=>[...b].map((b)=>b.replace(/\[([^\[\]]*)\]/g,'.$1.').split('.').filter((a)=>''!==a).reduce((a,b)=>a&&a[b],a)),getDaysDiffBetweenDates:(a,b)=>(b-a)/86400000,getScrollPosition:(a=window)=>({x:a.pageXOffset===void 0?a.scrollLeft:a.pageXOffset,y:a.pageYOffset===void 0?a.scrollTop:a.pageYOffset}),getStyle:(a,b)=>getComputedStyle(a)[b],getType:(a)=>a===void 0?'undefined':null===a?'null':a.constructor.name.toLowerCase(),getURLParameters:(a)=>(a.match(/([^?=&]+)(=([^&]*))/g)||[]).reduce((b,a)=>(b[a.slice(0,a.indexOf('='))]=a.slice(a.indexOf('=')+1),b),{}),groupBy:(a,b)=>a.map('function'==typeof b?b:(a)=>a[b]).reduce((b,c,d)=>(b[c]=(b[c]||[]).concat(a[d]),b),{}),hammingDistance:(a,b)=>((a^b).toString(2).match(/1/g)||'').length,hasClass:(a,b)=>a.classList.contains(b),hasFlags:(...a)=>a.every((a)=>process.argv.includes(/^-{1,2}/.test(a)?a:'--'+a)),hashBrowser:(a)=>crypto.subtle.digest('SHA-256',new TextEncoder('utf-8').encode(a)).then((a)=>{let b=[],c=new DataView(a);for(let d=0;dnew Promise((b)=>setTimeout(()=>b(t.createHash('sha256').update(a).digest('hex')),0)),head:(a)=>a[0],hexToRGB:(a)=>{let b=!1,c=a.slice(a.startsWith('#')?1:0);return 3===c.length?c=[...c].map((a)=>a+a).join(''):8===c.length&&(b=!0),c=parseInt(c,16),'rgb'+(b?'a':'')+'('+(c>>>(b?24:16))+', '+((c&(b?16711680:65280))>>>(b?16:8))+', '+((c&(b?65280:255))>>>(b?8:0))+(b?`, ${255&c}`:'')+')'},hide:(...a)=>[...a].forEach((a)=>a.style.display='none'),httpGet:(a,b,c=console.error)=>{const d=new XMLHttpRequest;d.open('GET',a,!0),d.onload=()=>b(d.responseText),d.onerror=()=>c(d),d.send()},httpPost:(a,b,c,d=console.error)=>{const e=new XMLHttpRequest;e.open('POST',a,!0),e.setRequestHeader('Content-type','application/json; charset=utf-8'),e.onload=()=>c(e.responseText),e.onerror=()=>d(e),e.send(b)},httpsRedirect:()=>{'https:'!==location.protocol&&location.replace('https://'+location.href.split('//')[1])},inRange:(a,b,c=null)=>(c&&b>c&&(c=b),null==c?0<=a&&a=b&&a{const c=[];return a.forEach((a,d)=>a===b&&c.push(d)),c},initial:(a)=>a.slice(0,-1),initialize2DArray:(a,b,c=null)=>Array.from({length:b}).map(()=>Array.from({length:a}).fill(c)),initializeArrayWithRange:(a,b=0,c=1)=>Array.from({length:h((a+1-b)/c)}).map((a,d)=>d*c+b),initializeArrayWithRangeRight:(a,b=0,c=1)=>Array.from({length:h((a+1-b)/c)}).map((a,d,e)=>(e.length-d-1)*c+b),initializeArrayWithValues:(a,b=0)=>Array(a).fill(b),intersection:(c,a)=>{const b=new Set(a);return c.filter((a)=>b.has(a))},intersectionBy:(c,a,b)=>{const d=new Set(a.map((a)=>b(a)));return c.filter((a)=>d.has(b(a)))},intersectionWith:(c,a,b)=>c.filter((c)=>-1!==a.findIndex((a)=>b(c,a))),invertKeyValues:(a,b)=>Object.keys(a).reduce((c,d)=>{const e=b?b(a[d]):a[d];return c[e]=c[e]||[],c[e].push(d),c},{}),is:(a,b)=>b instanceof a,isAbsoluteURL:(a)=>/^[a-z][a-z0-9+.-]*:/.test(a),isArrayLike:(a)=>{try{return[...a],!0}catch(a){return!1}},isBoolean:(a)=>'boolean'==typeof a,isDivisible:(a,b)=>0==a%b,isEmpty:(a)=>null==a||!(Object.keys(a)||a).length,isEven:(a)=>0==a%2,isFunction:(a)=>'function'==typeof a,isLowerCase:(a)=>a===a.toLowerCase(),isNil:(a)=>a===void 0||null===a,isNull:(a)=>null===a,isNumber:(a)=>'number'==typeof a,isObject:(a)=>a===Object(a),isObjectLike:(a)=>null!==a&&'object'==typeof a,isPlainObject:(a)=>!!a&&'object'==typeof a&&a.constructor===Object,isPrime:(a)=>{const c=d(b(a));for(var e=2;e<=c;e++)if(0==a%e)return!1;return 2<=a},isPrimitive:(a)=>!['object','function'].includes(typeof a)||null===a,isPromiseLike:(a)=>null!==a&&('object'==typeof a||'function'==typeof a)&&'function'==typeof a.then,isSorted:(a)=>{const b=a[0]>a[1]?-1:1;for(let[c,d]of a.entries()){if(c===a.length-1)return b;if(0<(d-a[c+1])*b)return 0}},isString:(a)=>'string'==typeof a,isSymbol:(a)=>'symbol'==typeof a,isTravisCI:()=>'TRAVIS'in process.env&&'CI'in process.env,isUndefined:(a)=>a===void 0,isUpperCase:(a)=>a===a.toUpperCase(),isValidJSON:(a)=>{try{return JSON.parse(a),!0}catch(a){return!1}},join:(a,b=',',c=b)=>a.reduce((d,e,g)=>g==a.length-2?d+e+c:g==a.length-1?d+e:d+e+b,''),last:(a)=>a[a.length-1],lcm:(...a)=>{const b=(a,c)=>c?b(c,a%c):a,c=(a,c)=>a*c/b(a,c);return[...a].reduce((d,a)=>c(d,a))},longestItem:(...a)=>[...a].sort((c,a)=>a.length-c.length)[0],lowercaseKeys:(a)=>Object.keys(a).reduce((b,c)=>(b[c.toLowerCase()]=a[c],b),{}),luhnCheck:(a)=>{let b=(a+'').split('').reverse().map((a)=>parseInt(a)),c=b.splice(0,1)[0],d=b.reduce((a,b,c)=>0==c%2?a+2*b%9||9:a+b,0);return d+=c,0==d%10},mapKeys:(a,b)=>Object.keys(a).reduce((c,d)=>(c[b(a[d],d,a)]=a[d],c),{}),mapObject:(b,c)=>((d)=>(d=[b,b.map(c)],d[0].reduce((a,b,c)=>(a[b]=d[1][c],a),{})))(),mapValues:(a,b)=>Object.keys(a).reduce((c,d)=>(c[d]=b(a[d],d,a),c),{}),mask:(a,b=4,c='*')=>(''+a).slice(0,-b).replace(/./g,c)+(''+a).slice(-b),matches:(a,b)=>Object.keys(b).every((c)=>a.hasOwnProperty(c)&&a[c]===b[c]),matchesWith:(a,b,c)=>Object.keys(b).every((d)=>a.hasOwnProperty(d)&&c?c(a[d],b[d],d,a,b):a[d]==b[d]),maxBy:(a,b)=>g(...a.map('function'==typeof b?b:(a)=>a[b])),maxN:(a,b=1)=>[...a].sort((c,a)=>a-c).slice(0,b),median:(a)=>{const b=d(a.length/2),c=[...a].sort((c,a)=>c-a);return 0==a.length%2?(c[b-1]+c[b])/2:c[b]},memoize:(a)=>{const b=new Map,c=function(c){return b.has(c)?b.get(c):b.set(c,a.call(this,c))&&b.get(c)};return c.cache=b,c},merge:(...a)=>[...a].reduce((b,c)=>Object.keys(c).reduce((d,a)=>(b[a]=b.hasOwnProperty(a)?[].concat(b[a]).concat(c[a]):c[a],b),{}),{}),minBy:(a,b)=>e(...a.map('function'==typeof b?b:(a)=>a[b])),minN:(a,b=1)=>[...a].sort((c,a)=>c-a).slice(0,b),negate:(a)=>(...b)=>!a(...b),nthArg:(a)=>(...b)=>b.slice(a)[0],nthElement:(a,b=0)=>(0a.reduce((b,a)=>(b[a[0]]=a[1],b),{}),objectToPairs:(a)=>Object.keys(a).map((b)=>[b,a[b]]),observeMutations:(a,b,c)=>{const d=new MutationObserver((a)=>a.forEach((a)=>b(a)));return d.observe(a,Object.assign({childList:!0,attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,subtree:!0},c)),d},off:(a,b,c,d=!1)=>a.removeEventListener(b,c,d),omit:(a,b)=>Object.keys(a).filter((a)=>!b.includes(a)).reduce((b,c)=>(b[c]=a[c],b),{}),omitBy:(a,b)=>Object.keys(a).filter((c)=>!b(a[c],c)).reduce((b,c)=>(b[c]=a[c],b),{}),on:(a,b,c,d={})=>{const e=(a)=>a.target.matches(d.target)&&c.call(a.target,a);if(a.addEventListener(b,d.target?e:c,d.options||!1),d.target)return e},onUserInputChange:(a)=>{let b='mouse',c=0;const d=()=>{const e=performance.now();20>e-c&&(b='mouse',a(b),document.removeEventListener('mousemove',d)),c=e};document.addEventListener('touchstart',()=>{'touch'==b||(b='touch',a(b),document.addEventListener('mousemove',d))})},once:(a)=>{let b=!1;return function(...c){if(!b)return b=!0,a.apply(this,c)}},orderBy:(a,c,d)=>[...a].sort((e,a)=>c.reduce((b,c,g)=>{if(0===b){const[h,i]=d&&'desc'===d[g]?[a[c],e[c]]:[e[c],a[c]];b=h>i?1:h(...b)=>a.map((a)=>a.apply(null,b)),overArgs:(a,b)=>(...c)=>a(...c.map((a,c)=>b[c](a))),palindrome:(a)=>{const b=a.toLowerCase().replace(/[\W_]/g,'');return b===b.split('').reverse().join('')},parseCookie:(a)=>a.split(';').map((a)=>a.split('=')).reduce((a,b)=>(a[decodeURIComponent(b[0].trim())]=decodeURIComponent(b[1].trim()),a),{}),partial:(a,...b)=>(...c)=>a(...b,...c),partialRight:(a,...b)=>(...c)=>a(...c,...b),partition:(a,b)=>a.reduce((a,c,d,e)=>(a[b(c,d,e)?0:1].push(c),a),[[],[]]),percentile:(a,b)=>100*a.reduce((a,c)=>a+(cb.reduce((b,c)=>(c in a&&(b[c]=a[c]),b),{}),pickBy:(a,b)=>Object.keys(a).filter((c)=>b(a[c],c)).reduce((b,c)=>(b[c]=a[c],b),{}),pipeAsyncFunctions:(...a)=>(b)=>a.reduce((a,b)=>a.then(b),Promise.resolve(b)),pipeFunctions:(...a)=>a.reduce((a,b)=>(...c)=>b(a(...c))),pluralize:(a,b,c=b+'s')=>{const d=(a,b,c=b+'s')=>[1,-1].includes(+a)?b:c;return'object'==typeof a?(b,c)=>d(b,c,a[c]):d(a,b,c)},powerset:(a)=>a.reduce((b,a)=>b.concat(b.map((b)=>[a].concat(b))),[[]]),prettyBytes:(a,b=3,c=!0)=>{const g=['B','KB','MB','GB','TB','PB','EB','ZB','YB'];if(1>Math.abs(a))return a+(c?' ':'')+g[0];const h=e(d(Math.log10(0>a?-a:a)/3),g.length-1),i=+((0>a?-a:a)/1e3**h).toPrecision(b);return(0>a?'-':'')+i+(c?' ':'')+g[h]},primes:(a)=>{let c=Array.from({length:a-1}).map((a,b)=>b+2),e=d(b(a)),g=Array.from({length:e-1}).map((a,b)=>b+2);return g.forEach((a)=>c=c.filter((b)=>0!=b%a||b==a)),c},promisify:(a)=>(...b)=>new Promise((c,d)=>a(...b,(a,b)=>a?d(a):c(b))),pull:(a,...b)=>{let c=Array.isArray(b[0])?b[0]:b,d=a.filter((a)=>!c.includes(a));a.length=0,d.forEach((b)=>a.push(b))},pullAtIndex:(a,b)=>{let c=[],d=a.map((a,d)=>b.includes(d)?c.push(a):a).filter((a,c)=>!b.includes(c));return a.length=0,d.forEach((b)=>a.push(b)),c},pullAtValue:(a,b)=>{let c=[],d=a.forEach((a)=>b.includes(a)?c.push(a):a),e=a.filter((a)=>!b.includes(a));return a.length=0,e.forEach((b)=>a.push(b)),c},pullBy:(a,...b)=>{const c=b.length;let d=1d(a)),g=a.filter((a)=>!e.includes(d(a)));a.length=0,g.forEach((b)=>a.push(b))},randomHexColorCode:()=>{let a=(0|1048575*Math.random()).toString(16);return'#'+(6===a.length?a:(0|15*Math.random()).toString(16)+a)},randomIntArrayInRange:(a,b,c=1)=>Array.from({length:c},()=>d(Math.random()*(b-a+1))+a),randomIntegerInRange:(a,b)=>d(Math.random()*(b-a+1))+a,randomNumberInRange:(a,b)=>Math.random()*(b-a)+a,readFileLines:(a)=>u.readFileSync(a).toString('UTF8').split('\n'),rearg:(a,b)=>(...c)=>a(...c.reduce((a,c,d)=>(a[b.indexOf(d)]=c,a),Array.from({length:b.length}))),redirect:(a,b=!0)=>b?window.location.href=a:window.location.replace(a),reduceSuccessive:(a,b,c)=>a.reduce((a,c,d,e)=>(a.push(b(a.slice(-1)[0],c,d,e)),a),[c]),reduceWhich:(a,c=(c,a)=>c-a)=>a.reduce((d,a)=>0<=c(d,a)?a:d),reducedFilter:(a,b,c)=>a.filter(c).map((a)=>b.reduce((b,c)=>(b[c]=a[c],b),{})),remove:(a,b)=>Array.isArray(a)?a.filter(b).reduce((b,c)=>(a.splice(a.indexOf(c),1),b.concat(c)),[]):[],removeNonASCII:(a)=>a.replace(/[^\x20-\x7E]/g,''),reverseString:(a)=>[...a].join(''),round:(b,c=0)=>+`${a(`${b}e${c}`)}e-${c}`,runAsync:(a)=>{const b=`var fn = ${a.toString()}; postMessage(fn());`,c=new Worker(URL.createObjectURL(new Blob([b]),{type:'application/javascript; charset=utf-8'}));return new Promise((a,b)=>{c.onmessage=({data:b})=>{a(b),c.terminate()},c.onerror=(a)=>{b(a),c.terminate()}})},runPromisesInSeries:(a)=>a.reduce((a,b)=>a.then(b),Promise.resolve()),sample:(a)=>a[d(Math.random()*a.length)],sampleSize:([...a],b=1)=>{for(let c=a.length;c;){const b=d(Math.random()*c--);[a[c],a[b]]=[a[b],a[c]]}return a.slice(0,b)},scrollToTop:v,sdbm:(a)=>{let b=a.split('');return b.reduce((a,b)=>a=b.charCodeAt(0)+(a<<6)+(a<<16)-a,0)},serializeCookie:(a,b)=>`${encodeURIComponent(a)}=${encodeURIComponent(b)}`,setStyle:(a,b,c)=>a.style[b]=c,shallowClone:(a)=>Object.assign({},a),show:(...a)=>[...a].forEach((a)=>a.style.display=''),shuffle:([...a])=>{for(let b=a.length;b;){const c=d(Math.random()*b--);[a[b],a[c]]=[a[c],a[b]]}return a},similarity:(a,b)=>a.filter((a)=>b.includes(a)),size:(a)=>Array.isArray(a)?a.length:a&&'object'==typeof a?a.size||a.length||Object.keys(a).length:'string'==typeof a?new Blob([a]).size:0,sleep:(a)=>new Promise((b)=>setTimeout(b,a)),sortCharactersInString:(a)=>[...a].sort((c,a)=>c.localeCompare(a)).join(''),sortedIndex:(a,b)=>{const c=a[0]>a[a.length-1],d=a.findIndex((a)=>c?b>=a:b<=a);return-1===d?a.length:d},sortedIndexBy:(a,b,c)=>{const d=c(a[0])>c(a[a.length-1]),e=c(b),g=a.findIndex((a)=>d?e>=c(a):e<=c(a));return-1===g?a.length:g},sortedLastIndex:(a,b)=>{const c=a[0]>a[a.length-1],d=a.map((a,b)=>[b,a]).reverse().findIndex((a)=>c?b<=a[1]:b>=a[1]);return-1===d?0:a.length-d-1},sortedLastIndexBy:(a,b,c)=>{const d=c(a[0])>c(a[a.length-1]),e=c(b),g=a.map((a,b)=>[b,c(a)]).reverse().findIndex((a)=>d?e<=a[1]:e>=a[1]);return-1===g?0:a.length-g},splitLines:(a)=>a.split(/\r?\n/),spreadOver:(a)=>(b)=>a(...b),standardDeviation:(a,c=!1)=>{const d=a.reduce((a,b)=>a+b,0)/a.length;return b(a.reduce((a,b)=>a.concat((b-d)**2),[]).reduce((a,b)=>a+b,0)/(a.length-(c?0:1)))},stripHTMLTags:(a)=>a.replace(/<[^>]*>/g,''),sum:(...a)=>[...a].reduce((a,b)=>a+b,0),sumBy:(a,b)=>a.map('function'==typeof b?b:(a)=>a[b]).reduce((a,b)=>a+b,0),sumPower:(a,b=2,c=1)=>Array(a+1-c).fill(0).map((a,d)=>(d+c)**b).reduce((c,a)=>c+a,0),symmetricDifference:(c,a)=>{const b=new Set(c),d=new Set(a);return[...c.filter((a)=>!d.has(a)),...a.filter((a)=>!b.has(a))]},symmetricDifferenceBy:(c,a,b)=>{const d=new Set(c.map((a)=>b(a))),e=new Set(a.map((a)=>b(a)));return[...c.filter((a)=>!e.has(b(a))),...a.filter((a)=>!d.has(b(a)))]},symmetricDifferenceWith:(b,c,d)=>[...b.filter((e)=>-1===c.findIndex((a)=>d(e,a))),...c.filter((c)=>-1===b.findIndex((a)=>d(c,a)))],tail:(a)=>1a.slice(0,b),takeRight:(a,b=1)=>a.slice(a.length-b,a.length),takeRightWhile:(a,b)=>{for(let c of a.reverse().keys())if(b(a[c]))return a.reverse().slice(a.length-c,a.length);return a},takeWhile:(a,b)=>{for(let c of a.keys())if(b(a[c]))return a.slice(0,c);return a},throttle:(a,b)=>{let c,d,e;return function(){const g=this,h=arguments;c?(clearTimeout(d),d=setTimeout(function(){Date.now()-e>=b&&(a.apply(g,h),e=Date.now())},b-(Date.now()-e))):(a.apply(g,h),e=Date.now(),c=!0)}},timeTaken:(a)=>{console.time('timeTaken');const b=a();return console.timeEnd('timeTaken'),b},times:(a,b,c=void 0)=>{for(let d=0;!1!==b.call(c,d)&&++d{let b=a&&a.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map((a)=>a.slice(0,1).toUpperCase()+a.slice(1).toLowerCase()).join('');return b.slice(0,1).toLowerCase()+b.slice(1)},toDecimalMark:(a)=>a.toLocaleString('en-US'),toKebabCase:(a)=>a&&a.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map((a)=>a.toLowerCase()).join('-'),toOrdinalSuffix:(a)=>{const b=parseInt(a),c=[b%10,b%100],d=['st','nd','rd','th'];return[1,2,3,4].includes(c[0])&&![11,12,13,14,15,16,17,18,19].includes(c[1])?b+d[c[0]-1]:b+d[3]},toSafeInteger:(b)=>a(g(e(b,Number.MAX_SAFE_INTEGER),Number.MIN_SAFE_INTEGER)),toSnakeCase:(a)=>a&&a.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map((a)=>a.toLowerCase()).join('_'),toggleClass:(a,b)=>a.classList.toggle(b),tomorrow:()=>{let a=new Date;return a.setDate(a.getDate()+1),`${a.getFullYear()}-${(a.getMonth()+1+'').padStart(2,'0')}-${(a.getDate()+'').padStart(2,'0')}`},transform:(b,c,a)=>Object.keys(b).reduce((d,a)=>c(d,b[a],a,b),a),truncateString:(a,b)=>a.length>b?a.slice(0,3a.every((a)=>a[b]),unary:(a)=>(b)=>a(b),unescapeHTML:(a)=>a.replace(/&|<|>|'|"/g,(a)=>({"&":'&',"<":'<',">":'>',"'":'\'',""":'"'})[a]||a),unfold:(a,b)=>{let c=[],d=[null,b];for(;d=a(d[1]);)c.push(d[0]);return c},union:(c,a)=>Array.from(new Set([...c,...a])),unionBy:(c,a,b)=>{const d=new Set(c.map((a)=>b(a)));return Array.from(new Set([...c,...a.filter((a)=>!d.has(b(a)))]))},unionWith:(c,a,b)=>Array.from(new Set([...c,...a.filter((a)=>-1===c.findIndex((c)=>b(a,c)))])),uniqueElements:(a)=>[...new Set(a)],untildify:(a)=>a.replace(/^~($|\/|\\)/,`${'undefined'!=typeof require&&require('os').homedir()}$1`),unzip:(a)=>a.reduce((a,b)=>(b.forEach((b,c)=>a[c].push(b)),a),Array.from({length:g(...a.map((a)=>a.length))}).map(()=>[])),unzipWith:(a,b)=>a.reduce((a,b)=>(b.forEach((b,c)=>a[c].push(b)),a),Array.from({length:g(...a.map((a)=>a.length))}).map(()=>[])).map((a)=>b(...a)),validateNumber:(a)=>!isNaN(parseFloat(a))&&isFinite(a)&&+a==a,without:(a,...b)=>a.filter((a)=>!b.includes(a)),words:(a,b=/[^a-zA-Z-]+/)=>a.split(b).filter(Boolean),xProd:(c,a)=>c.reduce((b,c)=>b.concat(a.map((a)=>[c,a])),[]),yesNo:(a,b=!1)=>!!/^(y|yes)$/i.test(a)||!/^(n|no)$/i.test(a)&&b,zip:(...a)=>{const b=g(...a.map((a)=>a.length));return Array.from({length:b}).map((b,c)=>Array.from({length:a.length},(b,d)=>a[d][c]))},zipObject:(a,b)=>a.reduce((a,c,d)=>(a[c]=b[d],a),{}),zipWith:(...a)=>{const b=a.length;let c=1a.length)),e=Array.from({length:d}).map((b,c)=>Array.from({length:a.length},(b,d)=>a[d][c]));return c?e.map((a)=>c(...a)):e}}}); diff --git a/docs/index.html b/docs/index.html index 6df6bfcae..366cc80a2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -50,7 +50,7 @@ scrollToTop(); } }, false); - }

    logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

     

    Adapter

    ary

    Creates a function that accepts up to n arguments, ignoring any additional arguments.

    Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

    const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
    +      }

    logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

     

    Adapter

    ary

    Creates a function that accepts up to n arguments, ignoring any additional arguments.

    Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

    const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
     
    const firstTwoMax = ary(Math.max, 2);
     [[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)); // [6, 8, 10]
     

    call

    Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

    Use a closure to call a stored key with stored arguments.

    const call = (key, ...args) => context => context[key](...args);
    @@ -66,7 +66,7 @@ Promise.reso
     let p1 = Promise.resolve(1);
     let p2 = Promise.resolve(2);
     let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
    -Pall(p1, p2, p3).then(console.log);
    +Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds)
     

    flip

    Flip takes a function as an argument, then makes the first argument the last.

    Return a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest.

    const flip = fn => (first, ...rest) => fn(...rest, first);
     
    let a = { name: 'John Smith' };
     let b = {};
    @@ -78,6 +78,24 @@ Object.assig
     

    over

    Creates a function that invokes each provided function with the arguments it receives and returns the results.

    Use Array.map() and Function.apply() to apply each function to the given arguments.

    const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args));
     
    const minMax = over(Math.min, Math.max);
     minMax(1, 2, 3, 4, 5); // [1,5]
    +

    overArgs

    Creates a function that invokes the provided function with its arguments transformed.

    Use Array.map() to apply transforms to args in combination with the spread operator (...) to pass the transformed arguments to fn.

    const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val)));
    +
    var func = overArgs(
    +  function(x, y) {
    +    return [x, y];
    +  },
    +  [square, doubled]
    +);
    +func(9, 3); // [81, 6]
    +

    pipeAsyncFunctions

    Performs left-to-right function composition for asynchronous functions.

    Use Array.reduce() with the spread operator (...) to perform left-to-right function composition using Promise.then(). The functions can return a combination of: simple values, Promise's, or they can be defined as async ones returning through await. All functions must be unary.

    const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg));
    +
    const sum = pipeAsyncFunctions(
    +  x => x + 1,
    +  x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)),
    +  x => x + 3,
    +  async x => (await x) + 4
    +);
    +(async () => {
    +  console.log(await sum(5)); // 15 (after one second)
    +})();
     

    pipeFunctions

    Performs left-to-right function composition.

    Use Array.reduce() with the spread operator (...) to perform left-to-right function composition. The first (leftmost) function can accept one or more arguments; the remaining functions must be unary.

    const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
     
    const add5 = x => x + 5;
     const multiply = (x, y) => x * y;
    @@ -89,6 +107,20 @@ Object.assig
       );
     
    const delay = promisify((d, cb) => setTimeout(cb, d));
     delay(2000).then(() => console.log('Hi!')); // // Promise resolves after 2s
    +

    rearg

    Creates a function that invokes the provided function with its arguments arranged according to the specified indexes.

    Use Array.reduce() and Array.indexOf() to reorder arguments based on indexes in combination with the spread operator (...) to pass the transformed arguments to fn.

    const rearg = (fn, indexes) => (...args) =>
    +  fn(
    +    ...args.reduce(
    +      (acc, val, i) => ((acc[indexes.indexOf(i)] = val), acc),
    +      Array.from({ length: indexes.length })
    +    )
    +  );
    +
    var rearged = rearg(
    +  function(a, b, c) {
    +    return [a, b, c];
    +  },
    +  [2, 0, 1]
    +);
    +rearged('b', 'c', 'a'); // ['a', 'b', 'c']
     

    spreadOver

    Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.

    Use closures and the spread operator (...) to map the array of arguments to the inputs of the function.

    const spreadOver = fn => argsArr => fn(...argsArr);
     
    const arrayMax = spreadOver(Math.max);
     arrayMax([1, 2, 3]); // 3
    @@ -752,7 +784,18 @@ document.bodypadStart(2, '0')}`;
     };
     
    tomorrow(); // 2017-12-27 (if current date is 2017-12-26)
    -

    Function

    bind

    Creates a function that invokes fn with a given context, optionally adding any additional supplied parameters to the beginning of the arguments.

    Return a function that uses Function.apply() to apply the given context to fn. Use Array.concat() to prepend any additional supplied parameters to the arguments.

    const bind = (fn, context, ...args) =>
    +

    Function

    attempt

    Attempts to invoke a function with the provided arguments, returning either the result or the caught error object.

    Use a try... catch block to return either the result of the function or an appropriate error.

    const attempt = (fn, ...args) => {
    +  try {
    +    return fn(args);
    +  } catch (e) {
    +    return e instanceof Error ? e : new Error(e);
    +  }
    +};
    +
    var elements = attempt(function(selector) {
    +  return document.querySelectorAll(selector);
    +}, '>_>');
    +if (elements instanceof Error) elements = []; // elements = []
    +

    bind

    Creates a function that invokes fn with a given context, optionally adding any additional supplied parameters to the beginning of the arguments.

    Return a function that uses Function.apply() to apply the given context to fn. Use Array.concat() to prepend any additional supplied parameters to the arguments.

    const bind = (fn, context, ...args) =>
       function() {
         return fn.apply(context, args.concat(...arguments));
       };
    @@ -802,6 +845,22 @@ console.log<
       arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);
     
    curry(Math.pow)(2)(10); // 1024
     curry(Math.min, 3)(10)(50)(2); // 2
    +

    debounce

    Creates a debounced function that delays invoking the provided function until after wait milliseconds have elapsed since the last time the debounced function was invoked.

    Use setTimeout() and clearTimeout() to debounce the given method, fn. Use Function.apply() to apply the this context to the function and provide the necessary arguments. Omit the second argument, wait, to set the timeout at a default of 0 ms.

    const debounce = (fn, wait = 0) => {
    +  let inDebounce;
    +  return function() {
    +    const context = this,
    +      args = arguments;
    +    clearTimeout(inDebounce);
    +    inDebounce = setTimeout(() => fn.apply(context, args), wait);
    +  };
    +};
    +
    window.addEventListener(
    +  'resize',
    +  debounce(function(evt) {
    +    console.log(window.innerWidth);
    +    console.log(window.innerHeight);
    +  }, 250)
    +); // Will log the window dimensions at most every 250ms
     

    defer

    Defers invoking a function until the current call stack has cleared.

    Use setTimeout() with a timeout of 1ms to add a new event to the browser event queue and allow the rendering engine to complete its work. Use the spread (...) operator to supply the function with an arbitrary number of arguments.

    const defer = (fn, ...args) => setTimeout(fn, 1, ...args);
     
    // Example A:
     defer(console.log, 'a'), console.log('b'); // logs 'b' then 'a'
    @@ -868,6 +927,33 @@ document.bodyawait sleep(1000);
       console.log('I woke up after 1 second.');
     }
    +

    throttle

    Creates a throttled function that only invokes the provided function at most once per every wait milliseconds

    Use setTimeout() and clearTimeout() to throttle the given method, fn. Use Function.apply() to apply the this context to the function and provide the necessary arguments. Use Date.now() to keep track of the last time the throttled function was invoked. Omit the second argument, wait, to set the timeout at a default of 0 ms.

    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));
    +    }
    +  };
    +};
    +
    window.addEventListener(
    +  'resize',
    +  throttle(function(evt) {
    +    console.log(window.innerWidth);
    +    console.log(window.innerHeight);
    +  }, 250)
    +); // Will log the window dimensions at most every 250ms
     

    times

    Iterates over a callback n times

    Use Function.call() to call fn n times or until it returns false. Omit the last argument, context, to use an undefined object (or the global object in non-strict mode).

    const times = (n, fn, context = undefined) => {
       let i = 0;
       while (fn.call(context, i) !== false && ++i < n) {}
    @@ -1137,12 +1223,14 @@ console.log<
         (c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
       );
     
    UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc'
    -

    Object

    bindAll

    Explain briefly what the snippet does.

    Use Array.forEach() to return a function that uses Function.apply() to apply the given context (obj) to fn for each function specified.

    const bindAll = (obj, ...fns) =>
    +

    Object

    bindAll

    Use Array.forEach() to return a function that uses Function.apply() to apply the given context (obj) to fn for each function specified.

    const bindAll = (obj, ...fns) =>
       fns.forEach(
    -    fn =>
    -      (obj[fn] = function() {
    -        return fn.apply(obj);
    +    fn => (
    +      (f = obj[fn]),
    +      (obj[fn] = function() {
    +        return f.apply(obj);
           })
    +    )
       );
     
    var view = {
       label: 'docs',
    diff --git a/snippets/attempt.md b/snippets/attempt.md
    new file mode 100644
    index 000000000..c3dae169e
    --- /dev/null
    +++ b/snippets/attempt.md
    @@ -0,0 +1,22 @@
    +### attempt
    +
    +Attempts to invoke a function with the provided arguments, returning either the result or the caught error object.
    +
    +Use a `try... catch` block to return either the result of the function or an appropriate error.
    +
    +```js
    +const attempt = (fn, ...args) => {
    +  try {
    +    return fn(args);
    +  } catch (e) {
    +    return e instanceof Error ? e : new Error(e);
    +  }
    +};
    +```
    +
    +```js
    +var elements = attempt(function(selector) {
    +  return document.querySelectorAll(selector);
    +}, '>_>');
    +if (elements instanceof Error) elements = []; // elements = []
    +```
    diff --git a/snippets/bindAll.md b/snippets/bindAll.md
    index e5e618ae0..da869957f 100644
    --- a/snippets/bindAll.md
    +++ b/snippets/bindAll.md
    @@ -1,16 +1,16 @@
     ### bindAll
     
    -Explain briefly what the snippet does.
    -
     Use `Array.forEach()` to return a `function` that uses `Function.apply()` to apply the given context (`obj`) to `fn` for each function specified.
     
     ```js
     const bindAll = (obj, ...fns) =>
       fns.forEach(
    -    fn =>
    +    fn => (
    +      (f = obj[fn]),
           (obj[fn] = function() {
    -        return fn.apply(obj);
    +        return f.apply(obj);
           })
    +    )
       );
     ```
     
    diff --git a/snippets/collectInto.md b/snippets/collectInto.md
    index 3da1173bd..da37626a2 100644
    --- a/snippets/collectInto.md
    +++ b/snippets/collectInto.md
    @@ -13,5 +13,5 @@ const Pall = collectInto(Promise.all.bind(Promise));
     let p1 = Promise.resolve(1);
     let p2 = Promise.resolve(2);
     let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
    -Pall(p1, p2, p3).then(console.log);
    +Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds)
     ```
    diff --git a/snippets/debounce.md b/snippets/debounce.md
    new file mode 100644
    index 000000000..941ab59a3
    --- /dev/null
    +++ b/snippets/debounce.md
    @@ -0,0 +1,29 @@
    +### debounce
    +
    +Creates a debounced function that delays invoking the provided function until after `wait` milliseconds have elapsed since the last time the debounced function was invoked.
    +
    +Use `setTimeout()` and `clearTimeout()` to debounce the given method, `fn`.
    +Use `Function.apply()` to apply the `this` context to the function and provide the necessary `arguments`.
    +Omit the second argument, `wait`, to set the timeout at a default of 0 ms.
    +
    +```js
    +const debounce = (fn, wait = 0) => {
    +  let inDebounce;
    +  return function() {
    +    const context = this,
    +      args = arguments;
    +    clearTimeout(inDebounce);
    +    inDebounce = setTimeout(() => fn.apply(context, args), wait);
    +  };
    +};
    +```
    +
    +```js
    +window.addEventListener(
    +  'resize',
    +  debounce(function(evt) {
    +    console.log(window.innerWidth);
    +    console.log(window.innerHeight);
    +  }, 250)
    +); // Will log the window dimensions at most every 250ms
    +```
    diff --git a/snippets/overArgs.md b/snippets/overArgs.md
    new file mode 100644
    index 000000000..9a913e049
    --- /dev/null
    +++ b/snippets/overArgs.md
    @@ -0,0 +1,19 @@
    +### overArgs
    +
    +Creates a function that invokes the provided function with its arguments transformed.
    +
    +Use `Array.map()` to apply `transforms` to `args` in combination with the spread operator (`...`) to pass the transformed arguments to `fn`.
    +
    +```js
    +const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val)));
    +```
    +
    +```js
    +var func = overArgs(
    +  function(x, y) {
    +    return [x, y];
    +  },
    +  [square, doubled]
    +);
    +func(9, 3); // [81, 6]
    +```
    diff --git a/snippets/pipeAsyncFunctions.md b/snippets/pipeAsyncFunctions.md
    new file mode 100644
    index 000000000..574591cb0
    --- /dev/null
    +++ b/snippets/pipeAsyncFunctions.md
    @@ -0,0 +1,23 @@
    +### pipeAsyncFunctions
    +
    +Performs left-to-right function composition for asynchronous functions.
    +
    +Use `Array.reduce()` with the spread operator (`...`) to perform left-to-right function composition using `Promise.then()`.
    +The functions can return a combination of: simple values, `Promise`'s, or they can be defined as `async` ones returning through `await`.
    +All functions must be unary.
    +
    +```js
    +const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg));
    +```
    +
    +```js
    +const sum = pipeAsyncFunctions(
    +  x => x + 1,
    +  x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)),
    +  x => x + 3,
    +  async x => (await x) + 4
    +);
    +(async () => {
    +  console.log(await sum(5)); // 15 (after one second)
    +})();
    +```
    diff --git a/snippets/rearg.md b/snippets/rearg.md
    new file mode 100644
    index 000000000..f58ea2f58
    --- /dev/null
    +++ b/snippets/rearg.md
    @@ -0,0 +1,25 @@
    +### rearg
    +
    +Creates a function that invokes the provided function with its arguments arranged according to the specified indexes.
    +
    +Use `Array.reduce()` and `Array.indexOf()` to reorder arguments based on `indexes` in combination with the spread operator (`...`) to pass the transformed arguments to `fn`.
    +
    +```js
    +const rearg = (fn, indexes) => (...args) =>
    +  fn(
    +    ...args.reduce(
    +      (acc, val, i) => ((acc[indexes.indexOf(i)] = val), acc),
    +      Array.from({ length: indexes.length })
    +    )
    +  );
    +```
    +
    +```js
    +var rearged = rearg(
    +  function(a, b, c) {
    +    return [a, b, c];
    +  },
    +  [2, 0, 1]
    +);
    +rearged('b', 'c', 'a'); // ['a', 'b', 'c']
    +```
    diff --git a/snippets/throttle.md b/snippets/throttle.md
    new file mode 100644
    index 000000000..5e1d01fd7
    --- /dev/null
    +++ b/snippets/throttle.md
    @@ -0,0 +1,41 @@
    +### throttle
    +
    +Creates a throttled function that only invokes the provided function at most once per every `wait` milliseconds
    +
    +Use `setTimeout()` and `clearTimeout()` to throttle the given method, `fn`.
    +Use `Function.apply()` to apply the `this` context to the function and provide the necessary `arguments`.
    +Use `Date.now()` to keep track of the last time the throttled function was invoked.
    +Omit the second argument, `wait`, to set the timeout at a default of 0 ms.
    +
    +```js
    +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));
    +    }
    +  };
    +};
    +```
    +
    +```js
    +window.addEventListener(
    +  'resize',
    +  throttle(function(evt) {
    +    console.log(window.innerWidth);
    +    console.log(window.innerHeight);
    +  }, 250)
    +); // Will log the window dimensions at most every 250ms
    +```
    diff --git a/tag_database b/tag_database
    index 0f8821946..4a5a0f084 100644
    --- a/tag_database
    +++ b/tag_database
    @@ -2,6 +2,7 @@ anagrams:string,recursion
     arrayToHtmlList:browser,array
     ary:adapter,function
     atob:node,string,utility
    +attempt:function
     average:math,array
     averageBy:math,array,function
     bind:function,object
    @@ -32,6 +33,7 @@ createElement:browser,utility
     createEventHub:browser,event,advanced
     currentURL:browser,url
     curry:function,recursion
    +debounce:function
     decapitalize:string,array
     deepClone:object,recursion
     deepFlatten:array,recursion
    @@ -161,6 +163,7 @@ once:function
     onUserInputChange:browser,event,advanced
     orderBy:object,array
     over:adapter,function
    +overArgs:adapter,function
     palindrome:string
     parseCookie:utility,string
     partial:function
    @@ -169,6 +172,7 @@ partition:array,object,function
     percentile:math
     pick:object,array
     pickBy:object,array,function
    +pipeAsyncFunctions:adapter,function,promise
     pipeFunctions:adapter,function
     pluralize:string
     powerset:math
    @@ -184,6 +188,7 @@ randomIntArrayInRange:math,utility,random
     randomIntegerInRange:math,utility,random
     randomNumberInRange:math,utility,random
     readFileLines:node,array,string
    +rearg:adapter,function
     redirect:browser,url
     reducedFilter:array
     reduceSuccessive:array,function
    @@ -227,6 +232,7 @@ take:array
     takeRight:array
     takeRightWhile:array,function
     takeWhile:array,function
    +throttle:function
     times:function
     timeTaken:utility
     toCamelCase:string,regexp
    diff --git a/test/anagrams/anagrams.test.js b/test/anagrams/anagrams.test.js
    index 4318f4c46..a7987d63f 100644
    --- a/test/anagrams/anagrams.test.js
    +++ b/test/anagrams/anagrams.test.js
    @@ -6,9 +6,11 @@ test('Testing anagrams', (t) => {
       //Please go to https://github.com/substack/tape
       t.true(typeof anagrams === 'function', 'anagrams is a Function');
       t.deepEqual(anagrams('abc'), ['abc','acb','bac','bca','cab','cba'], "Generates all anagrams of a string");
    +  t.deepEqual(anagrams('a'), ['a'], "Works for single-letter strings");
    +  t.deepEqual(anagrams(''), [''], "Works for empty strings");
       //t.deepEqual(anagrams(args..), 'Expected');
       //t.equal(anagrams(args..), 'Expected');
       //t.false(anagrams(args..), 'Expected');
       //t.throws(anagrams(args..), 'Expected');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/ary/ary.test.js b/test/ary/ary.test.js
    index 445b40618..065b18a96 100644
    --- a/test/ary/ary.test.js
    +++ b/test/ary/ary.test.js
    @@ -5,9 +5,11 @@ test('Testing ary', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof ary === 'function', 'ary is a Function');
    +  const firstTwoMax = ary(Math.max, 2);
    +  t.deepEquals([[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)), [6, 8, 10], 'Discards arguments with index >=n')
       //t.deepEqual(ary(args..), 'Expected');
       //t.equal(ary(args..), 'Expected');
       //t.false(ary(args..), 'Expected');
       //t.throws(ary(args..), 'Expected');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/attempt/attempt.js b/test/attempt/attempt.js
    new file mode 100644
    index 000000000..6d079c71e
    --- /dev/null
    +++ b/test/attempt/attempt.js
    @@ -0,0 +1,8 @@
    +const attempt = (fn, ...args) => {
    +try {
    +return fn(args);
    +} catch (e) {
    +return e instanceof Error ? e : new Error(e);
    +}
    +};
    +module.exports = attempt
    \ No newline at end of file
    diff --git a/test/attempt/attempt.test.js b/test/attempt/attempt.test.js
    new file mode 100644
    index 000000000..13ae65686
    --- /dev/null
    +++ b/test/attempt/attempt.test.js
    @@ -0,0 +1,15 @@
    +const test = require('tape');
    +const attempt = require('./attempt.js');
    +
    +test('Testing attempt', (t) => {
    +  //For more information on all the methods supported by tape
    +  //Please go to https://github.com/substack/tape
    +  t.true(typeof attempt === 'function', 'attempt is a Function');
    +  t.equals(attempt(() => 0), 0, 'Returns a value');
    +  t.true(attempt(() => {throw new Error()}) instanceof Error, 'Returns an error');
    +  //t.deepEqual(attempt(args..), 'Expected');
    +  //t.equal(attempt(args..), 'Expected');
    +  //t.false(attempt(args..), 'Expected');
    +  //t.throws(attempt(args..), 'Expected');
    +  t.end();
    +});
    diff --git a/test/bind/bind.test.js b/test/bind/bind.test.js
    index 6ad403682..e3ba1054c 100644
    --- a/test/bind/bind.test.js
    +++ b/test/bind/bind.test.js
    @@ -5,9 +5,15 @@ test('Testing bind', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof bind === 'function', 'bind is a Function');
    +  function greet(greeting, punctuation) {
    +    return greeting + ' ' + this.user + punctuation;
    +  }
    +  const freddy = { user: 'fred' };
    +  const freddyBound = bind(greet, freddy);
    +  t.equals(freddyBound('hi', '!'),'hi fred!', 'Binds to an object context');
       //t.deepEqual(bind(args..), 'Expected');
       //t.equal(bind(args..), 'Expected');
       //t.false(bind(args..), 'Expected');
       //t.throws(bind(args..), 'Expected');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/bindAll/bindAll.js b/test/bindAll/bindAll.js
    index cf66ad583..187778935 100644
    --- a/test/bindAll/bindAll.js
    +++ b/test/bindAll/bindAll.js
    @@ -1,8 +1,10 @@
     const bindAll = (obj, ...fns) =>
     fns.forEach(
    -fn =>
    +fn => (
    +(f = obj[fn]),
     (obj[fn] = function() {
    -return fn.apply(obj);
    +return f.apply(obj);
     })
    +)
     );
     module.exports = bindAll
    \ No newline at end of file
    diff --git a/test/bindAll/bindAll.test.js b/test/bindAll/bindAll.test.js
    index 513eae230..90c9e23a8 100644
    --- a/test/bindAll/bindAll.test.js
    +++ b/test/bindAll/bindAll.test.js
    @@ -5,9 +5,17 @@ test('Testing bindAll', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof bindAll === 'function', 'bindAll is a Function');
    +  var view = {
    +    label: 'docs',
    +    'click': function() {
    +      return 'clicked ' + this.label;
    +    }
    +  }
    +  bindAll(view, 'click');
    +  t.equal(view.click(), 'clicked docs', 'Binds to an object context')
       //t.deepEqual(bindAll(args..), 'Expected');
       //t.equal(bindAll(args..), 'Expected');
       //t.false(bindAll(args..), 'Expected');
       //t.throws(bindAll(args..), 'Expected');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/bindKey/bindKey.test.js b/test/bindKey/bindKey.test.js
    index 36619ebcd..2aed1fb1e 100644
    --- a/test/bindKey/bindKey.test.js
    +++ b/test/bindKey/bindKey.test.js
    @@ -5,9 +5,17 @@ test('Testing bindKey', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof bindKey === 'function', 'bindKey is a Function');
    +  const freddy = {
    +    user: 'fred',
    +    greet: function(greeting, punctuation) {
    +      return greeting + ' ' + this.user + punctuation;
    +    }
    +  };
    +  const freddyBound = bindKey(freddy, 'greet');
    +  t.equal(freddyBound('hi', '!'), 'hi fred!', 'Binds function to an object context');
       //t.deepEqual(bindKey(args..), 'Expected');
       //t.equal(bindKey(args..), 'Expected');
       //t.false(bindKey(args..), 'Expected');
       //t.throws(bindKey(args..), 'Expected');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/byteSize/byteSize.test.js b/test/byteSize/byteSize.test.js
    index 32718fada..b79b83889 100644
    --- a/test/byteSize/byteSize.test.js
    +++ b/test/byteSize/byteSize.test.js
    @@ -5,6 +5,9 @@ test('Testing byteSize', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof byteSize === 'function', 'byteSize is a Function');
    +  // Blob is not part of Node apparently?
    +  //t.equal(byteSize('Hello World'), 11, 'Works for text');
    +  //t.equal(byteSize('😀'), 4, 'Works for emojis');
       // Works only in browser
       // t.equal(byteSize('Hello World'), 11, "Returns the length of a string in bytes");
       //t.deepEqual(byteSize(args..), 'Expected');
    @@ -12,4 +15,4 @@ test('Testing byteSize', (t) => {
       //t.false(byteSize(args..), 'Expected');
       //t.throws(byteSize(args..), 'Expected');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/collectInto/collectInto.test.js b/test/collectInto/collectInto.test.js
    index a3d303e5a..557134336 100644
    --- a/test/collectInto/collectInto.test.js
    +++ b/test/collectInto/collectInto.test.js
    @@ -5,9 +5,14 @@ test('Testing collectInto', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof collectInto === 'function', 'collectInto is a Function');
    +  const Pall = collectInto(Promise.all.bind(Promise));
    +  let p1 = Promise.resolve(1);
    +  let p2 = Promise.resolve(2);
    +  let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
    +  Pall(p1, p2, p3).then(function(val){ t.deepEqual(val, [1,2,3], 'Works with multiple promises')}, function(reason){});
       //t.deepEqual(collectInto(args..), 'Expected');
       //t.equal(collectInto(args..), 'Expected');
       //t.false(collectInto(args..), 'Expected');
       //t.throws(collectInto(args..), 'Expected');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/countBy/countBy.test.js b/test/countBy/countBy.test.js
    index ea6c3b748..94296d017 100644
    --- a/test/countBy/countBy.test.js
    +++ b/test/countBy/countBy.test.js
    @@ -5,9 +5,11 @@ test('Testing countBy', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof countBy === 'function', 'countBy is a Function');
    +  t.deepEqual(countBy([6.1, 4.2, 6.3], Math.floor), {4: 1, 6: 2}, 'Works for functions');
    +  t.deepEqual(countBy(['one', 'two', 'three'], 'length'), {3: 2, 5: 1}, 'Works for property names');
       //t.deepEqual(countBy(args..), 'Expected');
       //t.equal(countBy(args..), 'Expected');
       //t.false(countBy(args..), 'Expected');
       //t.throws(countBy(args..), 'Expected');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/debounce/debounce.js b/test/debounce/debounce.js
    new file mode 100644
    index 000000000..430bfeaed
    --- /dev/null
    +++ b/test/debounce/debounce.js
    @@ -0,0 +1,10 @@
    +const debounce = (fn, wait = 0) => {
    +let inDebounce;
    +return function() {
    +const context = this,
    +args = arguments;
    +clearTimeout(inDebounce);
    +inDebounce = setTimeout(() => fn.apply(context, args), wait);
    +};
    +};
    +module.exports = debounce
    \ No newline at end of file
    diff --git a/test/debounce/debounce.test.js b/test/debounce/debounce.test.js
    new file mode 100644
    index 000000000..f1a35323c
    --- /dev/null
    +++ b/test/debounce/debounce.test.js
    @@ -0,0 +1,13 @@
    +const test = require('tape');
    +const debounce = require('./debounce.js');
    +
    +test('Testing debounce', (t) => {
    +  //For more information on all the methods supported by tape
    +  //Please go to https://github.com/substack/tape
    +  t.true(typeof debounce === 'function', 'debounce is a Function');
    +  //t.deepEqual(debounce(args..), 'Expected');
    +  //t.equal(debounce(args..), 'Expected');
    +  //t.false(debounce(args..), 'Expected');
    +  //t.throws(debounce(args..), 'Expected');
    +  t.end();
    +});
    \ No newline at end of file
    diff --git a/test/decapitalize/decapitalize.test.js b/test/decapitalize/decapitalize.test.js
    index c18264447..83bf6b32a 100644
    --- a/test/decapitalize/decapitalize.test.js
    +++ b/test/decapitalize/decapitalize.test.js
    @@ -5,9 +5,11 @@ test('Testing decapitalize', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof decapitalize === 'function', 'decapitalize is a Function');
    +  t.equal(decapitalize('FooBar'), 'fooBar', 'Works with default parameter');
    +  t.equal(decapitalize('FooBar', true), 'fOOBAR', 'Works with second parameter set to true');
       //t.deepEqual(decapitalize(args..), 'Expected');
       //t.equal(decapitalize(args..), 'Expected');
       //t.false(decapitalize(args..), 'Expected');
       //t.throws(decapitalize(args..), 'Expected');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/dropWhile/dropWhile.test.js b/test/dropWhile/dropWhile.test.js
    index 6e0ecf54e..198d8202a 100644
    --- a/test/dropWhile/dropWhile.test.js
    +++ b/test/dropWhile/dropWhile.test.js
    @@ -10,4 +10,4 @@ test('Testing dropWhile', (t) => {
       //t.false(dropWhile(args..), 'Expected');
       //t.throws(dropWhile(args..), 'Expected');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/overArgs/overArgs.js b/test/overArgs/overArgs.js
    new file mode 100644
    index 000000000..41250eb89
    --- /dev/null
    +++ b/test/overArgs/overArgs.js
    @@ -0,0 +1,2 @@
    +const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val)));
    +module.exports = overArgs
    \ No newline at end of file
    diff --git a/test/overArgs/overArgs.test.js b/test/overArgs/overArgs.test.js
    new file mode 100644
    index 000000000..81c194c90
    --- /dev/null
    +++ b/test/overArgs/overArgs.test.js
    @@ -0,0 +1,13 @@
    +const test = require('tape');
    +const overArgs = require('./overArgs.js');
    +
    +test('Testing overArgs', (t) => {
    +  //For more information on all the methods supported by tape
    +  //Please go to https://github.com/substack/tape
    +  t.true(typeof overArgs === 'function', 'overArgs is a Function');
    +  //t.deepEqual(overArgs(args..), 'Expected');
    +  //t.equal(overArgs(args..), 'Expected');
    +  //t.false(overArgs(args..), 'Expected');
    +  //t.throws(overArgs(args..), 'Expected');
    +  t.end();
    +});
    \ No newline at end of file
    diff --git a/test/pipeAsyncFunctions/pipeAsyncFunctions.js b/test/pipeAsyncFunctions/pipeAsyncFunctions.js
    new file mode 100644
    index 000000000..09091affc
    --- /dev/null
    +++ b/test/pipeAsyncFunctions/pipeAsyncFunctions.js
    @@ -0,0 +1,2 @@
    +const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg));
    +module.exports = pipeAsyncFunctions
    \ No newline at end of file
    diff --git a/test/pipeAsyncFunctions/pipeAsyncFunctions.test.js b/test/pipeAsyncFunctions/pipeAsyncFunctions.test.js
    new file mode 100644
    index 000000000..7a4ae346e
    --- /dev/null
    +++ b/test/pipeAsyncFunctions/pipeAsyncFunctions.test.js
    @@ -0,0 +1,24 @@
    +const test = require('tape');
    +const pipeAsyncFunctions = require('./pipeAsyncFunctions.js');
    +
    +test('Testing pipeAsyncFunctions', async (t) => {
    +  //For more information on all the methods supported by tape
    +  //Please go to https://github.com/substack/tape
    +  t.true(typeof pipeAsyncFunctions === 'function', 'pipeAsyncFunctions is a Function');
    +  //t.deepEqual(pipeAsyncFunctions(args..), 'Expected');
    +  //t.equal(pipeAsyncFunctions(args..), 'Expected');
    +  //t.false(pipeAsyncFunctions(args..), 'Expected');
    +  //t.throws(pipeAsyncFunctions(args..), 'Expected');
    +  t.equal(
    +    await pipeAsyncFunctions(
    +      (x) => x + 1,
    +      (x) => new Promise((resolve) => setTimeout(() => resolve(x + 2), 0)),
    +      (x) => x + 3,
    +      async (x) => await x + 4,
    +    )
    +    (5),
    +    15,
    +    'pipeAsyncFunctions result should be 15'
    +  );
    +  t.end();
    +});
    \ No newline at end of file
    diff --git a/test/rearg/rearg.js b/test/rearg/rearg.js
    new file mode 100644
    index 000000000..b2f97244c
    --- /dev/null
    +++ b/test/rearg/rearg.js
    @@ -0,0 +1,8 @@
    +const rearg = (fn, indexes) => (...args) =>
    +fn(
    +...args.reduce(
    +(acc, val, i) => ((acc[indexes.indexOf(i)] = val), acc),
    +Array.from({ length: indexes.length })
    +)
    +);
    +module.exports = rearg
    \ No newline at end of file
    diff --git a/test/rearg/rearg.test.js b/test/rearg/rearg.test.js
    new file mode 100644
    index 000000000..9139d3f64
    --- /dev/null
    +++ b/test/rearg/rearg.test.js
    @@ -0,0 +1,13 @@
    +const test = require('tape');
    +const rearg = require('./rearg.js');
    +
    +test('Testing rearg', (t) => {
    +  //For more information on all the methods supported by tape
    +  //Please go to https://github.com/substack/tape
    +  t.true(typeof rearg === 'function', 'rearg is a Function');
    +  //t.deepEqual(rearg(args..), 'Expected');
    +  //t.equal(rearg(args..), 'Expected');
    +  //t.false(rearg(args..), 'Expected');
    +  //t.throws(rearg(args..), 'Expected');
    +  t.end();
    +});
    \ No newline at end of file
    diff --git a/test/round/round.test.js b/test/round/round.test.js
    index 7af718c04..2aa705899 100644
    --- a/test/round/round.test.js
    +++ b/test/round/round.test.js
    @@ -5,9 +5,19 @@ test('Testing round', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof round === 'function', 'round is a Function');
    -  t.equal(round(1.005, 2), 1.01, "Rounds a number to a specified amount of digits.");
    -  //t.equal(round(args..), 'Expected');
    -  //t.false(round(args..), 'Expected');
    -  //t.throws(round(args..), 'Expected');
    +  t.equal(round(1.005, 2), 1.01, "round(1.005, 2) returns 1.01");
    +  t.equal(round(123.3423345345345345344, 11), 123.34233453453, "round(123.3423345345345345344, 11) returns 123.34233453453");
    +  t.equal(round(3.342, 11), 3.342, "round(3.342, 11) returns 3.342");
    +  t.equal(round(1.005), 1, "round(1.005) returns 1");
    +  t.true(isNaN(round([1.005, 2])), 'round([1.005, 2]) returns NaN');
    +  t.true(isNaN(round('string')), 'round(string) returns NaN');
    +  t.true(isNaN(round()), 'round() returns NaN');
    +  t.true(isNaN(round(132, 413, 4134)), 'round(132, 413, 4134) returns NaN');
    +  t.true(isNaN(round({a: 132}, 413)), 'round({a: 132}, 413) returns NaN');
    +
    +  let start = new Date().getTime();
    +  round(123.3423345345345345344, 11);
    +  let end = new Date().getTime();
    +  t.true((end - start) < 2000, 'round(123.3423345345345345344, 11) takes less than 2s to run');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/throttle/throttle.js b/test/throttle/throttle.js
    new file mode 100644
    index 000000000..b26b6b74b
    --- /dev/null
    +++ b/test/throttle/throttle.js
    @@ -0,0 +1,21 @@
    +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));
    +}
    +};
    +};
    +module.exports = throttle
    \ No newline at end of file
    diff --git a/test/throttle/throttle.test.js b/test/throttle/throttle.test.js
    new file mode 100644
    index 000000000..4de75afdb
    --- /dev/null
    +++ b/test/throttle/throttle.test.js
    @@ -0,0 +1,13 @@
    +const test = require('tape');
    +const throttle = require('./throttle.js');
    +
    +test('Testing throttle', (t) => {
    +  //For more information on all the methods supported by tape
    +  //Please go to https://github.com/substack/tape
    +  t.true(typeof throttle === 'function', 'throttle is a Function');
    +  //t.deepEqual(throttle(args..), 'Expected');
    +  //t.equal(throttle(args..), 'Expected');
    +  //t.false(throttle(args..), 'Expected');
    +  //t.throws(throttle(args..), 'Expected');
    +  t.end();
    +});
    \ No newline at end of file
    diff --git a/test/toCamelCase/toCamelCase.test.js b/test/toCamelCase/toCamelCase.test.js
    index b41794011..0f3efc557 100644
    --- a/test/toCamelCase/toCamelCase.test.js
    +++ b/test/toCamelCase/toCamelCase.test.js
    @@ -5,13 +5,18 @@ test('Testing toCamelCase', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof toCamelCase === 'function', 'toCamelCase is a Function');
    -  t.equal(toCamelCase('some_database_field_name'), 'someDatabaseFieldName', "Converts a string to camelCase");
    -  t.equal(toCamelCase('Some label that needs to be camelized'), 'someLabelThatNeedsToBeCamelized', "Converts a string to camelCase");
    -  t.equal(toCamelCase('some-javascript-property'), 'someJavascriptProperty', "Converts a string to camelCase");
    -  t.equal(toCamelCase('some-mixed_string with spaces_underscores-and-hyphens'), 'someMixedStringWithSpacesUnderscoresAndHyphens', "Converts a string to camelCase");
    -  //t.deepEqual(toCamelCase(args..), 'Expected');
    -  //t.equal(toCamelCase(args..), 'Expected');
    -  //t.false(toCamelCase(args..), 'Expected');
    -  //t.throws(toCamelCase(args..), 'Expected');
    +  t.equal(toCamelCase('some_database_field_name'), 'someDatabaseFieldName', "toCamelCase('some_database_field_name') returns someDatabaseFieldName");
    +  t.equal(toCamelCase('Some label that needs to be camelized'), 'someLabelThatNeedsToBeCamelized', "toCamelCase('Some label that needs to be camelized') returns someLabelThatNeedsToBeCamelized");
    +  t.equal(toCamelCase('some-javascript-property'), 'someJavascriptProperty', "toCamelCase('some-javascript-property') return someJavascriptProperty");
    +  t.equal(toCamelCase('some-mixed_string with spaces_underscores-and-hyphens'), 'someMixedStringWithSpacesUnderscoresAndHyphens', "toCamelCase('some-mixed_string with spaces_underscores-and-hyphens') returns someMixedStringWithSpacesUnderscoresAndHyphens");
    +  t.throws(() => toCamelCase(), 'toCamelCase() throws a error');
    +  t.throws(() => toCamelCase([]), 'toCamelCase([]) throws a error');
    +  t.throws(() => toCamelCase({}), 'toCamelCase({}) throws a error');
    +  t.throws(() => toCamelCase(123), 'toCamelCase(123) throws a error');
    +
    +  let start = new Date().getTime();
    +  toCamelCase('some-mixed_string with spaces_underscores-and-hyphens');
    +  let end = new Date().getTime();
    +  t.true((end - start) < 2000, 'toCamelCase(some-mixed_string with spaces_underscores-and-hyphens) takes less than 2s to run');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/toKebabCase/toKebabCase.test.js b/test/toKebabCase/toKebabCase.test.js
    index fe305e2b2..e2dfd8891 100644
    --- a/test/toKebabCase/toKebabCase.test.js
    +++ b/test/toKebabCase/toKebabCase.test.js
    @@ -5,13 +5,18 @@ test('Testing toKebabCase', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof toKebabCase === 'function', 'toKebabCase is a Function');
    -  t.equal(toKebabCase('camelCase'), 'camel-case', "string converts to snake case");
    -  t.equal(toKebabCase('some text'), 'some-text', "string converts to snake case");
    -  t.equal(toKebabCase('some-mixed-string With spaces-underscores-and-hyphens'), 'some-mixed-string-with-spaces-underscores-and-hyphens', "string converts to snake case");
    -  t.equal(toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'), 'i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html', "string converts to snake case");
    -  //t.deepEqual(toKebabCase(args..), 'Expected');
    -  //t.equal(toKebabCase(args..), 'Expected');
    -  //t.false(toKebabCase(args..), 'Expected');
    -  //t.throws(toKebabCase(args..), 'Expected');
    +  t.equal(toKebabCase('camelCase'), 'camel-case', "toKebabCase('camelCase') returns camel-case");
    +  t.equal(toKebabCase('some text'), 'some-text', "toKebabCase('some text') returns some-text");
    +  t.equal(toKebabCase('some-mixed-string With spaces-underscores-and-hyphens'), 'some-mixed-string-with-spaces-underscores-and-hyphens', "toKebabCase('some-mixed-string With spaces-underscores-and-hyphens') returns some-mixed-string-with-spaces-underscores-and-hyphens");
    +  t.equal(toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'), 'i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html', "toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html");
    +  t.equal(toKebabCase(), undefined, 'toKebabCase() return undefined');
    +  t.throws(() => toKebabCase([]), 'toKebabCase([]) throws an error');
    +  t.throws(() => toKebabCase({}), 'toKebabCase({}) throws an error');
    +  t.throws(() => toKebabCase(123), 'toKebabCase(123) throws an error');
    +
    +  let start = new Date().getTime();
    +  toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML')
    +  let end = new Date().getTime();
    +  t.true((end - start) < 2000, 'toKebabCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/toSafeInteger/toSafeInteger.test.js b/test/toSafeInteger/toSafeInteger.test.js
    index 508da718a..885f6e324 100644
    --- a/test/toSafeInteger/toSafeInteger.test.js
    +++ b/test/toSafeInteger/toSafeInteger.test.js
    @@ -5,14 +5,20 @@ test('Testing toSafeInteger', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof toSafeInteger === 'function', 'toSafeInteger is a Function');
    +  t.true(Number(toSafeInteger(3.2)), 'Number(toSafeInteger(3.2)) is a number');
       t.equal(toSafeInteger(3.2), 3, "Converts a value to a safe integer");
    -  t.equal(toSafeInteger('4.2'), 4, "Converts a value to a safe integer");
    -  t.equal(toSafeInteger(4.6), 5, "Converts a value to a safe integer");
    -  t.equal(toSafeInteger(1.5), 2, "Converts a value to a safe integer");
    -  t.equal(toSafeInteger(Infinity), 9007199254740991, "Converts a value to a safe integer");
    -  //t.deepEqual(toSafeInteger(args..), 'Expected');
    -  //t.equal(toSafeInteger(args..), 'Expected');
    -  //t.false(toSafeInteger(args..), 'Expected');
    -  //t.throws(toSafeInteger(args..), 'Expected');
    +  t.equal(toSafeInteger('4.2'), 4, "toSafeInteger('4.2') returns 4");
    +  t.equal(toSafeInteger(4.6), 5, "toSafeInteger(4.6) returns 5");
    +  t.equal(toSafeInteger([]), 0, "toSafeInteger([]) returns 0");
    +  t.true(isNaN(toSafeInteger([1.5, 3124])), "isNaN(toSafeInteger([1.5, 3124])) is true");
    +  t.true(isNaN(toSafeInteger('string')), "isNaN(toSafeInteger('string')) is true");
    +  t.true(isNaN(toSafeInteger({})), "isNaN(toSafeInteger({})) is true");
    +  t.true(isNaN(toSafeInteger()), "isNaN(toSafeInteger()) is true");
    +  t.equal(toSafeInteger(Infinity), 9007199254740991, "toSafeInteger(Infinity) returns 9007199254740991");
    +
    +  let start = new Date().getTime();
    +  toSafeInteger(3.2);
    +  let end = new Date().getTime();
    +  t.true((end - start) < 2000, 'toSafeInteger(3.2) takes less than 2s to run');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/toSnakeCase/toSnakeCase.test.js b/test/toSnakeCase/toSnakeCase.test.js
    index 14bed623d..72190fda2 100644
    --- a/test/toSnakeCase/toSnakeCase.test.js
    +++ b/test/toSnakeCase/toSnakeCase.test.js
    @@ -5,14 +5,18 @@ test('Testing toSnakeCase', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof toSnakeCase === 'function', 'toSnakeCase is a Function');
    -  t.equal(toSnakeCase('camelCase'), 'camel_case', "string converts to snake case");
    -  t.equal(toSnakeCase('some text'), 'some_text', "string converts to snake case");
    -  t.equal(toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens'), 'some_mixed_string_with_spaces_underscores_and_hyphens', "string converts to snake case");
    -  t.equal(toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'), 'i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html', "string converts to snake case");
    +  t.equal(toSnakeCase('camelCase'), 'camel_case', "toSnakeCase('camelCase') returns camel_case");
    +  t.equal(toSnakeCase('some text'), 'some_text', "toSnakeCase('some text') returns some_text");
    +  t.equal(toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens'), 'some_mixed_string_with_spaces_underscores_and_hyphens', "toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens') returns some_mixed_string_with_spaces_underscores_and_hyphens");
    +  t.equal(toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'), 'i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html', "toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html");
    +  t.equal(toSnakeCase(), undefined, 'toSnakeCase() returns undefined');
    +  t.throws(() => toSnakeCase([]), 'toSnakeCase([]) throws an error');
    +  t.throws(() => toSnakeCase({}), 'toSnakeCase({}) throws an error');
    +  t.throws(() => toSnakeCase(123), 'toSnakeCase(123) throws an error');
     
    -  //t.deepEqual(toSnakeCase(args..), 'Expected');
    -  //t.equal(toSnakeCase(args..), 'Expected');
    -  //t.false(toSnakeCase(args..), 'Expected');
    -  //t.throws(toSnakeCase(args..), 'Expected');
    +  let start = new Date().getTime();
    +  toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML');
    +  let end = new Date().getTime();
    +  t.true((end - start) < 2000, 'toSnakeCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/union/union.test.js b/test/union/union.test.js
    index 73427934a..fd6157918 100644
    --- a/test/union/union.test.js
    +++ b/test/union/union.test.js
    @@ -5,10 +5,20 @@ test('Testing union', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof union === 'function', 'union is a Function');
    -  t.deepEqual(union([1, 2, 3], [4, 3, 2]), [1, 2, 3, 4], "Returns every element that exists in any of the two arrays once");
    -  //t.deepEqual(union(args..), 'Expected');
    -  //t.equal(union(args..), 'Expected');
    -  //t.false(union(args..), 'Expected');
    -  //t.throws(union(args..), 'Expected');
    +  t.deepEqual(union([1, 2, 3], [4, 3, 2]), [1, 2, 3, 4], "union([1, 2, 3], [4, 3, 2]) returns [1, 2, 3, 4]");
    +  t.deepEqual(union('str', 'asd'), [ 's', 't', 'r', 'a', 'd' ], "union('str', 'asd') returns [ 's', 't', 'r', 'a', 'd' ]");
    +  t.deepEqual(union([[], {}], [1, 2, 3]), [[], {}, 1, 2, 3], "union([[], {}], [1, 2, 3]) returns [[], {}, 1, 2, 3]");
    +  t.deepEqual(union([], []), [], "union([], []) returns []");
    +  t.throws(() => union(), 'union() throws an error');
    +  t.throws(() => union(true, 'str'), 'union(true, str) throws an error');
    +  t.throws(() => union('false', true), 'union(false, true) throws an error');
    +  t.throws(() => union(123, {}), 'union(123, {}) throws an error');
    +  t.throws(() => union([], {}), 'union([], {}) throws an error');
    +  t.throws(() => union(undefined, null), 'union(undefined, null) throws an error');
    +
    +  let start = new Date().getTime();
    +  union([1, 2, 3], [4, 3, 2]);
    +  let end = new Date().getTime();
    +  t.true((end - start) < 2000, 'union([1, 2, 3], [4, 3, 2]) takes less than 2s to run');
       t.end();
    -});
    \ No newline at end of file
    +});
    diff --git a/test/uniqueElements/uniqueElements.test.js b/test/uniqueElements/uniqueElements.test.js
    index 38d55aea5..137f791dc 100644
    --- a/test/uniqueElements/uniqueElements.test.js
    +++ b/test/uniqueElements/uniqueElements.test.js
    @@ -5,10 +5,24 @@ test('Testing uniqueElements', (t) => {
       //For more information on all the methods supported by tape
       //Please go to https://github.com/substack/tape
       t.true(typeof uniqueElements === 'function', 'uniqueElements is a Function');
    -  t.deepEqual(uniqueElements([1, 2, 2, 3, 4, 4, 5]), [1,2,3,4,5], "Returns all unique values of an array");
    -  //t.deepEqual(uniqueElements(args..), 'Expected');
    -  //t.equal(uniqueElements(args..), 'Expected');
    -  //t.false(uniqueElements(args..), 'Expected');
    -  //t.throws(uniqueElements(args..), 'Expected');
    +  t.deepEqual(uniqueElements([1, 2, 2, 3, 4, 4, 5]), [1,2,3,4,5], "uniqueElements([1, 2, 2, 3, 4, 4, 5]) returns [1,2,3,4,5]");
    +  t.deepEqual(uniqueElements([1, 23, 53]), [1, 23, 53], "uniqueElements([1, 23, 53]) returns [1, 23, 53]");
    +  t.deepEqual(uniqueElements([true, 0, 1, false, false, undefined, null, '']), [true, 0, 1, false, undefined, null, ''], "uniqueElements([true, 0, 1, false, false, undefined, null, '']) returns [true, 0, 1, false, false, undefined, null, '']");
    +  t.deepEqual(uniqueElements(), [], "uniqueElements() returns []");
    +  t.deepEqual(uniqueElements(null), [], "uniqueElements(null) returns []");
    +  t.deepEqual(uniqueElements(undefined), [], "uniqueElements(undefined) returns []");
    +  t.deepEqual(uniqueElements('strt'), ['s', 't', 'r'], "uniqueElements('strt') returns ['s', 't', 'r']");
    +  t.throws(() => uniqueElements(1, 1, 2543, 534, 5), 'uniqueElements(1, 1, 2543, 534, 5) throws an error');
    +  t.throws(() => uniqueElements({}), 'uniqueElements({}) throws an error');
    +  t.throws(() => uniqueElements(true), 'uniqueElements(true) throws an error');
    +  t.throws(() => uniqueElements(false), 'uniqueElements(false) throws an error');
    +
    +  let start = new Date().getTime();
    +  uniqueElements([true, 0, 1, false, false, undefined, null, ''])
    +  let end = new Date().getTime();
    +  t.true((end - start) < 2000, 'uniqueElements([true, 0, 1, false, false, undefined, null]) takes less than 2s to run');
    +
       t.end();
    -});
    \ No newline at end of file
    +});
    +
    +uniqueElements([1, 2, 2, '1', 4, 4, 4, 5, true]); // [1,2,3,4,5]