diff --git a/.gitignore b/.gitignore index d6b1b7f9c..a7eb01438 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ currentSnippet\.js .idea test.sh /*.log + +dist/flavor\.min\.css + +dist/flavor\.css diff --git a/README.md b/README.md index bddfc47cd..b1295b78d 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,7 @@ average(1, 2, 3); * [`none`](#none) * [`nthElement`](#nthelement) * [`partition`](#partition) +* [`permutations`](#permutations) * [`pull`](#pull) * [`pullAtIndex`](#pullatindex) * [`pullAtValue`](#pullatvalue) @@ -343,6 +344,7 @@ average(1, 2, 3); * [`matches`](#matches) * [`matchesWith`](#matcheswith) * [`merge`](#merge) +* [`nest`](#nest) * [`objectFromPairs`](#objectfrompairs) * [`objectToPairs`](#objecttopairs) * [`omit`](#omit) @@ -363,7 +365,6 @@ average(1, 2, 3);
View contents -* [`anagrams`](#anagrams) * [`byteSize`](#bytesize) * [`capitalize`](#capitalize) * [`capitalizeEveryWord`](#capitalizeeveryword) @@ -372,15 +373,18 @@ average(1, 2, 3); * [`escapeRegExp`](#escaperegexp) * [`fromCamelCase`](#fromcamelcase) * [`isAbsoluteURL`](#isabsoluteurl) +* [`isAnagram`](#isanagram) * [`isLowerCase`](#islowercase) * [`isUpperCase`](#isuppercase) * [`mask`](#mask) +* [`pad`](#pad) * [`palindrome`](#palindrome) * [`pluralize`](#pluralize) * [`removeNonASCII`](#removenonascii) * [`reverseString`](#reversestring) * [`sortCharactersInString`](#sortcharactersinstring) * [`splitLines`](#splitlines) +* [`stringPermutations`](#stringpermutations) * [`stripHTMLTags`](#striphtmltags) * [`toCamelCase`](#tocamelcase) * [`toKebabCase`](#tokebabcase) @@ -1851,6 +1855,42 @@ partition(users, o => o.active); // [[{ 'user': 'fred', 'age': 40, 'active':
[⬆ Back to top](#table-of-contents) +### permutations + +⚠️ **WARNING**: This function's execution time increases exponentially with each array element. Anything more than 8 to 10 entries will cause your browser to hang as it tries to solve all the different combinations. + +Generates all permutations of an array's elements (contains duplicates). + +Use recursion. +For each element in the given array, create all the partial permutations for the rest of its elements. +Use `Array.map()` to combine the element with each partial permutation, then `Array.reduce()` to combine all permutations in one array. +Base cases are for array `length` equal to `2` or `1`. + +```js +const permutations = arr => { + if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr; + return arr.reduce( + (acc, item, i) => + acc.concat( + permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val => [item, ...val]) + ), + [] + ); +}; +``` + +
+Examples + +```js +permutations([1, 33, 5]); // [ [ 1, 33, 5 ], [ 1, 5, 33 ], [ 33, 1, 5 ], [ 33, 5, 1 ], [ 5, 1, 33 ], [ 5, 33, 1 ] ] +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### pull Mutates the original array to filter out the values specified. @@ -2272,16 +2312,12 @@ sortedIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x); // 0 Returns the highest index at which value should be inserted into array in order to maintain its sort order. Check if the array is sorted in descending order (loosely). -Use `Array.map()` to map each element to an array with its index and value. Use `Array.reverse()` and `Array.findIndex()` to find the appropriate last index where the element should be inserted. ```js const sortedLastIndex = (arr, n) => { const isDescending = arr[0] > arr[arr.length - 1]; - const index = arr - .map((val, i) => [i, val]) - .reverse() - .findIndex(el => (isDescending ? n <= el[1] : n >= el[1])); + const index = arr.reverse().findIndex(el => (isDescending ? n <= el : n >= el)); return index === -1 ? 0 : arr.length - index - 1; }; ``` @@ -2303,16 +2339,17 @@ sortedLastIndex([10, 20, 30, 30, 40], 30); // 3 Returns the highest index at which value should be inserted into array in order to maintain its sort order, based on a provided iterator function. Check if the array is sorted in descending order (loosely). -Use `Array.reverse()` and `Array.findIndex()` to find the appropriate last index where the element should be inserted, based on the iterator function `fn`.. +Use `Array.map()` to apply the iterator function to all elements of the array. +Use `Array.reverse()` and `Array.findIndex()` to find the appropriate last index where the element should be inserted, based on the provided iterator function. ```js const sortedLastIndexBy = (arr, n, fn) => { const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]); const val = fn(n); const index = arr - .map((val, i) => [i, fn(val)]) + .map(fn) .reverse() - .findIndex(el => (isDescending ? val <= el[1] : val >= el[1])); + .findIndex(el => (isDescending ? val <= el : val >= el)); return index === -1 ? 0 : arr.length - index; }; ``` @@ -3722,12 +3759,13 @@ Results in a string representation of tomorrow's date. Use `new Date()` to get today's date, adding one day using `Date.getDate()` and `Date.setDate()`, and converting the Date object to a string. ```js -const tomorrow = () => { +const tomorrow = (long = false) => { let t = new Date(); t.setDate(t.getDate() + 1); - return `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String( + const ret = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String( t.getDate() ).padStart(2, '0')}`; + return !long ? ret : `${ret}T00:00:00`; }; ``` @@ -3736,6 +3774,7 @@ const tomorrow = () => { ```js tomorrow(); // 2017-12-27 (if current date is 2017-12-26) +tomorrow(true); // 2017-12-27T00:00:00 (if current date is 2017-12-26) ```
@@ -6221,6 +6260,44 @@ merge(object, other); // { a: [ { x: 2 }, { y: 4 }, { z: 3 } ], b: [ 1, 2, 3 ],
[⬆ Back to top](#table-of-contents) +### nest + +Given a flat array of objects linked to one another, it will nest them recursively. +Useful for nesting comments, such as the ones on reddit.com. + +Use recursion. +Use `Array.filter()` to filter the items where the `id` matches the `link`, then `Array.map()` to map each one to a new object that has a `children` property which recursively nests the items based on which ones are children of the current item. +Omit the second argument, `id`, to default to `null` which indicates the object is not linked to another one (i.e. it is a top level object). +Omit the third argument, `link`, to use `'parent_id'` as the default property which links the object to another one by its `id`. + +```js +const nest = (items, id = null, link = 'parent_id') => + items + .filter(item => item[link] === id) + .map(item => ({ ...item, children: nest(items, item.id) })); +``` + +
+Examples + +```js +// One top level comment +const comments = [ + { id: 1, parent_id: null }, + { id: 2, parent_id: 1 }, + { id: 3, parent_id: 1 }, + { id: 4, parent_id: 2 }, + { id: 5, parent_id: 4 } +]; +const nestedComments = nest(comments); // [{ id: 1, parent_id: null, children: [...] }] +``` + + +
+ +
[⬆ Back to top](#table-of-contents) + + ### objectFromPairs Creates an object from the given key-value pairs. @@ -6549,42 +6626,6 @@ unflattenObject({ 'a.b.c': 1, d: 1 }); // { a: { b: { c: 1 } }, d: 1 } --- ## 📜 String -### anagrams - -⚠️ **WARNING**: This function's execution time increases exponentially with each character. Anything more than 8 to 10 characters will cause your browser to hang as it tries to solve all the different combinations. - -Generates all anagrams of a string (contains duplicates). - -Use recursion. -For each letter in the given string, create all the partial anagrams for the rest of its letters. -Use `Array.map()` to combine the letter with each partial anagram, then `Array.reduce()` to combine all anagrams in one array. -Base cases are for string `length` equal to `2` or `1`. - -```js -const anagrams = str => { - if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str]; - return str - .split('') - .reduce( - (acc, letter, i) => - acc.concat(anagrams(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)), - [] - ); -}; -``` - -
-Examples - -```js -anagrams('abc'); // ['abc','acb','bac','bca','cab','cba'] -``` - -
- -
[⬆ Back to top](#table-of-contents) - - ### byteSize Returns the length of a string in bytes. @@ -6788,6 +6829,37 @@ isAbsoluteURL('/foo/bar'); // false
[⬆ Back to top](#table-of-contents) +### isAnagram + +Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters). + +Use `String.toLowerCase()`, `String.replace()` with an appropriate regular expression to remove unnecessary characters, `String.split('')`, `Array.sort()` and `Array.join('')` on both strings to normalize them, then check if their normalized forms are equal. + +```js +const isAnagram = (str1, str2) => { + const normalize = str => + str + .toLowerCase() + .replace(/[^a-z0-9]/gi, '') + .split('') + .sort() + .join(''); + return normalize(str1) === normalize(str2); +}; +``` + +
+Examples + +```js +isAnagram('iceman', 'cinema'); // true +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### isLowerCase Checks if a string is lower case. @@ -6865,6 +6937,32 @@ mask(1234567890, -4, '$'); // '$$$$567890'
[⬆ Back to top](#table-of-contents) +### pad + +Pads a string on both sides with the specified character, if it's shorter than the specified length. + +Use `String.padStart()` and `String.padEnd()` to pad both sides of the given string. +Omit the third argument, `char`, to use the whitespace character as the default padding character. + +```js +const pad = (str, length, char = ' ') => + str.padStart((str.length + length) / 2, char).padEnd(length, char); +``` + +
+Examples + +```js +pad('cat', 8); // ' cat ' +pad(String(42), 6, '0'); // '004200' +pad('foobar', 3); // 'foobar' +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### palindrome Returns `true` if the given string is a palindrome, `false` otherwise. @@ -7023,6 +7121,42 @@ splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline',
[⬆ Back to top](#table-of-contents) +### stringPermutations + +⚠️ **WARNING**: This function's execution time increases exponentially with each character. Anything more than 8 to 10 characters will cause your browser to hang as it tries to solve all the different combinations. + +Generates all permutations of a string (contains duplicates). + +Use recursion. +For each letter in the given string, create all the partial permutations for the rest of its letters. +Use `Array.map()` to combine the letter with each partial permutation, then `Array.reduce()` to combine all permutations in one array. +Base cases are for string `length` equal to `2` or `1`. + +```js +const stringPermutations = str => { + if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str]; + return str + .split('') + .reduce( + (acc, letter, i) => + acc.concat(stringPermutations(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)), + [] + ); +}; +``` + +
+Examples + +```js +stringPermutations('abc'); // ['abc','acb','bac','bca','cab','cba'] +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### stripHTMLTags Removes HTML/XML tags from string. diff --git a/dist/_30s.es5.js b/dist/_30s.es5.js index 0bc6ed0a8..2ee4a9491 100644 --- a/dist/_30s.es5.js +++ b/dist/_30s.es5.js @@ -39,15 +39,6 @@ var all = function all(arr) { return arr.every(fn); }; -var anagrams = function anagrams(str) { - if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str]; - return str.split('').reduce(function (acc, letter, i) { - return acc.concat(anagrams(str.slice(0, i) + str.slice(i + 1)).map(function (val) { - return letter + val; - })); - }, []); -}; - var any = function any(arr) { var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Boolean; return arr.some(fn); @@ -1027,6 +1018,13 @@ var isAbsoluteURL = function isAbsoluteURL(str) { ); }; +var isAnagram = function isAnagram(str1, str2) { + var normalize = function normalize(str) { + return str.toLowerCase().replace(/[^a-z0-9]/gi, '').split('').sort().join(''); + }; + return normalize(str1) === normalize(str2); +}; + function _toConsumableArray$7(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 isArrayLike = function isArrayLike(val) { @@ -1570,6 +1568,17 @@ var percentile = function percentile(arr, val) { }, 0) / arr.length; }; +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 permutations = function permutations(arr) { + if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr; + return arr.reduce(function (acc, item, i) { + return acc.concat(permutations([].concat(_toConsumableArray$16(arr.slice(0, i)), _toConsumableArray$16(arr.slice(i + 1)))).map(function (val) { + return [item].concat(_toConsumableArray$16(val)); + })); + }, []); +}; + var pick = function pick(obj, arr) { return arr.reduce(function (acc, curr) { return curr in obj && (acc[curr] = obj[curr]), acc; @@ -1765,7 +1774,7 @@ var readFileLines = function readFileLines(filename) { return fs$1.readFileSync(filename).toString('UTF8').split('\n'); }; -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$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 rearg = function rearg(fn, indexes) { return function () { @@ -1773,7 +1782,7 @@ var rearg = function rearg(fn, indexes) { args[_key] = arguments[_key]; } - return fn.apply(undefined, _toConsumableArray$16(args.reduce(function (acc, val, i) { + return fn.apply(undefined, _toConsumableArray$17(args.reduce(function (acc, val, i) { return acc[indexes.indexOf(i)] = val, acc; }, Array.from({ length: indexes.length })))); }; @@ -1819,10 +1828,10 @@ var removeNonASCII = function removeNonASCII(str) { return str.replace(/[^\x20-\x7E]/g, ''); }; -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$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 reverseString = function reverseString(str) { - return [].concat(_toConsumableArray$17(str)).reverse().join(''); + return [].concat(_toConsumableArray$18(str)).reverse().join(''); }; var round = function round(n) { @@ -1945,10 +1954,10 @@ var sleep = function sleep(ms) { }); }; -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$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 sortCharactersInString = function sortCharactersInString(str) { - return [].concat(_toConsumableArray$18(str)).sort(function (a, b) { + return [].concat(_toConsumableArray$19(str)).sort(function (a, b) { return a.localeCompare(b); }).join(''); }; @@ -1995,11 +2004,11 @@ var splitLines = function splitLines(str) { return str.split(/\r?\n/); }; -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$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 spreadOver = function spreadOver(fn) { return function (argsArr) { - return fn.apply(undefined, _toConsumableArray$19(argsArr)); + return fn.apply(undefined, _toConsumableArray$20(argsArr)); }; }; @@ -2027,6 +2036,15 @@ var standardDeviation = function standardDeviation(arr) { }, 0) / (arr.length - (usePopulation ? 0 : 1))); }; +var stringPermutations = function stringPermutations(str) { + if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str]; + return str.split('').reduce(function (acc, letter, i) { + return acc.concat(stringPermutations(str.slice(0, i) + str.slice(i + 1)).map(function (val) { + return letter + val; + })); + }, []); +}; + var stripHTMLTags = function stripHTMLTags(str) { return str.replace(/<[^>]*>/g, ''); }; @@ -2059,19 +2077,19 @@ var sumPower = function sumPower(end) { }, 0); }; -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$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 symmetricDifference = function symmetricDifference(a, b) { var sA = new Set(a), sB = new Set(b); - return [].concat(_toConsumableArray$20(a.filter(function (x) { + return [].concat(_toConsumableArray$21(a.filter(function (x) { return !sB.has(x); - })), _toConsumableArray$20(b.filter(function (x) { + })), _toConsumableArray$21(b.filter(function (x) { return !sA.has(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$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 symmetricDifferenceBy = function symmetricDifferenceBy(a, b, fn) { var sA = new Set(a.map(function (v) { @@ -2080,21 +2098,21 @@ var symmetricDifferenceBy = function symmetricDifferenceBy(a, b, fn) { sB = new Set(b.map(function (v) { return fn(v); })); - return [].concat(_toConsumableArray$21(a.filter(function (x) { + return [].concat(_toConsumableArray$22(a.filter(function (x) { return !sB.has(fn(x)); - })), _toConsumableArray$21(b.filter(function (x) { + })), _toConsumableArray$22(b.filter(function (x) { return !sA.has(fn(x)); }))); }; -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$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 symmetricDifferenceWith = function symmetricDifferenceWith(arr, val, comp) { - return [].concat(_toConsumableArray$22(arr.filter(function (a) { + return [].concat(_toConsumableArray$23(arr.filter(function (a) { return val.findIndex(function (b) { return comp(a, b); }) === -1; - })), _toConsumableArray$22(val.filter(function (a) { + })), _toConsumableArray$23(val.filter(function (a) { return arr.findIndex(function (b) { return comp(a, b); }) === -1; @@ -2333,62 +2351,46 @@ var unfold = function unfold(fn, seed) { }return result; }; -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$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 union = function union(a, b) { - return Array.from(new Set([].concat(_toConsumableArray$23(a), _toConsumableArray$23(b)))); + return Array.from(new Set([].concat(_toConsumableArray$24(a), _toConsumableArray$24(b)))); }; -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$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 unionBy = function unionBy(a, b, fn) { var s = new Set(a.map(function (v) { return fn(v); })); - return Array.from(new Set([].concat(_toConsumableArray$24(a), _toConsumableArray$24(b.filter(function (x) { + return Array.from(new Set([].concat(_toConsumableArray$25(a), _toConsumableArray$25(b.filter(function (x) { return !s.has(fn(x)); }))))); }; -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$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 unionWith = function unionWith(a, b, comp) { - return Array.from(new Set([].concat(_toConsumableArray$25(a), _toConsumableArray$25(b.filter(function (x) { + return Array.from(new Set([].concat(_toConsumableArray$26(a), _toConsumableArray$26(b.filter(function (x) { return a.findIndex(function (y) { return comp(x, y); }) === -1; }))))); }; -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$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 uniqueElements = function uniqueElements(arr) { - return [].concat(_toConsumableArray$26(new Set(arr))); + return [].concat(_toConsumableArray$27(new Set(arr))); }; var untildify = function untildify(str) { return str.replace(/^~($|\/|\\)/, (typeof require !== "undefined" && require('os').homedir()) + "$1"); }; -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 unzip = function unzip(arr) { - return arr.reduce(function (acc, val) { - return val.forEach(function (v, i) { - return acc[i].push(v); - }), acc; - }, Array.from({ - length: Math.max.apply(Math, _toConsumableArray$27(arr.map(function (x) { - return x.length; - }))) - }).map(function (x) { - return []; - })); -}; - 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 unzipWith = function unzipWith(arr, fn) { +var unzip = function unzip(arr) { return arr.reduce(function (acc, val) { return val.forEach(function (v, i) { return acc[i].push(v); @@ -2399,8 +2401,24 @@ var unzipWith = function unzipWith(arr, fn) { }))) }).map(function (x) { return []; + })); +}; + +function _toConsumableArray$29(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) { + return val.forEach(function (v, i) { + return acc[i].push(v); + }), acc; + }, Array.from({ + length: Math.max.apply(Math, _toConsumableArray$29(arr.map(function (x) { + return x.length; + }))) + }).map(function (x) { + return []; })).map(function (val) { - return fn.apply(undefined, _toConsumableArray$28(val)); + return fn.apply(undefined, _toConsumableArray$29(val)); }); }; @@ -2437,14 +2455,14 @@ var yesNo = function yesNo(val) { ); }; -function _toConsumableArray$29(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$30(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$29(arrays.map(function (x) { + var maxLength = Math.max.apply(Math, _toConsumableArray$30(arrays.map(function (x) { return x.length; }))); return Array.from({ length: maxLength }).map(function (_, i) { @@ -2460,7 +2478,7 @@ var zipObject = function zipObject(props, values) { }, {}); }; -function _toConsumableArray$30(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$31(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++) { @@ -2470,7 +2488,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$30(arrays.map(function (x) { + var maxLength = Math.max.apply(Math, _toConsumableArray$31(arrays.map(function (x) { return x.length; }))); var result = Array.from({ length: maxLength }).map(function (_, i) { @@ -2479,11 +2497,11 @@ var zipWith = function zipWith() { }); }); return fn ? result.map(function (arr) { - return fn.apply(undefined, _toConsumableArray$30(arr)); + return fn.apply(undefined, _toConsumableArray$31(arr)); }) : result; }; -var imports = { JSONToFile: JSONToFile, RGBToHex: RGBToHex, URLJoin: URLJoin, UUIDGeneratorBrowser: UUIDGeneratorBrowser, UUIDGeneratorNode: UUIDGeneratorNode, all: all, anagrams: anagrams, any: any, approximatelyEqual: approximatelyEqual, arrayToHtmlList: arrayToHtmlList, ary: ary, atob: atob, attempt: attempt, average: average, averageBy: averageBy, bifurcate: bifurcate, bifurcateBy: bifurcateBy, bind: bind, bindAll: bindAll, bindKey: bindKey, binomialCoefficient: binomialCoefficient, bottomVisible: bottomVisible, btoa: btoa, byteSize: byteSize, call: call, capitalize: capitalize, capitalizeEveryWord: capitalizeEveryWord, castArray: castArray, chainAsync: chainAsync, chunk: chunk, clampNumber: clampNumber, cloneRegExp: cloneRegExp, coalesce: coalesce, coalesceFactory: coalesceFactory, collectInto: collectInto, colorize: colorize, compact: compact, compose: compose, composeRight: composeRight, converge: converge, copyToClipboard: copyToClipboard, countBy: countBy, countOccurrences: countOccurrences, createElement: createElement, createEventHub: createEventHub, currentURL: currentURL, curry: curry, debounce: debounce, decapitalize: decapitalize, deepClone: deepClone, deepFlatten: deepFlatten, defaults: defaults, defer: defer, degreesToRads: degreesToRads, 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, flattenObject: flattenObject, flip: flip, forEachRight: forEachRight, forOwn: forOwn, forOwnRight: forOwnRight, formatDuration: formatDuration, fromCamelCase: fromCamelCase, functionName: functionName, functions: functions, gcd: gcd, geometricProgression: geometricProgression, get: get, getColonTimeFromDate: getColonTimeFromDate, getDaysDiffBetweenDates: getDaysDiffBetweenDates, getMeridiemSuffixOfInteger: getMeridiemSuffixOfInteger, getScrollPosition: getScrollPosition, getStyle: getStyle, getType: getType, getURLParameters: getURLParameters, groupBy: groupBy, hammingDistance: hammingDistance, hasClass: hasClass, hasFlags: hasFlags, hashBrowser: hashBrowser, hashNode: hashNode, head: head, hexToRGB: hexToRGB, hide: hide, httpGet: httpGet, httpPost: httpPost, httpsRedirect: httpsRedirect, 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, mostPerformant: mostPerformant, negate: negate, none: none, 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, radsToDegrees: radsToDegrees, 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, stableSort: stableSort, 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, toCurrency: toCurrency, toDecimalMark: toDecimalMark, toKebabCase: toKebabCase, toOrdinalSuffix: toOrdinalSuffix, toSafeInteger: toSafeInteger, toSnakeCase: toSnakeCase, toggleClass: toggleClass, tomorrow: tomorrow, transform: transform, truncateString: truncateString, truthCheckCollection: truthCheckCollection, unary: unary, uncurry: uncurry, unescapeHTML: unescapeHTML, unflattenObject: unflattenObject, 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, all: all, any: any, approximatelyEqual: approximatelyEqual, arrayToHtmlList: arrayToHtmlList, ary: ary, atob: atob, attempt: attempt, average: average, averageBy: averageBy, bifurcate: bifurcate, bifurcateBy: bifurcateBy, bind: bind, bindAll: bindAll, bindKey: bindKey, binomialCoefficient: binomialCoefficient, bottomVisible: bottomVisible, btoa: btoa, byteSize: byteSize, call: call, capitalize: capitalize, capitalizeEveryWord: capitalizeEveryWord, castArray: castArray, chainAsync: chainAsync, chunk: chunk, clampNumber: clampNumber, cloneRegExp: cloneRegExp, coalesce: coalesce, coalesceFactory: coalesceFactory, collectInto: collectInto, colorize: colorize, compact: compact, compose: compose, composeRight: composeRight, converge: converge, copyToClipboard: copyToClipboard, countBy: countBy, countOccurrences: countOccurrences, createElement: createElement, createEventHub: createEventHub, currentURL: currentURL, curry: curry, debounce: debounce, decapitalize: decapitalize, deepClone: deepClone, deepFlatten: deepFlatten, defaults: defaults, defer: defer, degreesToRads: degreesToRads, 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, flattenObject: flattenObject, flip: flip, forEachRight: forEachRight, forOwn: forOwn, forOwnRight: forOwnRight, formatDuration: formatDuration, fromCamelCase: fromCamelCase, functionName: functionName, functions: functions, gcd: gcd, geometricProgression: geometricProgression, get: get, getColonTimeFromDate: getColonTimeFromDate, getDaysDiffBetweenDates: getDaysDiffBetweenDates, getMeridiemSuffixOfInteger: getMeridiemSuffixOfInteger, getScrollPosition: getScrollPosition, getStyle: getStyle, getType: getType, getURLParameters: getURLParameters, groupBy: groupBy, hammingDistance: hammingDistance, hasClass: hasClass, hasFlags: hasFlags, hashBrowser: hashBrowser, hashNode: hashNode, head: head, hexToRGB: hexToRGB, hide: hide, httpGet: httpGet, httpPost: httpPost, httpsRedirect: httpsRedirect, 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, isAnagram: isAnagram, 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, mostPerformant: mostPerformant, negate: negate, none: none, 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, permutations: permutations, 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, radsToDegrees: radsToDegrees, 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, stableSort: stableSort, standardDeviation: standardDeviation, stringPermutations: stringPermutations, stripHTMLTags: stripHTMLTags, sum: sum, sumBy: sumBy, sumPower: sumPower, symmetricDifference: symmetricDifference, symmetricDifferenceBy: symmetricDifferenceBy, symmetricDifferenceWith: symmetricDifferenceWith, tail: tail, take: take, takeRight: takeRight, takeRightWhile: takeRightWhile, takeWhile: takeWhile, throttle: throttle, timeTaken: timeTaken, times: times, toCamelCase: toCamelCase, toCurrency: toCurrency, toDecimalMark: toDecimalMark, toKebabCase: toKebabCase, toOrdinalSuffix: toOrdinalSuffix, toSafeInteger: toSafeInteger, toSnakeCase: toSnakeCase, toggleClass: toggleClass, tomorrow: tomorrow, transform: transform, truncateString: truncateString, truthCheckCollection: truthCheckCollection, unary: unary, uncurry: uncurry, unescapeHTML: unescapeHTML, unflattenObject: unflattenObject, 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 8121c7fea..1e206da34 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^$.randomBytes(1)[0]&15>>e/4).toString(16)})},all:function(e){var t=1=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}))},[])},any:function(e){var t=1'})},ary:function(t,r){return function(){for(var n=arguments.length,i=Array(n),l=0;lt||t>e)return 0;if(0===t||t===e)return 1;if(1===t||t===e-1)return e;e-t=(document.documentElement.scrollHeight||document.documentElement.clientHeight)},btoa:function(e){return 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:P(e/8.64e7),hour:P(e/3.6e6)%24,minute:P(e/6e4)%60,second:P(e/1e3)%60,millisecond:P(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=1e?e%12+'am':e%12+'pm'},getScrollPosition:function(){var e=0>>(t?24:16))+', '+((n&(t?16711680:65280))>>>(t?16:8))+', '+((n&(t?65280:255))>>>(t?8:0))+(t?', '+(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=re(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':ie(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:sG(e))return e+(r?' ':'')+i[0];var l=F(P(Math.log10(0>e?-e:e)/3),i.length-1),o=+((0>e?-e:e)/U(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=P(z(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,C(t))}},stableSort:function(e,t){return e.map(function(e,t){return{item:e,index:t}}).sort(function(e,n){return t(e.item,n.item)||e.index-n.index}).map(function(e){var t=e.item;return t})},standardDeviation:function(e){var t=1]*>/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,3r.length)throw new RangeError('Arguments too few!');return function(e){return function(t){return t.reduce(function(e,t){return e(t)},e)}}(e)(r.slice(0,t))}},unescapeHTML:function(e){return e.replace(/&|<|>|'|"/g,function(e){return{"&":'&',"<":'<',">":'>',"'":'\'',""":'"'}[e]||e})},unflattenObject:function(e){return Object.keys(e).reduce(function(t,n){if(-1!==n.indexOf('.')){var r=n.split('.');Object.assign(t,JSON.parse('{'+r.map(function(e,t){return t===r.length-1?'"'+e+'":':'"'+e+'":{'}).join('')+e[n]+'}'.repeat(r.length)))}else t[n]=e[n];return t},{})},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(w(e),w(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(T(e),T(t.filter(function(t){return-1===e.findIndex(function(e){return n(t,e)})})))))},uniqueElements:function(e){return[].concat(B(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:H.apply(Math,R(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:H.apply(Math,O(e.map(function(e){return e.length})))}).map(function(){return[]})).map(function(e){return t.apply(void 0,O(e))})},validateNumber:function(e){return!isNaN(parseFloat(e))&&isFinite(e)&&+e==e},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^K.randomBytes(1)[0]&15>>e/4).toString(16)})},all:function(e){var t=1'})},ary:function(t,r){return function(){for(var n=arguments.length,i=Array(n),l=0;lt||t>e)return 0;if(0===t||t===e)return 1;if(1===t||t===e-1)return e;e-t=(document.documentElement.scrollHeight||document.documentElement.clientHeight)},btoa:function(e){return 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=1e?e%12+'am':e%12+'pm'},getScrollPosition:function(){var e=0>>(t?24:16))+', '+((n&(t?16711680:65280))>>>(t?16:8))+', '+((n&(t?65280:255))>>>(t?8:0))+(t?', '+(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=ie(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':le(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:sq(e))return e+(r?' ':'')+i[0];var l=H(U(Math.log10(0>e?-e:e)/3),i.length-1),o=+((0>e?-e:e)/W(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(P(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,E(t))}},stableSort:function(e,t){return e.map(function(e,t){return{item:e,index:t}}).sort(function(e,n){return t(e.item,n.item)||e.index-n.index}).map(function(e){var t=e.item;return t})},standardDeviation:function(e){var t=1=t.length?2===t.length?[t,t[1]+t[0]]:[t]:t.split('').reduce(function(n,r,l){return n.concat(e(t.slice(0,l)+t.slice(l+1)).map(function(e){return r+e}))},[])},stripHTMLTags:function(e){return e.replace(/<[^>]*>/g,'')},sum:function(){for(var e=arguments.length,t=Array(e),n=0;n=t&&(e.apply(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,3r.length)throw new RangeError('Arguments too few!');return function(e){return function(t){return t.reduce(function(e,t){return e(t)},e)}}(e)(r.slice(0,t))}},unescapeHTML:function(e){return e.replace(/&|<|>|'|"/g,function(e){return{"&":'&',"<":'<',">":'>',"'":'\'',""":'"'}[e]||e})},unflattenObject:function(e){return Object.keys(e).reduce(function(t,n){if(-1!==n.indexOf('.')){var r=n.split('.');Object.assign(t,JSON.parse('{'+r.map(function(e,t){return t===r.length-1?'"'+e+'":':'"'+e+'":{'}).join('')+e[n]+'}'.repeat(r.length)))}else t[n]=e[n];return t},{})},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(w(e),w(t))))},unionBy:function(e,t,n){var r=new Set(e.map(function(e){return n(e)}));return Array.from(new Set([].concat(T(e),T(t.filter(function(e){return!r.has(n(e))})))))},unionWith:function(e,t,n){return Array.from(new Set([].concat(B(e),B(t.filter(function(t){return-1===e.findIndex(function(e){return n(t,e)})})))))},uniqueElements:function(e){return[].concat(R(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:M.apply(Math,O(e.map(function(e){return e.length})))}).map(function(){return[]}))},unzipWith:function(e,t){return e.reduce(function(e,t){return t.forEach(function(t,n){return e[n].push(t)}),e},Array.from({length:M.apply(Math,N(e.map(function(e){return e.length})))}).map(function(){return[]})).map(function(e){return t.apply(void 0,N(e))})},validateNumber:function(e){return!isNaN(parseFloat(e))&&isFinite(e)&&+e==e},without:function(e){for(var t=arguments.length,n=Array(1 const all = (arr, fn = Boolean) => arr.every(fn); -const anagrams = str => { - if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str]; - return str - .split('') - .reduce( - (acc, letter, i) => - acc.concat(anagrams(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)), - [] - ); -}; - const any = (arr, fn = Boolean) => arr.some(fn); const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon; @@ -607,6 +596,17 @@ const is = (type, val) => val instanceof type; const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); +const isAnagram = (str1, str2) => { + const normalize = str => + str + .toLowerCase() + .replace(/[^a-z0-9]/gi, '') + .split('') + .sort() + .join(''); + return normalize(str1) === normalize(str2); +}; + const isArrayLike = val => { try { return [...val], true; @@ -910,6 +910,17 @@ const partition = (arr, fn) => const percentile = (arr, val) => 100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0) / arr.length; +const permutations = arr => { + if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr; + return arr.reduce( + (acc, item, i) => + acc.concat( + permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val => [item, ...val]) + ), + [] + ); +}; + const pick = (obj, arr) => arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {}); @@ -1174,6 +1185,17 @@ const standardDeviation = (arr, usePopulation = false) => { ); }; +const stringPermutations = str => { + if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str]; + return str + .split('') + .reduce( + (acc, letter, i) => + acc.concat(stringPermutations(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)), + [] + ); +}; + const stripHTMLTags = str => str.replace(/<[^>]*>/g, ''); const sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0); @@ -1423,6 +1445,6 @@ const zipWith = (...arrays) => { return fn ? result.map(arr => fn(...arr)) : result; }; -var imports = {JSONToFile,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,all,anagrams,any,approximatelyEqual,arrayToHtmlList,ary,atob,attempt,average,averageBy,bifurcate,bifurcateBy,bind,bindAll,bindKey,binomialCoefficient,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,composeRight,converge,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,debounce,decapitalize,deepClone,deepFlatten,defaults,defer,degreesToRads,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,flattenObject,flip,forEachRight,forOwn,forOwnRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getColonTimeFromDate,getDaysDiffBetweenDates,getMeridiemSuffixOfInteger,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,mostPerformant,negate,none,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,radsToDegrees,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,stableSort,standardDeviation,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,timeTaken,times,toCamelCase,toCurrency,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unary,uncurry,unescapeHTML,unflattenObject,unfold,union,unionBy,unionWith,uniqueElements,untildify,unzip,unzipWith,validateNumber,without,words,xProd,yesNo,zip,zipObject,zipWith,} +var imports = {JSONToFile,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,all,any,approximatelyEqual,arrayToHtmlList,ary,atob,attempt,average,averageBy,bifurcate,bifurcateBy,bind,bindAll,bindKey,binomialCoefficient,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,composeRight,converge,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,debounce,decapitalize,deepClone,deepFlatten,defaults,defer,degreesToRads,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,flattenObject,flip,forEachRight,forOwn,forOwnRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getColonTimeFromDate,getDaysDiffBetweenDates,getMeridiemSuffixOfInteger,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,isAnagram,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,mostPerformant,negate,none,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,omit,omitBy,on,onUserInputChange,once,orderBy,over,overArgs,palindrome,parseCookie,partial,partialRight,partition,percentile,permutations,pick,pickBy,pipeAsyncFunctions,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,radsToDegrees,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,stableSort,standardDeviation,stringPermutations,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,timeTaken,times,toCamelCase,toCurrency,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unary,uncurry,unescapeHTML,unflattenObject,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 b57412c38..5631a8425 100644 --- a/dist/_30s.js +++ b/dist/_30s.js @@ -33,17 +33,6 @@ const UUIDGeneratorNode = () => const all = (arr, fn = Boolean) => arr.every(fn); -const anagrams = str => { - if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str]; - return str - .split('') - .reduce( - (acc, letter, i) => - acc.concat(anagrams(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)), - [] - ); -}; - const any = (arr, fn = Boolean) => arr.some(fn); const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon; @@ -613,6 +602,17 @@ const is = (type, val) => val instanceof type; const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); +const isAnagram = (str1, str2) => { + const normalize = str => + str + .toLowerCase() + .replace(/[^a-z0-9]/gi, '') + .split('') + .sort() + .join(''); + return normalize(str1) === normalize(str2); +}; + const isArrayLike = val => { try { return [...val], true; @@ -916,6 +916,17 @@ const partition = (arr, fn) => const percentile = (arr, val) => 100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0) / arr.length; +const permutations = arr => { + if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr; + return arr.reduce( + (acc, item, i) => + acc.concat( + permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val => [item, ...val]) + ), + [] + ); +}; + const pick = (obj, arr) => arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {}); @@ -1180,6 +1191,17 @@ const standardDeviation = (arr, usePopulation = false) => { ); }; +const stringPermutations = str => { + if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str]; + return str + .split('') + .reduce( + (acc, letter, i) => + acc.concat(stringPermutations(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)), + [] + ); +}; + const stripHTMLTags = str => str.replace(/<[^>]*>/g, ''); const sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0); @@ -1429,7 +1451,7 @@ const zipWith = (...arrays) => { return fn ? result.map(arr => fn(...arr)) : result; }; -var imports = {JSONToFile,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,all,anagrams,any,approximatelyEqual,arrayToHtmlList,ary,atob,attempt,average,averageBy,bifurcate,bifurcateBy,bind,bindAll,bindKey,binomialCoefficient,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,composeRight,converge,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,debounce,decapitalize,deepClone,deepFlatten,defaults,defer,degreesToRads,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,flattenObject,flip,forEachRight,forOwn,forOwnRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getColonTimeFromDate,getDaysDiffBetweenDates,getMeridiemSuffixOfInteger,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,mostPerformant,negate,none,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,radsToDegrees,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,stableSort,standardDeviation,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,timeTaken,times,toCamelCase,toCurrency,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unary,uncurry,unescapeHTML,unflattenObject,unfold,union,unionBy,unionWith,uniqueElements,untildify,unzip,unzipWith,validateNumber,without,words,xProd,yesNo,zip,zipObject,zipWith,} +var imports = {JSONToFile,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,all,any,approximatelyEqual,arrayToHtmlList,ary,atob,attempt,average,averageBy,bifurcate,bifurcateBy,bind,bindAll,bindKey,binomialCoefficient,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,composeRight,converge,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,debounce,decapitalize,deepClone,deepFlatten,defaults,defer,degreesToRads,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,flattenObject,flip,forEachRight,forOwn,forOwnRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getColonTimeFromDate,getDaysDiffBetweenDates,getMeridiemSuffixOfInteger,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,isAnagram,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,mostPerformant,negate,none,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,omit,omitBy,on,onUserInputChange,once,orderBy,over,overArgs,palindrome,parseCookie,partial,partialRight,partition,percentile,permutations,pick,pickBy,pipeAsyncFunctions,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,radsToDegrees,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,stableSort,standardDeviation,stringPermutations,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,timeTaken,times,toCamelCase,toCurrency,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unary,uncurry,unescapeHTML,unflattenObject,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 acdc95069..958823a81 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.sqrt,b=Math.log,c=Math.floor,d=Math.PI,e=Math.min,g=Math.max,h=Math.ceil,i=Math.round,j=Math.abs;const k='undefined'!=typeof require&&require('fs'),l='undefined'!=typeof require&&require('crypto'),m=(a)=>2>=a.length?2===a.length?[a,a[1]+a[0]]:[a]:a.split('').reduce((b,c,d)=>b.concat(m(a.slice(0,d)+a.slice(d+1)).map((a)=>c+a)),[]),n=(a,b=a.length,...c)=>b<=c.length?a(...c):n.bind(null,a,b,...c),o=(a)=>{let b=Object.assign({},a);return Object.keys(b).forEach((c)=>b[c]='object'==typeof a[c]?o(a[c]):a[c]),b},p=(a)=>[].concat(...a.map((a)=>Array.isArray(a)?p(a):a)),q=([...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)=>r(c[a],d[a]))},s=(a)=>0>a?(()=>{throw new TypeError('Negative numbers are not allowed!')})():1>=a?1:a*s(a-1),t=(a,b=1)=>1===b?a.reduce((b,a)=>b.concat(a),[]):a.reduce((c,a)=>c.concat(Array.isArray(a)?t(a,b-1):a),[]),u=(a,b='')=>Object.keys(a).reduce((c,d)=>{const e=b.length?b+'.':'';return'object'==typeof a[d]?Object.assign(c,u(a[d],e+d)):c[e+d]=a[d],c},{}),v=(...a)=>{const c=(a,b)=>b?v(b,a%b):a;return[...a].reduce((d,a)=>c(d,a))},w='undefined'!=typeof require&&require('crypto'),x='undefined'!=typeof require&&require('fs'),y=()=>{const a=document.documentElement.scrollTop||document.body.scrollTop;0k.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^l.randomBytes(1)[0]&15>>a/4).toString(16)),all:(a,b=Boolean)=>a.every(b),anagrams:m,any:(a,b=Boolean)=>a.some(b),approximatelyEqual:(a,b,c=1e-3)=>j(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,bifurcate:(a,b)=>a.reduce((a,c,d)=>(a[b[d]?0:1].push(c),a),[[],[]]),bifurcateBy:(a,b)=>a.reduce((a,c,d)=>(a[b(c,d)?0:1].push(c),a),[[],[]]),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))},binomialCoefficient:(a,b)=>{var c=Number.isNaN;if(c(a)||c(b))return NaN;if(0>b||b>a)return 0;if(0===b||b===a)return 1;if(1===b||b===a-1)return a;a-bdocument.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))),converge:(a,b)=>(...c)=>a(...b.map((a)=>a.apply(null,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:n,debounce:(a,b=0)=>{let c;return function(...d){clearTimeout(c),c=setTimeout(()=>a.apply(this,d),b)}},decapitalize:([a,...b],c=!1)=>a.toLowerCase()+(c?b.join('').toUpperCase():b.join('')),deepClone:o,deepFlatten:p,defaults:(a,...b)=>Object.assign({},a,...b.reverse(),a),defer:(a,...b)=>setTimeout(a,1,...b),degreesToRads:(a)=>a*d/180,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:s,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:t,flattenObject:u,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:c(a/8.64e7),hour:c(a/3.6e6)%24,minute:c(a/6e4)%60,second:c(a/1e3)%60,millisecond:c(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:v,geometricProgression:(a,d=1,e=2)=>Array.from({length:c(b(a/d)/b(e))+1}).map((a,b)=>d*e**b),get:(a,...b)=>[...b].map((b)=>b.replace(/\[([^\[\]]*)\]/g,'.$1.').split('.').filter((a)=>''!==a).reduce((a,b)=>a&&a[b],a)),getColonTimeFromDate:(a)=>a.toTimeString().slice(0,8),getDaysDiffBetweenDates:(a,b)=>(b-a)/86400000,getMeridiemSuffixOfInteger:(a)=>0===a||24===a?'12am':12===a?'12pm':12>a?a%12+'am':a%12+'pm',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(w.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:(b)=>{const d=c(a(b));for(var e=2;e<=d;e++)if(0==b%e)return!1;return 2<=b},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=c(a.length/2),d=[...a].sort((c,a)=>c-a);return 0==a.length%2?(d[b-1]+d[b])/2:d[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),mostPerformant:(a,b=1e4)=>{const c=a.map((a)=>{const c=performance.now();for(let c=0;c(...b)=>!a(...b),none:(a,b=Boolean)=>!a.some(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,d=!0)=>{const g=['B','KB','MB','GB','TB','PB','EB','ZB','YB'];if(1>j(a))return a+(d?' ':'')+g[0];const h=e(c(Math.log10(0>a?-a:a)/3),g.length-1),i=+((0>a?-a:a)/1e3**h).toPrecision(b);return(0>a?'-':'')+i+(d?' ':'')+g[h]},primes:(b)=>{let d=Array.from({length:b-1}).map((a,b)=>b+2),e=c(a(b)),g=Array.from({length:e-1}).map((a,b)=>b+2);return g.forEach((a)=>d=d.filter((b)=>0!=b%a||b===a)),d},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))},radsToDegrees:(a)=>180*a/d,randomHexColorCode:()=>{let a=(1e6*(1048575*Math.random())).toString(16);return'#'+a.slice(0,6)},randomIntArrayInRange:(a,b,d=1)=>Array.from({length:d},()=>c(Math.random()*(b-a+1))+a),randomIntegerInRange:(a,b)=>c(Math.random()*(b-a+1))+a,randomNumberInRange:(a,b)=>Math.random()*(b-a)+a,readFileLines:(a)=>x.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:(a,b=0)=>+`${i(`${a}e${b}`)}e-${b}`,runAsync:(a)=>{const b=new Worker(URL.createObjectURL(new Blob([`postMessage((${a})());`]),{type:'application/javascript; charset=utf-8'}));return new Promise((a,c)=>{b.onmessage=({data:c})=>{a(c),b.terminate()},b.onerror=(a)=>{c(a),b.terminate()}})},runPromisesInSeries:(a)=>a.reduce((a,b)=>a.then(b),Promise.resolve()),sample:(a)=>a[c(Math.random()*a.length)],sampleSize:([...a],b=1)=>{for(let d=a.length;d;){const b=c(Math.random()*d--);[a[d],a[b]]=[a[b],a[d]]}return a.slice(0,b)},scrollToTop:y,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 d=c(Math.random()*b--);[a[b],a[d]]=[a[d],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),stableSort:(a,c)=>a.map((a,b)=>({item:a,index:b})).sort((d,a)=>c(d.item,a.item)||d.index-a.index).map(({item:a})=>a),standardDeviation:(b,c=!1)=>{const d=b.reduce((a,b)=>a+b,0)/b.length;return a(b.reduce((a,b)=>a.concat((b-d)**2),[]).reduce((a,b)=>a+b,0)/(b.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)},toCurrency:(a,b,c=void 0)=>Intl.NumberFormat(c,{style:'currency',currency:b}).format(a),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:(a)=>i(g(e(a,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),uncurry:(a,b=1)=>(...c)=>{if(b>c.length)throw new RangeError('Arguments too few!');return((a)=>(b)=>b.reduce((a,b)=>a(b),a))(a)(c.slice(0,b))},unescapeHTML:(a)=>a.replace(/&|<|>|'|"/g,(a)=>({"&":'&',"<":'<',">":'>',"'":'\'',""":'"'})[a]||a),unflattenObject:(a)=>Object.keys(a).reduce((b,c)=>{if(-1!==c.indexOf('.')){const d=c.split('.');Object.assign(b,JSON.parse('{'+d.map((a,b)=>b===d.length-1?`"${a}":`:`"${a}":{`).join('')+a[c]+'}'.repeat(d.length)))}else b[c]=a[c];return b},{}),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}}}); +(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.sqrt,b=Math.log,c=Math.floor,d=Math.PI,e=Math.min,g=Math.max,h=Math.ceil,i=Math.round,j=Math.abs;const k='undefined'!=typeof require&&require('fs'),l='undefined'!=typeof require&&require('crypto'),m=(a,b=a.length,...c)=>b<=c.length?a(...c):m.bind(null,a,b,...c),n=(a)=>{let b=Object.assign({},a);return Object.keys(b).forEach((c)=>b[c]='object'==typeof a[c]?n(a[c]):a[c]),b},o=(a)=>[].concat(...a.map((a)=>Array.isArray(a)?o(a):a)),p=([...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)=>q(c[a],d[a]))},r=(a)=>0>a?(()=>{throw new TypeError('Negative numbers are not allowed!')})():1>=a?1:a*r(a-1),s=(a,b=1)=>1===b?a.reduce((b,a)=>b.concat(a),[]):a.reduce((c,a)=>c.concat(Array.isArray(a)?s(a,b-1):a),[]),t=(a,b='')=>Object.keys(a).reduce((c,d)=>{const e=b.length?b+'.':'';return'object'==typeof a[d]?Object.assign(c,t(a[d],e+d)):c[e+d]=a[d],c},{}),u=(...a)=>{const c=(a,b)=>b?u(b,a%b):a;return[...a].reduce((d,a)=>c(d,a))},v='undefined'!=typeof require&&require('crypto'),w=(a)=>2>=a.length?2===a.length?[a,[a[1],a[0]]]:a:a.reduce((b,c,d)=>b.concat(w([...a.slice(0,d),...a.slice(d+1)]).map((a)=>[c,...a])),[]),x='undefined'!=typeof require&&require('fs'),y=()=>{const a=document.documentElement.scrollTop||document.body.scrollTop;02>=a.length?2===a.length?[a,a[1]+a[0]]:[a]:a.split('').reduce((b,c,d)=>b.concat(z(a.slice(0,d)+a.slice(d+1)).map((a)=>c+a)),[]);return{JSONToFile:(a,b)=>k.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^l.randomBytes(1)[0]&15>>a/4).toString(16)),all:(a,b=Boolean)=>a.every(b),any:(a,b=Boolean)=>a.some(b),approximatelyEqual:(a,b,c=1e-3)=>j(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,bifurcate:(a,b)=>a.reduce((a,c,d)=>(a[b[d]?0:1].push(c),a),[[],[]]),bifurcateBy:(a,b)=>a.reduce((a,c,d)=>(a[b(c,d)?0:1].push(c),a),[[],[]]),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))},binomialCoefficient:(a,b)=>{var c=Number.isNaN;if(c(a)||c(b))return NaN;if(0>b||b>a)return 0;if(0===b||b===a)return 1;if(1===b||b===a-1)return a;a-bdocument.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))),converge:(a,b)=>(...c)=>a(...b.map((a)=>a.apply(null,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:m,debounce:(a,b=0)=>{let c;return function(...d){clearTimeout(c),c=setTimeout(()=>a.apply(this,d),b)}},decapitalize:([a,...b],c=!1)=>a.toLowerCase()+(c?b.join('').toUpperCase():b.join('')),deepClone:n,deepFlatten:o,defaults:(a,...b)=>Object.assign({},a,...b.reverse(),a),defer:(a,...b)=>setTimeout(a,1,...b),degreesToRads:(a)=>a*d/180,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:r,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:s,flattenObject:t,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:c(a/8.64e7),hour:c(a/3.6e6)%24,minute:c(a/6e4)%60,second:c(a/1e3)%60,millisecond:c(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:u,geometricProgression:(a,d=1,e=2)=>Array.from({length:c(b(a/d)/b(e))+1}).map((a,b)=>d*e**b),get:(a,...b)=>[...b].map((b)=>b.replace(/\[([^\[\]]*)\]/g,'.$1.').split('.').filter((a)=>''!==a).reduce((a,b)=>a&&a[b],a)),getColonTimeFromDate:(a)=>a.toTimeString().slice(0,8),getDaysDiffBetweenDates:(a,b)=>(b-a)/86400000,getMeridiemSuffixOfInteger:(a)=>0===a||24===a?'12am':12===a?'12pm':12>a?a%12+'am':a%12+'pm',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(v.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),isAnagram:(a,b)=>{const c=(a)=>a.toLowerCase().replace(/[^a-z0-9]/gi,'').split('').sort().join('');return c(a)===c(b)},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:(b)=>{const d=c(a(b));for(var e=2;e<=d;e++)if(0==b%e)return!1;return 2<=b},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=c(a.length/2),d=[...a].sort((c,a)=>c-a);return 0==a.length%2?(d[b-1]+d[b])/2:d[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),mostPerformant:(a,b=1e4)=>{const c=a.map((a)=>{const c=performance.now();for(let c=0;c(...b)=>!a(...b),none:(a,b=Boolean)=>!a.some(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,d=!0)=>{const g=['B','KB','MB','GB','TB','PB','EB','ZB','YB'];if(1>j(a))return a+(d?' ':'')+g[0];const h=e(c(Math.log10(0>a?-a:a)/3),g.length-1),i=+((0>a?-a:a)/1e3**h).toPrecision(b);return(0>a?'-':'')+i+(d?' ':'')+g[h]},primes:(b)=>{let d=Array.from({length:b-1}).map((a,b)=>b+2),e=c(a(b)),g=Array.from({length:e-1}).map((a,b)=>b+2);return g.forEach((a)=>d=d.filter((b)=>0!=b%a||b===a)),d},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))},radsToDegrees:(a)=>180*a/d,randomHexColorCode:()=>{let a=(1e6*(1048575*Math.random())).toString(16);return'#'+a.slice(0,6)},randomIntArrayInRange:(a,b,d=1)=>Array.from({length:d},()=>c(Math.random()*(b-a+1))+a),randomIntegerInRange:(a,b)=>c(Math.random()*(b-a+1))+a,randomNumberInRange:(a,b)=>Math.random()*(b-a)+a,readFileLines:(a)=>x.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:(a,b=0)=>+`${i(`${a}e${b}`)}e-${b}`,runAsync:(a)=>{const b=new Worker(URL.createObjectURL(new Blob([`postMessage((${a})());`]),{type:'application/javascript; charset=utf-8'}));return new Promise((a,c)=>{b.onmessage=({data:c})=>{a(c),b.terminate()},b.onerror=(a)=>{c(a),b.terminate()}})},runPromisesInSeries:(a)=>a.reduce((a,b)=>a.then(b),Promise.resolve()),sample:(a)=>a[c(Math.random()*a.length)],sampleSize:([...a],b=1)=>{for(let d=a.length;d;){const b=c(Math.random()*d--);[a[d],a[b]]=[a[b],a[d]]}return a.slice(0,b)},scrollToTop:y,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 d=c(Math.random()*b--);[a[b],a[d]]=[a[d],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),stableSort:(a,c)=>a.map((a,b)=>({item:a,index:b})).sort((d,a)=>c(d.item,a.item)||d.index-a.index).map(({item:a})=>a),standardDeviation:(b,c=!1)=>{const d=b.reduce((a,b)=>a+b,0)/b.length;return a(b.reduce((a,b)=>a.concat((b-d)**2),[]).reduce((a,b)=>a+b,0)/(b.length-(c?0:1)))},stringPermutations:z,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)},toCurrency:(a,b,c=void 0)=>Intl.NumberFormat(c,{style:'currency',currency:b}).format(a),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:(a)=>i(g(e(a,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),uncurry:(a,b=1)=>(...c)=>{if(b>c.length)throw new RangeError('Arguments too few!');return((a)=>(b)=>b.reduce((a,b)=>a(b),a))(a)(c.slice(0,b))},unescapeHTML:(a)=>a.replace(/&|<|>|'|"/g,(a)=>({"&":'&',"<":'<',">":'>',"'":'\'',""":'"'})[a]||a),unflattenObject:(a)=>Object.keys(a).reduce((b,c)=>{if(-1!==c.indexOf('.')){const d=c.split('.');Object.assign(b,JSON.parse('{'+d.map((a,b)=>b===d.length-1?`"${a}":`:`"${a}":{`).join('')+a[c]+'}'.repeat(d.length)))}else b[c]=a[c];return b},{}),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 d8b48804d..6cc929870 100644 --- a/docs/index.html +++ b/docs/index.html @@ -19,11 +19,30 @@ document.querySelector('main').scrollTo(0, c - c / 4); } }; + function scrollTo(element, to, id, duration) { + if (duration <= 0) return; + var difference = to - element.scrollTop; + var perTick = difference / duration * 40; + + setTimeout(function() { + element.scrollTop = element.scrollTop + perTick; + if (element.scrollTop === to) { + window.location.href = "#"+id; + return; + } + scrollTo(element, to, id, duration - 40); + }, 40); + }; function loader() { registerClickListener(); } function registerClickListener() { document.addEventListener('click', function (event) { + if( document.getElementById('doc-drawer-checkbox').checked ) { + if(!document.querySelector('nav').contains(event.target) && !event.target.classList.contains('drawer-toggle') && !event.target.classList.contains('drawer')) { + document.getElementById('doc-drawer-checkbox').checked = false; + } + } if ( event.target.classList.contains('collapse') ) { event.target.classList = event.target.classList.contains('toggled') ? 'collapse' : 'collapse toggled'; } @@ -49,8 +68,13 @@ else if (event.target.classList.contains('scroll-to-top')){ scrollToTop(); } + else if (event.target.classList.contains('sublink-1')){ + event.preventDefault(); + scrollTo(document.querySelector('main'), document.getElementById(event.target.href.split('#')[1]).parentElement.offsetTop - 60, event.target.href.split('#')[1], 400); + document.getElementById('doc-drawer-checkbox').checked = false; + } }, 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);
    @@ -311,6 +335,17 @@ Object.assig
       );
     
    const users = [{ user: 'barney', age: 36, active: false }, { user: 'fred', age: 40, active: true }];
     partition(users, o => o.active); // [[{ 'user': 'fred',    'age': 40, 'active': true }],[{ 'user': 'barney',  'age': 36, 'active': false }]]
    +

    permutations

    ⚠️ WARNING: This function's execution time increases exponentially with each array element. Anything more than 8 to 10 entries will cause your browser to hang as it tries to solve all the different combinations.

    Generates all permutations of an array's elements (contains duplicates).

    Use recursion. For each element in the given array, create all the partial permutations for the rest of its elements. Use Array.map() to combine the element with each partial permutation, then Array.reduce() to combine all permutations in one array. Base cases are for array length equal to 2 or 1.

    const permutations = arr => {
    +  if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr;
    +  return arr.reduce(
    +    (acc, item, i) =>
    +      acc.concat(
    +        permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val => [item, ...val])
    +      ),
    +    []
    +  );
    +};
    +
    permutations([1, 33, 5]); // [ [ 1, 33, 5 ], [ 1, 5, 33 ], [ 33, 1, 5 ], [ 33, 5, 1 ], [ 5, 1, 33 ], [ 5, 33, 1 ] ]
     

    pull

    Mutates the original array to filter out the values specified.

    Use Array.filter() and Array.includes() to pull out the values that are not needed. Use Array.length = 0 to mutate the passed in an array by resetting it's length to zero and Array.push() to re-populate it with only the pulled values.

    (For a snippet that does not mutate the original array see without)

    const pull = (arr, ...args) => {
       let argState = Array.isArray(args[0]) ? args[0] : args;
       let pulled = arr.filter((v, i) => !argState.includes(v));
    @@ -429,22 +464,19 @@ Object.assig
       return index === -1 ? arr.length : index;
     };
     
    sortedIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x); // 0
    -

    sortedLastIndex

    Returns the highest index at which value should be inserted into array in order to maintain its sort order.

    Check if the array is sorted in descending order (loosely). Use Array.map() to map each element to an array with its index and value. Use Array.reverse() and Array.findIndex() to find the appropriate last index where the element should be inserted.

    const sortedLastIndex = (arr, n) => {
    +

    sortedLastIndex

    Returns the highest index at which value should be inserted into array in order to maintain its sort order.

    Check if the array is sorted in descending order (loosely). Use Array.reverse() and Array.findIndex() to find the appropriate last index where the element should be inserted.

    const sortedLastIndex = (arr, n) => {
       const isDescending = arr[0] > arr[arr.length - 1];
    -  const index = arr
    -    .map((val, i) => [i, val])
    -    .reverse()
    -    .findIndex(el => (isDescending ? n <= el[1] : n >= el[1]));
    +  const index = arr.reverse().findIndex(el => (isDescending ? n <= el : n >= el));
       return index === -1 ? 0 : arr.length - index - 1;
     };
     
    sortedLastIndex([10, 20, 30, 30, 40], 30); // 3
    -

    sortedLastIndexBy

    Returns the highest index at which value should be inserted into array in order to maintain its sort order, based on a provided iterator function.

    Check if the array is sorted in descending order (loosely). Use Array.reverse() and Array.findIndex() to find the appropriate last index where the element should be inserted, based on the iterator function fn..

    const sortedLastIndexBy = (arr, n, fn) => {
    +

    sortedLastIndexBy

    Returns the highest index at which value should be inserted into array in order to maintain its sort order, based on a provided iterator function.

    Check if the array is sorted in descending order (loosely). Use Array.map() to apply the iterator function to all elements of the array. Use Array.reverse() and Array.findIndex() to find the appropriate last index where the element should be inserted, based on the provided iterator function.

    const sortedLastIndexBy = (arr, n, fn) => {
       const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]);
       const val = fn(n);
       const index = arr
    -    .map((val, i) => [i, fn(val)])
    +    .map(fn)
         .reverse()
    -    .findIndex(el => (isDescending ? val <= el[1] : val >= el[1]));
    +    .findIndex(el => (isDescending ? val <= el : val >= el));
       return index === -1 ? 0 : arr.length - index;
     };
     
    sortedLastIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x); // 1
    @@ -804,14 +836,16 @@ document.bodygetMeridiemSuffixOfInteger(11); // "11am"
     getMeridiemSuffixOfInteger(13); // "1pm"
     getMeridiemSuffixOfInteger(25); // "1pm"
    -

    tomorrow

    Results in a string representation of tomorrow's date. Use new Date() to get today's date, adding one day using Date.getDate() and Date.setDate(), and converting the Date object to a string.

    const tomorrow = () => {
    +

    tomorrow

    Results in a string representation of tomorrow's date. Use new Date() to get today's date, adding one day using Date.getDate() and Date.setDate(), and converting the Date object to a string.

    const tomorrow = (long = false) => {
       let t = new Date();
       t.setDate(t.getDate() + 1);
    -  return `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(
    +  const ret = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(
         t.getDate()
    -  ).padStart(2, '0')}`;
    +  ).padStart(2, '0')}`;
    +  return !long ? ret : `${ret}T00:00:00`;
     };
     
    tomorrow(); // 2017-12-27 (if current date is 2017-12-26)
    +tomorrow(true); // 2017-12-27T00:00:00 (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.

    const attempt = (fn, ...args) => {
       try {
         return fn(args);
    @@ -1441,6 +1475,19 @@ Foo.prototype: 'foo'
     };
     merge(object, other); // { a: [ { x: 2 }, { y: 4 }, { z: 3 } ], b: [ 1, 2, 3 ], c: 'foo' }
    +

    nest

    Given a flat array of objects linked to one another, it will nest them recursively. Useful for nesting comments, such as the ones on reddit.com.

    Use recursion. Use Array.filter() to filter the items where the id matches the link, then Array.map() to map each one to a new object that has a children property which recursively nests the items based on which ones are children of the current item. Omit the second argument, id, to default to null which indicates the object is not linked to another one (i.e. it is a top level object). Omit the third argument, link, to use 'parent_id' as the default property which links the object to another one by its id.

    const nest = (items, id = null, link = 'parent_id') =>
    +  items
    +    .filter(item => item[link] === id)
    +    .map(item => ({ ...item, children: nest(items, item.id) }));
    +
    // One top level comment
    +const comments = [
    +  { id: 1, parent_id: null },
    +  { id: 2, parent_id: 1 },
    +  { id: 3, parent_id: 1 },
    +  { id: 4, parent_id: 2 },
    +  { id: 5, parent_id: 4 }
    +];
    +const nestedComments = nest(comments); // [{ id: 1, parent_id: null, children: [...] }]
     

    objectFromPairs

    Creates an object from the given key-value pairs.

    Use Array.reduce() to create and combine key-value pairs.

    const objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {});
     
    objectFromPairs([['a', 1], ['b', 2]]); // {a: 1, b: 2}
     

    objectToPairs

    Creates an array of key-value pair arrays from an object.

    Use Object.keys() and Array.map() to iterate over the object's keys and produce an array with key-value pairs.

    const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]);
    @@ -1516,18 +1563,7 @@ Foo.prototypereturn acc;
       }, {});
     
    unflattenObject({ 'a.b.c': 1, d: 1 }); // { a: { b: { c: 1 } }, d: 1 }
    -

    String

    anagrams

    ⚠️ WARNING: This function's execution time increases exponentially with each character. Anything more than 8 to 10 characters will cause your browser to hang as it tries to solve all the different combinations.

    Generates all anagrams of a string (contains duplicates).

    Use recursion. For each letter in the given string, create all the partial anagrams for the rest of its letters. Use Array.map() to combine the letter with each partial anagram, then Array.reduce() to combine all anagrams in one array. Base cases are for string length equal to 2 or 1.

    const anagrams = str => {
    -  if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str];
    -  return str
    -    .split('')
    -    .reduce(
    -      (acc, letter, i) =>
    -        acc.concat(anagrams(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)),
    -      []
    -    );
    -};
    -
    anagrams('abc'); // ['abc','acb','bac','bca','cab','cba']
    -

    byteSize

    Returns the length of a string in bytes.

    Convert a given string to a Blob Object and find its size.

    const byteSize = str => new Blob([str]).size;
    +

    String

    byteSize

    Returns the length of a string in bytes.

    Convert a given string to a Blob Object and find its size.

    const byteSize = str => new Blob([str]).size;
     
    byteSize('😀'); // 4
     byteSize('Hello World'); // 11
     

    capitalize

    Capitalizes the first letter of a string.

    Use array destructuring and String.toUpperCase() to capitalize first letter, ...rest to get array of characters after first letter and then Array.join('') to make it a string again. Omit the lowerRest parameter to keep the rest of the string intact, or set it to true to convert to lowercase.

    const capitalize = ([first, ...rest], lowerRest = false) =>
    @@ -1567,6 +1603,17 @@ Foo.prototypeShow examples
    isAbsoluteURL('https://google.com'); // true
     isAbsoluteURL('ftp://www.myserver.net'); // true
     isAbsoluteURL('/foo/bar'); // false
    +

    isAnagram

    Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).

    Use String.toLowerCase(), String.replace() with an appropriate regular expression to remove unnecessary characters, String.split(''), Array.sort() and Array.join('') on both strings to normalize them, then check if their normalized forms are equal.

    const isAnagram = (str1, str2) => {
    +  const normalize = str =>
    +    str
    +      .toLowerCase()
    +      .replace(/[^a-z0-9]/gi, '')
    +      .split('')
    +      .sort()
    +      .join('');
    +  return normalize(str1) === normalize(str2);
    +};
    +
    isAnagram('iceman', 'cinema'); // true
     

    isLowerCase

    Checks if a string is lower case.

    Convert the given string to lower case, using String.toLowerCase() and compare it to the original.

    const isLowerCase = str => str === str.toLowerCase();
     
    isLowerCase('abc'); // true
     isLowerCase('a3@$'); // true
    @@ -1580,6 +1627,11 @@ Foo.prototypeShow examples
    mask(1234567890); // '******7890'
     mask(1234567890, 3); // '*******890'
     mask(1234567890, -4, '$'); // '$$$$567890'
    +

    pad

    Pads a string on both sides with the specified character, if it's shorter than the specified length.

    Use String.padStart() and String.padEnd() to pad both sides of the given string. Omit the third argument, char, to use the whitespace character as the default padding character.

    const pad = (str, length, char = ' ') =>
    +  str.padStart((str.length + length) / 2, char).padEnd(length, char);
    +
    pad('cat', 8); // '  cat   '
    +pad(String(42), 6, '0'); // '004200'
    +pad('foobar', 3); // 'foobar'
     

    palindrome

    Returns true if the given string is a palindrome, false otherwise.

    Convert string String.toLowerCase() and use String.replace() to remove non-alphanumeric characters from it. Then, String.split('') into individual characters, Array.reverse(), String.join('') and compare to the original, unreversed string, after converting it String.tolowerCase().

    const palindrome = str => {
       const s = str.toLowerCase().replace(/[\W_]/g, '');
       return (
    @@ -1616,6 +1668,17 @@ Foo.prototypeShow examples
    sortCharactersInString('cabbage'); // 'aabbceg'
     

    splitLines

    Splits a multiline string into an array of lines.

    Use String.split() and a regular expression to match line breaks and create an array.

    const splitLines = str => str.split(/\r?\n/);
     
    splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline', 'string.' , '']
    +

    stringPermutations

    ⚠️ WARNING: This function's execution time increases exponentially with each character. Anything more than 8 to 10 characters will cause your browser to hang as it tries to solve all the different combinations.

    Generates all permutations of a string (contains duplicates).

    Use recursion. For each letter in the given string, create all the partial permutations for the rest of its letters. Use Array.map() to combine the letter with each partial permutation, then Array.reduce() to combine all permutations in one array. Base cases are for string length equal to 2 or 1.

    const stringPermutations = str => {
    +  if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str];
    +  return str
    +    .split('')
    +    .reduce(
    +      (acc, letter, i) =>
    +        acc.concat(stringPermutations(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)),
    +      []
    +    );
    +};
    +
    stringPermutations('abc'); // ['abc','acb','bac','bca','cab','cba']
     

    stripHTMLTags

    Removes HTML/XML tags from string.

    Use a regular expression to remove HTML/XML tags from a string.

    const stripHTMLTags = str => str.replace(/<[^>]*>/g, '');
     
    stripHTMLTags('<p><em>lorem</em> <strong>ipsum</strong></p>'); // 'lorem ipsum'
     

    toCamelCase

    Converts a string to camelcase.

    Break the string into words and combine them capitalizing the first letter of each word, using a regexp.

    const toCamelCase = str => {
    diff --git a/docs/mini.css b/docs/mini.css
    index f986e4ed1..ec1fe96f9 100644
    --- a/docs/mini.css
    +++ b/docs/mini.css
    @@ -1 +1 @@
    -:root{--f-col:#111;--f-col2:#444;--b-col:#f8f8f8;--b-col2:#f0f0f0;--blq-col:#f57c00;--pre-col:#1565c0;--br-col:#aaa;--br-col2:#ddd;--h-ratio:1.19;--u-m:.5rem;--u-p:.5rem;--u-br-r:.125rem;--a-l-col:#0277bd;--a-v-col:#01579b}html{font-size:16px}a,b,del,em,i,ins,q,span,strong,u{font-size:1em}html,*{font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Helvetica, sans-serif;line-height:1.5;-webkit-text-size-adjust:100%}*{font-size:1rem}body{margin:0;color:var(--f-col);background:var(--b-col)}details{display:block}summary{display:list-item}abbr[title]{border-bottom:none;text-decoration:underline dotted}input{overflow:visible}img{max-width:100%;height:auto}h1,h2,h3,h4,h5,h6{line-height:1.2;margin:calc(1.5 * var(--u-m)) var(--u-m);font-weight:500}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{color:var(--f-col2);display:block;margin-top:-.25rem}h1{font-size:calc(1rem * var(--h-ratio) * var(--h-ratio) * var(--h-ratio) * var(--h-ratio))}h2{font-size:calc(1rem * var(--h-ratio) * var(--h-ratio) * var(--h-ratio))}h3{font-size:calc(1rem * var(--h-ratio) * var(--h-ratio))}h4{font-size:calc(1rem * var(--h-ratio))}h5{font-size:1rem}h6{font-size:calc(1rem / var(--h-ratio))}p{margin:var(--u-m)}ol,ul{margin:var(--u-m);padding-left:calc(2 * var(--u-m))}b,strong{font-weight:700}hr{box-sizing:content-box;border:0;line-height:1.25em;margin:var(--u-m);height:.0625rem;background:linear-gradient(to right, transparent, var(--br-col) 20%, var(--br-col) 80%, transparent)}blockquote{display:block;position:relative;font-style:italic;color:var(--f-col2);margin:var(--u-m);padding:calc(3 * var(--u-p));border:.0625rem solid var(--br-col2);border-left:.375rem solid var(--blq-col);border-radius:0 var(--u-br-r) var(--u-br-r) 0}blockquote:before{position:absolute;top:calc(0rem - var(--u-p));left:0;font-family:sans-serif;font-size:3rem;font-weight:700;content:"\201c";color:var(--blq-col)}blockquote[cite]:after{font-style:normal;font-size:.75em;font-weight:700;content:"\a—  " attr(cite);white-space:pre}code,kbd,pre,samp{font-family:Menlo, Consolas, monospace;font-size:.85em}code{background:var(--b-col2);border-radius:var(--u-br-r);padding:calc(var(--u-p) / 4) calc(var(--u-p) / 2)}kbd{background:var(--f-col);color:var(--b-col);border-radius:var(--u-br-r);padding:calc(var(--u-p) / 4) calc(var(--u-p) / 2)}pre{overflow:auto;background:var(--b-col2);padding:calc(1.5 * var(--u-p));margin:var(--u-m);border:.0625rem solid var(--br-col2);border-left:.25rem solid var(--pre-col);border-radius:0 var(--u-br-r) var(--u-br-r) 0}sup,sub,code,kbd{line-height:0;position:relative;vertical-align:baseline}small,sup,sub,figcaption{font-size:.75em}sup{top:-.5em}sub{bottom:-.25em}figure{margin:var(--u-m)}figcaption{color:var(--f-col2)}a{text-decoration:none}a:link{color:var(--a-l-col)}a:visited{color:var(--a-v-col)}a:hover,a:focus{text-decoration:underline}.container{margin:0 auto;padding:0 calc(1.5 * var(--u-p))}.row{box-sizing:border-box;display:flex;flex:0 1 auto;flex-flow:row wrap}.col-sm,[class^='col-sm-'],[class^='col-sm-o-']{flex:0 0 auto;padding:0 calc(var(--u-p) / 2)}.col-sm{max-width:100%;flex-grow:1;flex-basis:0}.col-sm-1{max-width:8.33333%;flex-basis:8.33333%}.col-sm-o-0{margin-left:0}.col-sm-2{max-width:16.66667%;flex-basis:16.66667%}.col-sm-o-1{margin-left:8.33333%}.col-sm-3{max-width:25%;flex-basis:25%}.col-sm-o-2{margin-left:16.66667%}.col-sm-4{max-width:33.33333%;flex-basis:33.33333%}.col-sm-o-3{margin-left:25%}.col-sm-5{max-width:41.66667%;flex-basis:41.66667%}.col-sm-o-4{margin-left:33.33333%}.col-sm-6{max-width:50%;flex-basis:50%}.col-sm-o-5{margin-left:41.66667%}.col-sm-7{max-width:58.33333%;flex-basis:58.33333%}.col-sm-o-6{margin-left:50%}.col-sm-8{max-width:66.66667%;flex-basis:66.66667%}.col-sm-o-7{margin-left:58.33333%}.col-sm-9{max-width:75%;flex-basis:75%}.col-sm-o-8{margin-left:66.66667%}.col-sm-10{max-width:83.33333%;flex-basis:83.33333%}.col-sm-o-9{margin-left:75%}.col-sm-11{max-width:91.66667%;flex-basis:91.66667%}.col-sm-o-10{margin-left:83.33333%}.col-sm-12{max-width:100%;flex-basis:100%}.col-sm-o-11{margin-left:91.66667%}.col-sm-n{order:initial}.col-sm-f{order:-999}.col-sm-l{order:999}@media screen and (min-width: 768px){.col-md,[class^='col-md-'],[class^='col-md-o-']{flex:0 0 auto;padding:0 calc(var(--u-p) / 2)}.col-md{max-width:100%;flex-grow:1;flex-basis:0}.col-md-1{max-width:8.33333%;flex-basis:8.33333%}.col-md-o-0{margin-left:0}.col-md-2{max-width:16.66667%;flex-basis:16.66667%}.col-md-o-1{margin-left:8.33333%}.col-md-3{max-width:25%;flex-basis:25%}.col-md-o-2{margin-left:16.66667%}.col-md-4{max-width:33.33333%;flex-basis:33.33333%}.col-md-o-3{margin-left:25%}.col-md-5{max-width:41.66667%;flex-basis:41.66667%}.col-md-o-4{margin-left:33.33333%}.col-md-6{max-width:50%;flex-basis:50%}.col-md-o-5{margin-left:41.66667%}.col-md-7{max-width:58.33333%;flex-basis:58.33333%}.col-md-o-6{margin-left:50%}.col-md-8{max-width:66.66667%;flex-basis:66.66667%}.col-md-o-7{margin-left:58.33333%}.col-md-9{max-width:75%;flex-basis:75%}.col-md-o-8{margin-left:66.66667%}.col-md-10{max-width:83.33333%;flex-basis:83.33333%}.col-md-o-9{margin-left:75%}.col-md-11{max-width:91.66667%;flex-basis:91.66667%}.col-md-o-10{margin-left:83.33333%}.col-md-12{max-width:100%;flex-basis:100%}.col-md-o-11{margin-left:91.66667%}.col-md-n{order:initial}.col-md-f{order:-999}.col-md-l{order:999}}@media screen and (min-width: 1280px){.col-lg,[class^='col-lg-'],[class^='col-lg-o-']{flex:0 0 auto;padding:0 calc(var(--u-p) / 2)}.col-lg{max-width:100%;flex-grow:1;flex-basis:0}.col-lg-1{max-width:8.33333%;flex-basis:8.33333%}.col-lg-o-0{margin-left:0}.col-lg-2{max-width:16.66667%;flex-basis:16.66667%}.col-lg-o-1{margin-left:8.33333%}.col-lg-3{max-width:25%;flex-basis:25%}.col-lg-o-2{margin-left:16.66667%}.col-lg-4{max-width:33.33333%;flex-basis:33.33333%}.col-lg-o-3{margin-left:25%}.col-lg-5{max-width:41.66667%;flex-basis:41.66667%}.col-lg-o-4{margin-left:33.33333%}.col-lg-6{max-width:50%;flex-basis:50%}.col-lg-o-5{margin-left:41.66667%}.col-lg-7{max-width:58.33333%;flex-basis:58.33333%}.col-lg-o-6{margin-left:50%}.col-lg-8{max-width:66.66667%;flex-basis:66.66667%}.col-lg-o-7{margin-left:58.33333%}.col-lg-9{max-width:75%;flex-basis:75%}.col-lg-o-8{margin-left:66.66667%}.col-lg-10{max-width:83.33333%;flex-basis:83.33333%}.col-lg-o-9{margin-left:75%}.col-lg-11{max-width:91.66667%;flex-basis:91.66667%}.col-lg-o-10{margin-left:83.33333%}.col-lg-12{max-width:100%;flex-basis:100%}.col-lg-o-11{margin-left:91.66667%}.col-lg-n{order:initial}.col-lg-f{order:-999}.col-lg-l{order:999}}:root{--cd-b-col:#f8f8f8;--cd-f-col:#111;--cd-br-col:#ddd}.card{display:flex;flex-direction:column;justify-content:space-between;align-self:center;position:relative;width:100%;background:var(--cd-b-col);color:var(--cd-f-col);border:.0625rem solid var(--cd-br-col);border-radius:var(--u-br-r);margin:var(--u-m);overflow:hidden}@media screen and (min-width: 320px){.card{max-width:320px}}.card>.section{background:var(--cd-b-col);color:var(--cd-f-col);box-sizing:border-box;margin:0;border:0;border-radius:0;border-bottom:.0625rem solid var(--cd-br-col);padding:var(--u-p);width:100%}.card>.section.media{height:200px;padding:0;-o-object-fit:cover;object-fit:cover}.card>.section:last-child{border-bottom:0}.card.fluid{max-width:100%;width:auto}.card>.section.double-padded{padding:calc(1.5 * var(--u-p))}.card{box-shadow:0 1.25rem 2.5rem -0.625rem rgba(0,32,64,0.1)}.card>h3.section.double-padded{padding:calc(3 * var(--u-p))}.card>.section.double-padded>p{margin:var(--u-m) calc(var(--u-m) / 2)}.card+.card{margin-top:calc(5 * var(--u-m))}:root{--frm-b-col:#f0f0f0;--frm-f-col:#111;--frm-br-col:#ddd;--in-b-col:#f8f8f8;--in-f-col:#111;--in-br-col:#ddd;--in-fc-col:#0288d1;--in-inv-col:#d32f2f;--btn-b-col:#e2e2e2;--btn-h-b-col:#dcdcdc;--btn-f-col:#212121;--btn-br-col:transparent;--btn-h-br-col:transparent;--btn-grp-br-col:rgba(124,124,124,0.54)}form{background:var(--frm-b-col);color:var(--frm-f-col);border:.0625rem solid var(--frm-br-col);border-radius:var(--u-br-r);margin:var(--u-m);padding:calc(2 * var(--u-p)) var(--u-p)}fieldset{border:.0625rem solid var(--frm-br-col);border-radius:var(--u-br-r);margin:calc(var(--u-m) / 4);padding:var(--u-p)}legend{box-sizing:border-box;display:table;max-width:100%;white-space:normal;font-weight:700;padding:calc(var(--u-p) / 2)}label{padding:calc(var(--u-p) / 2) var(--u-p)}.input-group{display:inline-block}[type="number"]::-webkit-inner-spin-button,[type="number"]::-webkit-outer-spin-button{height:auto}[type="search"]{-webkit-appearance:textfield;outline-offset:-2px}[type="search"]::-webkit-search-cancel-button,[type="search"]::-webkit-search-decoration{-webkit-appearance:none}input:not([type]),[type="text"],[type="email"],[type="number"],[type="search"],[type="password"],[type="url"],[type="tel"],[type="checkbox"],[type="radio"],textarea,select{box-sizing:border-box;background:var(--in-b-col);color:var(--in-f-col);border:.0625rem solid var(--in-br-col);border-radius:var(--u-br-r);margin:calc(var(--u-m) / 2);padding:var(--u-p) calc(1.5 * var(--u-p))}input:not([type="button"]):not([type="submit"]):not([type="reset"]):hover,input:not([type="button"]):not([type="submit"]):not([type="reset"]):focus,textarea:hover,textarea:focus,select:hover,select:focus{border-color:var(--in-fc-col);box-shadow:none}input:not([type="button"]):not([type="submit"]):not([type="reset"]):invalid,input:not([type="button"]):not([type="submit"]):not([type="reset"]):focus:invalid,textarea:invalid,textarea:focus:invalid,select:invalid,select:focus:invalid{border-color:var(--in-inv-col);box-shadow:none}input:not([type="button"]):not([type="submit"]):not([type="reset"])[readonly],textarea[readonly],select[readonly]{background:var(--b-col2)}select{max-width:100%}option{overflow:hidden;text-overflow:ellipsis}[type="checkbox"],[type="radio"]{-webkit-appearance:none;-moz-appearance:none;appearance:none;position:relative;height:calc(1rem + var(--u-p) / 2);width:calc(1rem + var(--u-p) / 2);vertical-align:text-bottom;padding:0;flex-basis:calc(1rem + var(--u-p) / 2) !important;flex-grow:0 !important}[type="checkbox"]:checked:before,[type="radio"]:checked:before{position:absolute}[type="checkbox"]:checked:before{content:'\2713';font-family:sans-serif;font-size:calc(1rem + var(--u-p) / 2);top:calc(0rem - var(--u-p));left:calc(var(--u-p) / 4)}[type="radio"]{border-radius:100%}[type="radio"]:checked:before{border-radius:100%;content:'';top:calc(.0625rem + var(--u-p) / 2);left:calc(.0625rem + var(--u-p) / 2);background:var(--in-f-col);width:0.5rem;height:0.5rem}:placeholder-shown{color:var(--in-f-col)}::-ms-placeholder{color:var(--in-f-col);opacity:0.54}button::-moz-focus-inner,[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner{border-style:none;padding:0}button,html [type="button"],[type="reset"],[type="submit"]{-webkit-appearance:button}button{overflow:visible;text-transform:none}button,[type="button"],[type="submit"],[type="reset"],a.button,label.button,.button,a[role="button"],label[role="button"],[role="button"]{display:inline-block;background:var(--btn-b-col);color:var(--btn-f-col);border:.0625rem solid var(--btn-br-col);border-radius:var(--u-br-r);padding:var(--u-p) calc(1.5 * var(--u-p));margin:var(--u-m);text-decoration:none;cursor:pointer;transition:background 0.3s}button:hover,button:focus,[type="button"]:hover,[type="button"]:focus,[type="submit"]:hover,[type="submit"]:focus,[type="reset"]:hover,[type="reset"]:focus,a.button:hover,a.button:focus,label.button:hover,label.button:focus,.button:hover,.button:focus,a[role="button"]:hover,a[role="button"]:focus,label[role="button"]:hover,label[role="button"]:focus,[role="button"]:hover,[role="button"]:focus{background:var(--btn-h-b-col);border-color:var(--btn-h-br-col)}input:disabled,input[disabled],textarea:disabled,textarea[disabled],select:disabled,select[disabled],button:disabled,button[disabled],.button:disabled,.button[disabled],[role="button"]:disabled,[role="button"][disabled]{cursor:not-allowed;opacity:.75}.button-group{display:flex;border:.0625rem solid var(--btn-grp-br-col);border-radius:var(--u-br-r);margin:var(--u-m)}.button-group>button,.button-group [type="button"],.button-group>[type="submit"],.button-group>[type="reset"],.button-group>.button,.button-group>[role="button"]{margin:0;max-width:100%;flex:1 1 auto;text-align:center;border:0;border-radius:0;box-shadow:none}.button-group>:not(:first-child){border-left:.0625rem solid var(--btn-grp-br-col)}@media screen and (max-width: 767px){.button-group{flex-direction:column}.button-group>:not(:first-child){border:0;border-top:.0625rem solid var(--btn-grp-br-col)}}button.primary,[type="button"].primary,[type="submit"].primary,[type="reset"].primary,.button.primary,[role="button"].primary{--btn-b-col:#1976d2;--btn-f-col:#f8f8f8}button.primary:hover,button.primary:focus,[type="button"].primary:hover,[type="button"].primary:focus,[type="submit"].primary:hover,[type="submit"].primary:focus,[type="reset"].primary:hover,[type="reset"].primary:focus,.button.primary:hover,.button.primary:focus,[role="button"].primary:hover,[role="button"].primary:focus{--btn-h-b-col:#1565c0}:root{--hd-b-col:#f8f8f8;--hd-hv-b-col:#f0f0f0;--hd-f-col:#444;--hd-br-col:#ddd;--nv-b-col:#f8f8f8;--nv-hv-b-col:#f0f0f0;--nv-f-col:#444;--nv-br-col:#ddd;--nv-ln-col:#0277bd;--ft-f-col:#444;--ft-b-col:#f8f8f8;--ft-br-col:#ddd;--ft-ln-col:#0277bd;--dr-b-col:#f8f8f8;--dr-hv-b-col:#f0f0f0;--dr-br-col:#ddd;--dr-cl-col:#444}header{height:3.1875rem;background:var(--hd-b-col);color:var(--hd-f-col);border-bottom:.0625rem solid var(--hd-br-col);padding:calc(var(--u-p) / 4) 0;white-space:nowrap;overflow-x:auto;overflow-y:hidden}header.row{box-sizing:content-box}header .logo{color:var(--hd-f-col);font-size:1.75rem;padding:var(--u-p) calc(2 * var(--u-p));text-decoration:none}header button,header [type="button"],header .button,header [role="button"]{box-sizing:border-box;position:relative;top:calc(0rem - var(--u-p) / 4);height:calc(3.1875rem + var(--u-p) / 2);background:var(--hd-b-col);line-height:calc(3.1875rem - var(--u-p) * 1.5);text-align:center;color:var(--hd-f-col);border:0;border-radius:0;margin:0;text-transform:uppercase}header button:hover,header button:focus,header [type="button"]:hover,header [type="button"]:focus,header .button:hover,header .button:focus,header [role="button"]:hover,header [role="button"]:focus{background:var(--hd-hv-b-col)}nav{background:var(--nv-b-col);color:var(--nv-f-col);border:.0625rem solid var(--nv-br-col);border-radius:var(--u-br-r);margin:var(--u-m)}nav *{padding:var(--u-p) calc(1.5 * var(--u-p))}nav a,nav a:visited{display:block;color:var(--nv-ln-col);border-radius:var(--u-br-r);transition:background 0.3s}nav a:hover,nav a:focus,nav a:visited:hover,nav a:visited:focus{text-decoration:none;background:var(--nv-hv-b-col)}nav .sublink-1{position:relative;margin-left:calc(2 * var(--u-p))}nav .sublink-1:before{position:absolute;left:calc(var(--u-p) - 1 * var(--u-p));top:-.0625rem;content:'';height:100%;border:.0625rem solid var(--nv-br-col);border-left:0}footer{background:var(--ft-b-col);color:var(--ft-f-col);border-top:.0625rem solid var(--ft-br-col);padding:calc(2 * var(--u-p)) var(--u-p);font-size:.875rem}footer a,footer a:visited{color:var(--ft-ln-col)}header.sticky{position:-webkit-sticky;position:sticky;z-index:1101;top:0}footer.sticky{position:-webkit-sticky;position:sticky;z-index:1101;bottom:0}.drawer-toggle:before{display:inline-block;position:relative;vertical-align:bottom;content:'\00a0\2261\00a0';font-family:sans-serif;font-size:1.5em}@media screen and (min-width: 768px){.drawer-toggle:not(.persistent){display:none}}[type="checkbox"].drawer{height:1px;width:1px;margin:-1px;overflow:hidden;position:absolute;clip:rect(0 0 0 0);-webkit-clip-path:inset(100%);clip-path:inset(100%)}[type="checkbox"].drawer+*{display:block;box-sizing:border-box;position:fixed;top:0;width:320px;height:100vh;overflow-y:auto;background:var(--dr-b-col);border:.0625rem solid var(--dr-br-col);border-radius:0;margin:0;z-index:1110;left:-320px;transition:left 0.3s}[type="checkbox"].drawer+* .drawer-close{position:absolute;top:var(--u-m);right:var(--u-m);z-index:1111;width:2rem;height:2rem;border-radius:var(--u-br-r);padding:var(--u-p);margin:0;cursor:pointer;transition:background 0.3s}[type="checkbox"].drawer+* .drawer-close:before{display:block;content:'\00D7';color:var(--dr-cl-col);position:relative;font-family:sans-serif;font-size:2rem;line-height:1;text-align:center}[type="checkbox"].drawer+* .drawer-close:hover,[type="checkbox"].drawer+* .drawer-close:focus{background:var(--dr-hv-b-col)}@media screen and (max-width: 320px){[type="checkbox"].drawer+*{width:100%}}[type="checkbox"].drawer:checked+*{left:0}@media screen and (min-width: 768px){[type="checkbox"].drawer:not(.persistent)+*{position:static;height:100%;z-index:1100}[type="checkbox"].drawer:not(.persistent)+* .drawer-close{display:none}}:root{--mrk-b-col:#424242;--mrk-f-col:#fafafa}mark{background:var(--mrk-b-col);color:var(--mrk-f-col);font-size:.5em;line-height:1em;border-radius:var(--u-br-r);padding:calc(var(--u-p) / 4) calc(var(--u-p) / 2)}mark.inline-block{display:inline-block;font-size:1em;line-height:1.5;padding:calc(var(--u-p) / 2) var(--u-p)}:root{--tst-b-col:#212121;--tst-f-col:#fafafa}.toast{position:fixed;bottom:calc(var(--u-m) * 3);left:50%;transform:translate(-50%, -50%);z-index:1111;color:var(--tst-f-col);background:var(--tst-b-col);border-radius:calc(var(--u-br-r) * 16);padding:var(--u-p) calc(var(--u-p) * 3)}.toast{bottom:calc(var(--u-m) / 2);opacity:1;transition:opacity 0.3s ease-in-out}mark{position:relative;top:-0.25rem;left:0.25rem}mark.secondary{--mrk-b-col:#d32f2f}mark.tertiary{--mrk-b-col:#308732}mark.tag{padding:calc(var(--u-p)/2) var(--u-p);border-radius:1em}code,pre,kbd,code *,pre *,kbd *,code[class*="language-"],pre[class*="language-"]{font-family:Menlo, Consolas, monospace !important}pre{border:0.0625rem solid var(--br-col2);border-radius:var(--u-br-r)}.group{position:relative;margin-top:2em;margin-bottom:1em}.search{font-size:0.875rem;margin-top:-0.1em;display:block;width:100%;border:none;border-bottom:.0625rem solid var(--nv-ln-col)}.search:focus{outline:none}label#search-label{color:var(--nv-ln-col);font-size:1.125rem;font-weight:400;position:absolute;left:0.3125rem;top:0.625rem}.search:focus ~ label#search-label,.search:valid ~ label#search-label{top:-1.25rem;font-size:0.875rem;color:var(--nv-ln-col)}label#menu-toggle{width:3.4375rem}header h1.logo{margin-top:-0.8rem;text-align:center}header h1.logo a{text-decoration:none;color:#111}header #title{position:relative;top:-1rem}@media screen and (max-width: 500px){header #title{font-size:1rem;display:block}}header h1 small{display:block;font-size:0.875rem;color:#888;margin-top:-0.8rem}@media screen and (max-width: 768px){header h1 small{font-size:0.75rem}}@media screen and (max-width: 600px){header h1 small{font-size:0.625rem}}@media screen and (max-width: 500px){header h1 small{font-size:0.5rem;margin-top:-1.2rem}}label#menu-toggle{position:absolute;left:0.5rem;top:0.5rem;width:3.4375rem}main{padding:0}:root{--clps-lbl-b-col:#e8e8e8;--clps-lbl-f-col:#212121;--clps-lbl-h-b-col:#f0f0f0;--clps-sel-lbl-b-col:#ececec;--clps-br-col:#ddd;--clps-cnt-b-col:#fafafa;--clps-sel-lbl-br-col:#0277bd}label.collapse{width:100%;display:inline-block;cursor:pointer;box-sizing:border-box;transition:background 0.3s;color:var(--clps-lbl-f-col);background:var(--clps-lbl-b-col);border:.0625rem solid var(--clps-br-col);padding:calc(1.5 * var(--u-p));border-radius:var(--u-br-r)}label.collapse:hover,label.collapse:focus{background:var(--clps-lbl-h-b-col)}label.collapse+pre{box-sizing:border-box;height:0;max-height:1px;overflow:auto;margin:0;border:0;padding:0;transition:max-height 0.3s}label.collapse.toggled{background:var(--clps-sel-lbl-b-col);border-bottom-color:var(--clps-sel-lbl-br-col);border-bottom-left-radius:0;border-bottom-right-radius:0}label.collapse.toggled+pre{border-top-left-radius:0;border-top-right-radius:0;position:relative;width:100%;height:auto;border:.0625rem solid var(--clps-br-col);border-top:0;padding:calc(2 * var(--u-p));max-height:400px}button.primary.clipboard-copy{width:100%;margin-left:0}button.primary.clipboard-copy>img{vertical-align:bottom}code[class*="language-"],pre[class*="language-"]{color:#222;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.8;-moz-tab-size:2;-o-tab-size:2;tab-size:2;-webkit-hypens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*="language-"]{padding:calc(2 * var(--u-p));overflow:auto;margin:var(--u-m) 0}pre[class*="language-"]::-moz-selection,pre[class*="language-"] ::-moz-selection,code[class*="language-"]::-moz-selection,code[class*="language-"] ::-moz-selection{background:#b3d4fc}pre[class*="language-"]::selection,pre[class*="language-"] ::selection,code[class*="language-"]::selection,code[class*="language-"] ::selection{background:#b3d4fc}:not(pre)>code[class*="language-"]{padding:.1em;border-radius:.3em;white-space:normal}.token.comment,.token.prolog,.token.doctype,.token.cdata{color:#7a8490}.token.punctuation{color:#666}.namespace{opacity:.7}.token.property,.token.tag,.token.boolean,.token.constant,.token.symbol,.token.deleted,.token.function{color:#005cc5}.token.number,.token.class-name{color:#832ed2}.token.selector,.token.attr-name,.token.string,.token.char,.token.builtin,.token.inserted{color:#067e36}.token.operator,.token.entity,.token.url,.language-css .token.string,.style .token.string,.token.atrule,.token.attr-value,.token.keyword{color:#d73a49}.token.regex{color:#097cab}.token.important,.token.variable{color:#e90}.token.important,.token.bold{font-weight:bold}.token.italic{font-style:italic}.token.entity{cursor:help}button.scroll-to-top{border-radius:100%;font-size:1.5rem;line-height:1;box-sizing:border-box;width:2.75rem;height:2.75rem;position:fixed;bottom:1rem;right:2rem;background:var(--b-col);box-shadow:0 0.25rem 0.25rem 0 rgba(0,0,0,0.125),0 0.125rem 0.125rem -0.125rem rgba(0,0,0,0.25)}button.scroll-to-top:hover,button.scroll-to-top:focus{background:var(--b-col2)}
    +:root{--f-col:#111;--f-col2:#444;--b-col:#f8f8f8;--b-col2:#f0f0f0;--blq-col:#f57c00;--pre-col:#1565c0;--br-col:#aaa;--br-col2:#ddd;--h-ratio:1.19;--u-m:.5rem;--u-p:.5rem;--u-br-r:.125rem;--a-l-col:#0277bd;--a-v-col:#01579b}html{font-size:16px}a,b,del,em,i,ins,q,span,strong,u{font-size:1em}html,*{font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Helvetica, sans-serif;line-height:1.5;-webkit-text-size-adjust:100%}*{font-size:1rem}body{margin:0;color:var(--f-col);background:var(--b-col)}details{display:block}summary{display:list-item}abbr[title]{border-bottom:none;text-decoration:underline dotted}input{overflow:visible}img{max-width:100%;height:auto}h1,h2,h3,h4,h5,h6{line-height:1.2;margin:calc(1.5 * var(--u-m)) var(--u-m);font-weight:500}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{color:var(--f-col2);display:block;margin-top:-.25rem}h1{font-size:calc(1rem * var(--h-ratio) * var(--h-ratio) * var(--h-ratio) * var(--h-ratio))}h2{font-size:calc(1rem * var(--h-ratio) * var(--h-ratio) * var(--h-ratio))}h3{font-size:calc(1rem * var(--h-ratio) * var(--h-ratio))}h4{font-size:calc(1rem * var(--h-ratio))}h5{font-size:1rem}h6{font-size:calc(1rem / var(--h-ratio))}p{margin:var(--u-m)}ol,ul{margin:var(--u-m);padding-left:calc(2 * var(--u-m))}b,strong{font-weight:700}hr{box-sizing:content-box;border:0;line-height:1.25em;margin:var(--u-m);height:.0625rem;background:linear-gradient(to right, transparent, var(--br-col) 20%, var(--br-col) 80%, transparent)}blockquote{display:block;position:relative;font-style:italic;color:var(--f-col2);margin:var(--u-m);padding:calc(3 * var(--u-p));border:.0625rem solid var(--br-col2);border-left:.375rem solid var(--blq-col);border-radius:0 var(--u-br-r) var(--u-br-r) 0}blockquote:before{position:absolute;top:calc(0rem - var(--u-p));left:0;font-family:sans-serif;font-size:3rem;font-weight:700;content:"\201c";color:var(--blq-col)}blockquote[cite]:after{font-style:normal;font-size:.75em;font-weight:700;content:"\a—  " attr(cite);white-space:pre}code,kbd,pre,samp{font-family:Menlo, Consolas, monospace;font-size:.85em}code{background:var(--b-col2);border-radius:var(--u-br-r);padding:calc(var(--u-p) / 4) calc(var(--u-p) / 2)}kbd{background:var(--f-col);color:var(--b-col);border-radius:var(--u-br-r);padding:calc(var(--u-p) / 4) calc(var(--u-p) / 2)}pre{overflow:auto;background:var(--b-col2);padding:calc(1.5 * var(--u-p));margin:var(--u-m);border:.0625rem solid var(--br-col2);border-left:.25rem solid var(--pre-col);border-radius:0 var(--u-br-r) var(--u-br-r) 0}sup,sub,code,kbd{line-height:0;position:relative;vertical-align:baseline}small,sup,sub,figcaption{font-size:.75em}sup{top:-.5em}sub{bottom:-.25em}figure{margin:var(--u-m)}figcaption{color:var(--f-col2)}a{text-decoration:none}a:link{color:var(--a-l-col)}a:visited{color:var(--a-v-col)}a:hover,a:focus{text-decoration:underline}.container{margin:0 auto;padding:0 calc(1.5 * var(--u-p))}.row{box-sizing:border-box;display:flex;flex:0 1 auto;flex-flow:row wrap}.col-sm,[class^='col-sm-'],[class^='col-sm-o-']{flex:0 0 auto;padding:0 calc(var(--u-p) / 2)}.col-sm{max-width:100%;flex-grow:1;flex-basis:0}.col-sm-1{max-width:8.33333%;flex-basis:8.33333%}.col-sm-o-0{margin-left:0}.col-sm-2{max-width:16.66667%;flex-basis:16.66667%}.col-sm-o-1{margin-left:8.33333%}.col-sm-3{max-width:25%;flex-basis:25%}.col-sm-o-2{margin-left:16.66667%}.col-sm-4{max-width:33.33333%;flex-basis:33.33333%}.col-sm-o-3{margin-left:25%}.col-sm-5{max-width:41.66667%;flex-basis:41.66667%}.col-sm-o-4{margin-left:33.33333%}.col-sm-6{max-width:50%;flex-basis:50%}.col-sm-o-5{margin-left:41.66667%}.col-sm-7{max-width:58.33333%;flex-basis:58.33333%}.col-sm-o-6{margin-left:50%}.col-sm-8{max-width:66.66667%;flex-basis:66.66667%}.col-sm-o-7{margin-left:58.33333%}.col-sm-9{max-width:75%;flex-basis:75%}.col-sm-o-8{margin-left:66.66667%}.col-sm-10{max-width:83.33333%;flex-basis:83.33333%}.col-sm-o-9{margin-left:75%}.col-sm-11{max-width:91.66667%;flex-basis:91.66667%}.col-sm-o-10{margin-left:83.33333%}.col-sm-12{max-width:100%;flex-basis:100%}.col-sm-o-11{margin-left:91.66667%}.col-sm-n{order:initial}.col-sm-f{order:-999}.col-sm-l{order:999}@media screen and (min-width: 768px){.col-md,[class^='col-md-'],[class^='col-md-o-']{flex:0 0 auto;padding:0 calc(var(--u-p) / 2)}.col-md{max-width:100%;flex-grow:1;flex-basis:0}.col-md-1{max-width:8.33333%;flex-basis:8.33333%}.col-md-o-0{margin-left:0}.col-md-2{max-width:16.66667%;flex-basis:16.66667%}.col-md-o-1{margin-left:8.33333%}.col-md-3{max-width:25%;flex-basis:25%}.col-md-o-2{margin-left:16.66667%}.col-md-4{max-width:33.33333%;flex-basis:33.33333%}.col-md-o-3{margin-left:25%}.col-md-5{max-width:41.66667%;flex-basis:41.66667%}.col-md-o-4{margin-left:33.33333%}.col-md-6{max-width:50%;flex-basis:50%}.col-md-o-5{margin-left:41.66667%}.col-md-7{max-width:58.33333%;flex-basis:58.33333%}.col-md-o-6{margin-left:50%}.col-md-8{max-width:66.66667%;flex-basis:66.66667%}.col-md-o-7{margin-left:58.33333%}.col-md-9{max-width:75%;flex-basis:75%}.col-md-o-8{margin-left:66.66667%}.col-md-10{max-width:83.33333%;flex-basis:83.33333%}.col-md-o-9{margin-left:75%}.col-md-11{max-width:91.66667%;flex-basis:91.66667%}.col-md-o-10{margin-left:83.33333%}.col-md-12{max-width:100%;flex-basis:100%}.col-md-o-11{margin-left:91.66667%}.col-md-n{order:initial}.col-md-f{order:-999}.col-md-l{order:999}}@media screen and (min-width: 1280px){.col-lg,[class^='col-lg-'],[class^='col-lg-o-']{flex:0 0 auto;padding:0 calc(var(--u-p) / 2)}.col-lg{max-width:100%;flex-grow:1;flex-basis:0}.col-lg-1{max-width:8.33333%;flex-basis:8.33333%}.col-lg-o-0{margin-left:0}.col-lg-2{max-width:16.66667%;flex-basis:16.66667%}.col-lg-o-1{margin-left:8.33333%}.col-lg-3{max-width:25%;flex-basis:25%}.col-lg-o-2{margin-left:16.66667%}.col-lg-4{max-width:33.33333%;flex-basis:33.33333%}.col-lg-o-3{margin-left:25%}.col-lg-5{max-width:41.66667%;flex-basis:41.66667%}.col-lg-o-4{margin-left:33.33333%}.col-lg-6{max-width:50%;flex-basis:50%}.col-lg-o-5{margin-left:41.66667%}.col-lg-7{max-width:58.33333%;flex-basis:58.33333%}.col-lg-o-6{margin-left:50%}.col-lg-8{max-width:66.66667%;flex-basis:66.66667%}.col-lg-o-7{margin-left:58.33333%}.col-lg-9{max-width:75%;flex-basis:75%}.col-lg-o-8{margin-left:66.66667%}.col-lg-10{max-width:83.33333%;flex-basis:83.33333%}.col-lg-o-9{margin-left:75%}.col-lg-11{max-width:91.66667%;flex-basis:91.66667%}.col-lg-o-10{margin-left:83.33333%}.col-lg-12{max-width:100%;flex-basis:100%}.col-lg-o-11{margin-left:91.66667%}.col-lg-n{order:initial}.col-lg-f{order:-999}.col-lg-l{order:999}}:root{--cd-b-col:#f8f8f8;--cd-f-col:#111;--cd-br-col:#ddd}.card{display:flex;flex-direction:column;justify-content:space-between;align-self:center;position:relative;width:100%;background:var(--cd-b-col);color:var(--cd-f-col);border:.0625rem solid var(--cd-br-col);border-radius:var(--u-br-r);margin:var(--u-m);overflow:hidden}@media screen and (min-width: 320px){.card{max-width:320px}}.card>.section{background:var(--cd-b-col);color:var(--cd-f-col);box-sizing:border-box;margin:0;border:0;border-radius:0;border-bottom:.0625rem solid var(--cd-br-col);padding:var(--u-p);width:100%}.card>.section.media{height:200px;padding:0;-o-object-fit:cover;object-fit:cover}.card>.section:last-child{border-bottom:0}.card.fluid{max-width:100%;width:auto}.card>.section.double-padded{padding:calc(1.5 * var(--u-p))}.card{box-shadow:0 1.25rem 2.5rem -0.625rem rgba(0,32,64,0.1)}.card>h3.section.double-padded{padding:calc(3 * var(--u-p))}.card>.section.double-padded>p{margin:var(--u-m) calc(var(--u-m) / 2)}.card+.card{margin-top:calc(5 * var(--u-m))}:root{--frm-b-col:#f0f0f0;--frm-f-col:#111;--frm-br-col:#ddd;--in-b-col:#f8f8f8;--in-f-col:#111;--in-br-col:#ddd;--in-fc-col:#0288d1;--in-inv-col:#d32f2f;--btn-b-col:#e2e2e2;--btn-h-b-col:#dcdcdc;--btn-f-col:#212121;--btn-br-col:transparent;--btn-h-br-col:transparent;--btn-grp-br-col:rgba(124,124,124,0.54)}form{background:var(--frm-b-col);color:var(--frm-f-col);border:.0625rem solid var(--frm-br-col);border-radius:var(--u-br-r);margin:var(--u-m);padding:calc(2 * var(--u-p)) var(--u-p)}fieldset{border:.0625rem solid var(--frm-br-col);border-radius:var(--u-br-r);margin:calc(var(--u-m) / 4);padding:var(--u-p)}legend{box-sizing:border-box;display:table;max-width:100%;white-space:normal;font-weight:700;padding:calc(var(--u-p) / 2)}label{padding:calc(var(--u-p) / 2) var(--u-p)}.input-group{display:inline-block}.input-group.fluid{display:flex;align-items:center;justify-content:center}.input-group.fluid>input{max-width:100%;flex-grow:1;flex-basis:0px}@media screen and (max-width: 767px){.input-group.fluid{align-items:stretch;flex-direction:column}}.input-group.vertical{display:flex;align-items:stretch;flex-direction:column}.input-group.vertical>input{max-width:100%;flex-grow:1;flex-basis:0px}[type="number"]::-webkit-inner-spin-button,[type="number"]::-webkit-outer-spin-button{height:auto}[type="search"]{-webkit-appearance:textfield;outline-offset:-2px}[type="search"]::-webkit-search-cancel-button,[type="search"]::-webkit-search-decoration{-webkit-appearance:none}input:not([type]),[type="text"],[type="email"],[type="number"],[type="search"],[type="password"],[type="url"],[type="tel"],[type="checkbox"],[type="radio"],textarea,select{box-sizing:border-box;background:var(--in-b-col);color:var(--in-f-col);border:.0625rem solid var(--in-br-col);border-radius:var(--u-br-r);margin:calc(var(--u-m) / 2);padding:var(--u-p) calc(1.5 * var(--u-p))}input:not([type="button"]):not([type="submit"]):not([type="reset"]):hover,input:not([type="button"]):not([type="submit"]):not([type="reset"]):focus,textarea:hover,textarea:focus,select:hover,select:focus{border-color:var(--in-fc-col);box-shadow:none}input:not([type="button"]):not([type="submit"]):not([type="reset"]):invalid,input:not([type="button"]):not([type="submit"]):not([type="reset"]):focus:invalid,textarea:invalid,textarea:focus:invalid,select:invalid,select:focus:invalid{border-color:var(--in-inv-col);box-shadow:none}input:not([type="button"]):not([type="submit"]):not([type="reset"])[readonly],textarea[readonly],select[readonly]{background:var(--b-col2)}select{max-width:100%}option{overflow:hidden;text-overflow:ellipsis}[type="checkbox"],[type="radio"]{-webkit-appearance:none;-moz-appearance:none;appearance:none;position:relative;height:calc(1rem + var(--u-p) / 2);width:calc(1rem + var(--u-p) / 2);vertical-align:text-bottom;padding:0;flex-basis:calc(1rem + var(--u-p) / 2) !important;flex-grow:0 !important}[type="checkbox"]:checked:before,[type="radio"]:checked:before{position:absolute}[type="checkbox"]:checked:before{content:'\2713';font-family:sans-serif;font-size:calc(1rem + var(--u-p) / 2);top:calc(0rem - var(--u-p));left:calc(var(--u-p) / 4)}[type="radio"]{border-radius:100%}[type="radio"]:checked:before{border-radius:100%;content:'';top:calc(.0625rem + var(--u-p) / 2);left:calc(.0625rem + var(--u-p) / 2);background:var(--in-f-col);width:0.5rem;height:0.5rem}:placeholder-shown{color:var(--in-f-col)}::-ms-placeholder{color:var(--in-f-col);opacity:0.54}button::-moz-focus-inner,[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner{border-style:none;padding:0}button,html [type="button"],[type="reset"],[type="submit"]{-webkit-appearance:button}button{overflow:visible;text-transform:none}button,[type="button"],[type="submit"],[type="reset"],a.button,label.button,.button,a[role="button"],label[role="button"],[role="button"]{display:inline-block;background:var(--btn-b-col);color:var(--btn-f-col);border:.0625rem solid var(--btn-br-col);border-radius:var(--u-br-r);padding:var(--u-p) calc(1.5 * var(--u-p));margin:var(--u-m);text-decoration:none;cursor:pointer;transition:background 0.3s}button:hover,button:focus,[type="button"]:hover,[type="button"]:focus,[type="submit"]:hover,[type="submit"]:focus,[type="reset"]:hover,[type="reset"]:focus,a.button:hover,a.button:focus,label.button:hover,label.button:focus,.button:hover,.button:focus,a[role="button"]:hover,a[role="button"]:focus,label[role="button"]:hover,label[role="button"]:focus,[role="button"]:hover,[role="button"]:focus{background:var(--btn-h-b-col);border-color:var(--btn-h-br-col)}input:disabled,input[disabled],textarea:disabled,textarea[disabled],select:disabled,select[disabled],button:disabled,button[disabled],.button:disabled,.button[disabled],[role="button"]:disabled,[role="button"][disabled]{cursor:not-allowed;opacity:.75}.button-group{display:flex;border:.0625rem solid var(--btn-grp-br-col);border-radius:var(--u-br-r);margin:var(--u-m)}.button-group>button,.button-group [type="button"],.button-group>[type="submit"],.button-group>[type="reset"],.button-group>.button,.button-group>[role="button"]{margin:0;max-width:100%;flex:1 1 auto;text-align:center;border:0;border-radius:0;box-shadow:none}.button-group>:not(:first-child){border-left:.0625rem solid var(--btn-grp-br-col)}@media screen and (max-width: 767px){.button-group{flex-direction:column}.button-group>:not(:first-child){border:0;border-top:.0625rem solid var(--btn-grp-br-col)}}button.primary,[type="button"].primary,[type="submit"].primary,[type="reset"].primary,.button.primary,[role="button"].primary{--btn-b-col:#1976d2;--btn-f-col:#f8f8f8}button.primary:hover,button.primary:focus,[type="button"].primary:hover,[type="button"].primary:focus,[type="submit"].primary:hover,[type="submit"].primary:focus,[type="reset"].primary:hover,[type="reset"].primary:focus,.button.primary:hover,.button.primary:focus,[role="button"].primary:hover,[role="button"].primary:focus{--btn-h-b-col:#1565c0}:root{--hd-b-col:#f8f8f8;--hd-hv-b-col:#f0f0f0;--hd-f-col:#444;--hd-br-col:#ddd;--nv-b-col:#f8f8f8;--nv-hv-b-col:#f0f0f0;--nv-f-col:#444;--nv-br-col:#ddd;--nv-ln-col:#0277bd;--ft-f-col:#444;--ft-b-col:#f8f8f8;--ft-br-col:#ddd;--ft-ln-col:#0277bd;--dr-b-col:#f8f8f8;--dr-hv-b-col:#f0f0f0;--dr-br-col:#ddd;--dr-cl-col:#444}header{height:3.1875rem;background:var(--hd-b-col);color:var(--hd-f-col);border-bottom:.0625rem solid var(--hd-br-col);padding:calc(var(--u-p) / 4) 0;white-space:nowrap;overflow-x:auto;overflow-y:hidden}header.row{box-sizing:content-box}header .logo{color:var(--hd-f-col);font-size:1.75rem;padding:var(--u-p) calc(2 * var(--u-p));text-decoration:none}header button,header [type="button"],header .button,header [role="button"]{box-sizing:border-box;position:relative;top:calc(0rem - var(--u-p) / 4);height:calc(3.1875rem + var(--u-p) / 2);background:var(--hd-b-col);line-height:calc(3.1875rem - var(--u-p) * 1.5);text-align:center;color:var(--hd-f-col);border:0;border-radius:0;margin:0;text-transform:uppercase}header button:hover,header button:focus,header [type="button"]:hover,header [type="button"]:focus,header .button:hover,header .button:focus,header [role="button"]:hover,header [role="button"]:focus{background:var(--hd-hv-b-col)}nav{background:var(--nv-b-col);color:var(--nv-f-col);border:.0625rem solid var(--nv-br-col);border-radius:var(--u-br-r);margin:var(--u-m)}nav *{padding:var(--u-p) calc(1.5 * var(--u-p))}nav a,nav a:visited{display:block;color:var(--nv-ln-col);border-radius:var(--u-br-r);transition:background 0.3s}nav a:hover,nav a:focus,nav a:visited:hover,nav a:visited:focus{text-decoration:none;background:var(--nv-hv-b-col)}nav .sublink-1{position:relative;margin-left:calc(2 * var(--u-p))}nav .sublink-1:before{position:absolute;left:calc(var(--u-p) - 1 * var(--u-p));top:-.0625rem;content:'';height:100%;border:.0625rem solid var(--nv-br-col);border-left:0}footer{background:var(--ft-b-col);color:var(--ft-f-col);border-top:.0625rem solid var(--ft-br-col);padding:calc(2 * var(--u-p)) var(--u-p);font-size:.875rem}footer a,footer a:visited{color:var(--ft-ln-col)}header.sticky{position:-webkit-sticky;position:sticky;z-index:1101;top:0}footer.sticky{position:-webkit-sticky;position:sticky;z-index:1101;bottom:0}.drawer-toggle:before{display:inline-block;position:relative;vertical-align:bottom;content:'\00a0\2261\00a0';font-family:sans-serif;font-size:1.5em}@media screen and (min-width: 768px){.drawer-toggle:not(.persistent){display:none}}[type="checkbox"].drawer{height:1px;width:1px;margin:-1px;overflow:hidden;position:absolute;clip:rect(0 0 0 0);-webkit-clip-path:inset(100%);clip-path:inset(100%)}[type="checkbox"].drawer+*{display:block;box-sizing:border-box;position:fixed;top:0;width:320px;height:100vh;overflow-y:auto;background:var(--dr-b-col);border:.0625rem solid var(--dr-br-col);border-radius:0;margin:0;z-index:1110;left:-320px;transition:left 0.3s}[type="checkbox"].drawer+* .drawer-close{position:absolute;top:var(--u-m);right:var(--u-m);z-index:1111;width:2rem;height:2rem;border-radius:var(--u-br-r);padding:var(--u-p);margin:0;cursor:pointer;transition:background 0.3s}[type="checkbox"].drawer+* .drawer-close:before{display:block;content:'\00D7';color:var(--dr-cl-col);position:relative;font-family:sans-serif;font-size:2rem;line-height:1;text-align:center}[type="checkbox"].drawer+* .drawer-close:hover,[type="checkbox"].drawer+* .drawer-close:focus{background:var(--dr-hv-b-col)}@media screen and (max-width: 320px){[type="checkbox"].drawer+*{width:100%}}[type="checkbox"].drawer:checked+*{left:0}@media screen and (min-width: 768px){[type="checkbox"].drawer:not(.persistent)+*{position:static;height:100%;z-index:1100}[type="checkbox"].drawer:not(.persistent)+* .drawer-close{display:none}}:root{--mrk-b-col:#424242;--mrk-f-col:#fafafa}mark{background:var(--mrk-b-col);color:var(--mrk-f-col);font-size:.5em;line-height:1em;border-radius:var(--u-br-r);padding:calc(var(--u-p) / 4) calc(var(--u-p) / 2)}mark.inline-block{display:inline-block;font-size:1em;line-height:1.5;padding:calc(var(--u-p) / 2) var(--u-p)}:root{--tst-b-col:#212121;--tst-f-col:#fafafa}.toast{position:fixed;bottom:calc(var(--u-m) * 3);left:50%;transform:translate(-50%, -50%);z-index:1111;color:var(--tst-f-col);background:var(--tst-b-col);border-radius:calc(var(--u-br-r) * 16);padding:var(--u-p) calc(var(--u-p) * 3)}div,main,nav{-webkit-overflow-scrolling:touch}.toast{bottom:calc(var(--u-m) / 2);opacity:1;transition:opacity 0.3s ease-in-out}mark{position:relative;top:-0.25rem;left:0.25rem}mark.secondary{--mrk-b-col:#d32f2f}mark.tertiary{--mrk-b-col:#308732}mark.tag{padding:calc(var(--u-p)/2) var(--u-p);border-radius:1em}code,pre,kbd,code *,pre *,kbd *,code[class*="language-"],pre[class*="language-"]{font-family:Menlo, Consolas, monospace !important}pre{border:0.0625rem solid var(--br-col2);border-radius:var(--u-br-r)}.search{font-size:0.875rem}header h1.logo{margin-top:-0.8rem;text-align:center;position:relative;top:0;transition:top 0.3s}header h1.logo a{text-decoration:none;color:#111}@media screen and (min-width: 769px){header h1.logo:hover{top:-3.5rem}}header #title{position:relative;top:-1rem}@media screen and (max-width: 768px){header #title{display:none}}header h1 small{display:block;font-size:0.875rem;color:#888;margin-top:0.75rem}label#menu-toggle{position:absolute;left:0rem;top:0rem;width:3.4375rem}main{padding:0}:root{--clps-lbl-b-col:#e8e8e8;--clps-lbl-f-col:#212121;--clps-lbl-h-b-col:#f0f0f0;--clps-sel-lbl-b-col:#ececec;--clps-br-col:#ddd;--clps-cnt-b-col:#fafafa;--clps-sel-lbl-br-col:#0277bd}label.collapse{width:100%;display:inline-block;cursor:pointer;box-sizing:border-box;transition:background 0.3s;color:var(--clps-lbl-f-col);background:var(--clps-lbl-b-col);border:.0625rem solid var(--clps-br-col);padding:calc(1.5 * var(--u-p));border-radius:var(--u-br-r)}label.collapse:hover,label.collapse:focus{background:var(--clps-lbl-h-b-col)}label.collapse+pre{box-sizing:border-box;height:0;max-height:1px;overflow:auto;margin:0;border:0;padding:0;transition:max-height 0.3s}label.collapse.toggled{background:var(--clps-sel-lbl-b-col);border-bottom-color:var(--clps-sel-lbl-br-col);border-bottom-left-radius:0;border-bottom-right-radius:0}label.collapse.toggled+pre{border-top-left-radius:0;border-top-right-radius:0;position:relative;width:100%;height:auto;border:.0625rem solid var(--clps-br-col);border-top:0;padding:calc(2 * var(--u-p));max-height:400px}button.primary.clipboard-copy{width:100%;margin-left:0}button.primary.clipboard-copy>img{vertical-align:bottom}code[class*="language-"],pre[class*="language-"]{color:#222;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.8;-moz-tab-size:2;-o-tab-size:2;tab-size:2;-webkit-hypens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*="language-"]{padding:calc(2 * var(--u-p));overflow:auto;margin:var(--u-m) 0}pre[class*="language-"]::-moz-selection,pre[class*="language-"] ::-moz-selection,code[class*="language-"]::-moz-selection,code[class*="language-"] ::-moz-selection{background:#b3d4fc}pre[class*="language-"]::selection,pre[class*="language-"] ::selection,code[class*="language-"]::selection,code[class*="language-"] ::selection{background:#b3d4fc}:not(pre)>code[class*="language-"]{padding:.1em;border-radius:.3em;white-space:normal}.token.comment,.token.prolog,.token.doctype,.token.cdata{color:#7a8490}.token.punctuation{color:#666}.namespace{opacity:.7}.token.property,.token.tag,.token.boolean,.token.constant,.token.symbol,.token.deleted,.token.function{color:#005cc5}.token.number,.token.class-name{color:#832ed2}.token.selector,.token.attr-name,.token.string,.token.char,.token.builtin,.token.inserted{color:#067e36}.token.operator,.token.entity,.token.url,.language-css .token.string,.style .token.string,.token.atrule,.token.attr-value,.token.keyword{color:#d73a49}.token.regex{color:#097cab}.token.important,.token.variable{color:#e90}.token.important,.token.bold{font-weight:bold}.token.italic{font-style:italic}.token.entity{cursor:help}button.scroll-to-top{border-radius:100%;font-size:1.5rem;line-height:1;box-sizing:border-box;width:2.75rem;height:2.75rem;position:fixed;bottom:1rem;right:2rem;background:var(--b-col);box-shadow:0 0.25rem 0.25rem 0 rgba(0,0,0,0.125),0 0.125rem 0.125rem -0.125rem rgba(0,0,0,0.25)}button.scroll-to-top:hover,button.scroll-to-top:focus{background:var(--b-col2)}
    diff --git a/docs/mini/flavor.scss b/docs/mini/flavor.scss
    index 59775783e..b4df595c0 100644
    --- a/docs/mini/flavor.scss
    +++ b/docs/mini/flavor.scss
    @@ -92,7 +92,7 @@ $button-hover-border-color-var: '--btn-h-br-col';
     $button-group-border-color-var: '--btn-grp-br-col';
     
     
    -$_include-fluid-input-group: false;
    +$_include-fluid-input-group: true;
     
     @import 'input_control';
     
    @@ -159,6 +159,9 @@ $_include-collapse: false;
     
     @import 'contextual';
     
    +div,main,nav{
    +  -webkit-overflow-scrolling: touch;
    +}
     .#{$toast-name} {
       bottom: calc(var(#{$universal-margin-var}) / 2);
       opacity: 1;
    @@ -195,68 +198,45 @@ pre {
       border: 0.0625rem solid var(#{$secondary-border-color-var});
       border-radius: var(#{$universal-border-radius-var});
     }
    -.group{
    -  position:relative;
    -  margin-top: 2em;
    -  margin-bottom: 1em
    -}
    -.search{
    +
    +.search {
       font-size: 0.875rem;
    -  margin-top: -0.1em;
    -  display:block;
    -  width:100%;
    -  border:none;
    -  border-bottom: $__1px solid var(#{$nav-link-color-var});
    -}
    -.search:focus{
    -  outline:none
    -}
    -label#search-label{
    -  color:var(#{$nav-link-color-var});
    -  font-size: 1.125rem;
    -  font-weight:400;
    -  position:absolute;
    -  left: 0.3125rem;
    -  top: 0.625rem;
    -}
    -.search:focus ~ label#search-label,.search:valid ~ label#search-label{
    -  top: -1.25rem;
    -  font-size: 0.875rem;
    -  color:var(#{$nav-link-color-var});
    -}
    -label#menu-toggle {
    -  width: 3.4375rem;
     }
     
     header h1.logo {
       margin-top: -0.8rem;
       text-align:center;
    +  position: relative;
    +  top: 0;
    +  transition: top 0.3s;
       a {
       text-decoration:none;
       color: #111;
       }
    +  @media screen and (min-width: 769px) {
    +    &:hover {
    +      top: -3.5rem;
    +    }
    +  }
     }
     
     header #title {
       position:relative;
       top: -1rem;
    -  @media screen and (max-width: 500px) { font-size: 1rem; display: block }
    +  @media screen and (max-width: 768px) { display: none; }
     }
     
     header h1 small {
       display:block;
       font-size: 0.875rem;
       color: #888;
    -  margin-top: -0.8rem;
    -  @media screen and (max-width: 768px) { font-size: 0.75rem; }
    -  @media screen and (max-width: 600px) { font-size: 0.625rem; }
    -  @media screen and (max-width: 500px) { font-size: 0.5rem; margin-top: -1.2rem; }
    +  margin-top: 0.75rem;
     }
     
     label#menu-toggle {
       position: absolute;
    -  left: 0.5rem;
    -  top: 0.5rem;
    +  left: 0rem;
    +  top: 0rem;
       width: 3.4375rem;
     }
     
    diff --git a/snippets/anagrams.md b/snippets/anagrams.md
    deleted file mode 100644
    index ae7284a0b..000000000
    --- a/snippets/anagrams.md
    +++ /dev/null
    @@ -1,27 +0,0 @@
    -### anagrams
    -
    -⚠️ **WARNING**: This function's execution time increases exponentially with each character. Anything more than 8 to 10 characters will cause your browser to hang as it tries to solve all the different combinations.
    -
    -Generates all anagrams of a string (contains duplicates).
    -
    -Use recursion.
    -For each letter in the given string, create all the partial anagrams for the rest of its letters.
    -Use `Array.map()` to combine the letter with each partial anagram, then `Array.reduce()` to combine all anagrams in one array.
    -Base cases are for string `length` equal to `2` or `1`.
    -
    -```js
    -const anagrams = str => {
    -  if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str];
    -  return str
    -    .split('')
    -    .reduce(
    -      (acc, letter, i) =>
    -        acc.concat(anagrams(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)),
    -      []
    -    );
    -};
    -```
    -
    -```js
    -anagrams('abc'); // ['abc','acb','bac','bca','cab','cba']
    -```
    diff --git a/snippets/isAnagram.md b/snippets/isAnagram.md
    new file mode 100644
    index 000000000..81045764a
    --- /dev/null
    +++ b/snippets/isAnagram.md
    @@ -0,0 +1,22 @@
    +### isAnagram
    +
    +Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).
    +
    +Use `String.toLowerCase()`, `String.replace()` with an appropriate regular expression to remove unnecessary characters, `String.split('')`, `Array.sort()` and `Array.join('')` on both strings to normalize them, then check if their normalized forms are equal.
    +
    +```js
    +const isAnagram = (str1, str2) => {
    +  const normalize = str =>
    +    str
    +      .toLowerCase()
    +      .replace(/[^a-z0-9]/gi, '')
    +      .split('')
    +      .sort()
    +      .join('');
    +  return normalize(str1) === normalize(str2);
    +};
    +```
    +
    +```js
    +isAnagram('iceman', 'cinema'); // true
    +```
    diff --git a/snippets/nest.md b/snippets/nest.md
    new file mode 100644
    index 000000000..b7ca13827
    --- /dev/null
    +++ b/snippets/nest.md
    @@ -0,0 +1,29 @@
    +### nest
    +
    +Given a flat array of objects linked to one another, it will nest them recursively.
    +Useful for nesting comments, such as the ones on reddit.com.
    +
    +Use recursion. 
    +Use `Array.filter()` to filter the items where the `id` matches the `link`, then `Array.map()` to map each one to a new object that has a `children` property which recursively nests the items based on which ones are children of the current item. 
    +Omit the second argument, `id`, to default to `null` which indicates the object is not linked to another one (i.e. it is a top level object). 
    +Omit the third argument, `link`, to use `'parent_id'` as the default property which links the object to another one by its `id`.
    +
    +```js
    +const nest = (items, id = null, link = 'parent_id') =>
    +  items
    +    .filter(item => item[link] === id)
    +    .map(item => ({ ...item, children: nest(items, item.id) }));
    +```
    +
    +```js
    +// One top level comment
    +const comments = [
    +  { id: 1, parent_id: null },
    +  { id: 2, parent_id: 1 },
    +  { id: 3, parent_id: 1 },
    +  { id: 4, parent_id: 2 },
    +  { id: 5, parent_id: 4 }
    +];
    +const nestedComments = nest(comments); // [{ id: 1, parent_id: null, children: [...] }]
    +```
    +
    diff --git a/snippets/pad.md b/snippets/pad.md
    new file mode 100644
    index 000000000..18e449739
    --- /dev/null
    +++ b/snippets/pad.md
    @@ -0,0 +1,17 @@
    +### pad
    +
    +Pads a string on both sides with the specified character, if it's shorter than the specified length.
    +
    +Use `String.padStart()` and `String.padEnd()` to pad both sides of the given string.
    +Omit the third argument, `char`, to use the whitespace character as the default padding character.
    +
    +```js
    +const pad = (str, length, char = ' ') =>
    +  str.padStart((str.length + length) / 2, char).padEnd(length, char);
    +```
    +
    +```js
    +pad('cat', 8); // '  cat   '
    +pad(String(42), 6, '0'); // '004200'
    +pad('foobar', 3); // 'foobar'
    +```
    diff --git a/snippets/permutations.md b/snippets/permutations.md
    new file mode 100644
    index 000000000..44ec508ce
    --- /dev/null
    +++ b/snippets/permutations.md
    @@ -0,0 +1,27 @@
    +### permutations
    +
    +⚠️ **WARNING**: This function's execution time increases exponentially with each array element. Anything more than 8 to 10 entries will cause your browser to hang as it tries to solve all the different combinations.
    +
    +Generates all permutations of an array's elements (contains duplicates).
    +
    +Use recursion.
    +For each element in the given array, create all the partial permutations for the rest of its elements.
    +Use `Array.map()` to combine the element with each partial permutation, then `Array.reduce()` to combine all permutations in one array.
    +Base cases are for array `length` equal to `2` or `1`.
    +
    +```js
    +const permutations = arr => {
    +  if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr;
    +  return arr.reduce(
    +    (acc, item, i) =>
    +      acc.concat(
    +        permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val => [item, ...val])
    +      ),
    +    []
    +  );
    +};
    +```
    +
    +```js
    +permutations([1, 33, 5]); // [ [ 1, 33, 5 ], [ 1, 5, 33 ], [ 33, 1, 5 ], [ 33, 5, 1 ], [ 5, 1, 33 ], [ 5, 33, 1 ] ]
    +```
    diff --git a/snippets/sortedLastIndex.md b/snippets/sortedLastIndex.md
    index 57d2499a3..43ecefab5 100644
    --- a/snippets/sortedLastIndex.md
    +++ b/snippets/sortedLastIndex.md
    @@ -3,16 +3,12 @@
     Returns the highest index at which value should be inserted into array in order to maintain its sort order.
     
     Check if the array is sorted in descending order (loosely).
    -Use `Array.map()` to map each element to an array with its index and value.
     Use `Array.reverse()` and `Array.findIndex()` to find the appropriate last index where the element should be inserted.
     
     ```js
     const sortedLastIndex = (arr, n) => {
       const isDescending = arr[0] > arr[arr.length - 1];
    -  const index = arr
    -    .map((val, i) => [i, val])
    -    .reverse()
    -    .findIndex(el => (isDescending ? n <= el[1] : n >= el[1]));
    +  const index = arr.reverse().findIndex(el => (isDescending ? n <= el : n >= el));
       return index === -1 ? 0 : arr.length - index - 1;
     };
     ```
    diff --git a/snippets/sortedLastIndexBy.md b/snippets/sortedLastIndexBy.md
    index 443ba5045..97e60f827 100644
    --- a/snippets/sortedLastIndexBy.md
    +++ b/snippets/sortedLastIndexBy.md
    @@ -3,16 +3,17 @@
     Returns the highest index at which value should be inserted into array in order to maintain its sort order, based on a provided iterator function.
     
     Check if the array is sorted in descending order (loosely).
    -Use `Array.reverse()` and `Array.findIndex()` to find the appropriate last index where the element should be inserted, based on the iterator function `fn`..
    +Use `Array.map()` to apply the iterator function to all elements of the array.
    +Use `Array.reverse()` and `Array.findIndex()` to find the appropriate last index where the element should be inserted, based on the provided iterator function.
     
     ```js
     const sortedLastIndexBy = (arr, n, fn) => {
       const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]);
       const val = fn(n);
       const index = arr
    -    .map((val, i) => [i, fn(val)])
    +    .map(fn)
         .reverse()
    -    .findIndex(el => (isDescending ? val <= el[1] : val >= el[1]));
    +    .findIndex(el => (isDescending ? val <= el : val >= el));
       return index === -1 ? 0 : arr.length - index;
     };
     ```
    diff --git a/snippets/stringPermutations.md b/snippets/stringPermutations.md
    new file mode 100644
    index 000000000..dee086afa
    --- /dev/null
    +++ b/snippets/stringPermutations.md
    @@ -0,0 +1,27 @@
    +### stringPermutations
    +
    +⚠️ **WARNING**: This function's execution time increases exponentially with each character. Anything more than 8 to 10 characters will cause your browser to hang as it tries to solve all the different combinations.
    +
    +Generates all permutations of a string (contains duplicates).
    +
    +Use recursion.
    +For each letter in the given string, create all the partial permutations for the rest of its letters.
    +Use `Array.map()` to combine the letter with each partial permutation, then `Array.reduce()` to combine all permutations in one array.
    +Base cases are for string `length` equal to `2` or `1`.
    +
    +```js
    +const stringPermutations = str => {
    +  if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str];
    +  return str
    +    .split('')
    +    .reduce(
    +      (acc, letter, i) =>
    +        acc.concat(stringPermutations(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)),
    +      []
    +    );
    +};
    +```
    +
    +```js
    +stringPermutations('abc'); // ['abc','acb','bac','bca','cab','cba']
    +```
    diff --git a/snippets/tomorrow.md b/snippets/tomorrow.md
    index fd7c4dfa1..68651691e 100644
    --- a/snippets/tomorrow.md
    +++ b/snippets/tomorrow.md
    @@ -4,15 +4,17 @@ Results in a string representation of tomorrow's date.
     Use `new Date()` to get today's date, adding one day using `Date.getDate()` and `Date.setDate()`, and converting the Date object to a string.
     
     ```js
    -const tomorrow = () => {
    +const tomorrow = (long = false) => {
       let t = new Date();
       t.setDate(t.getDate() + 1);
    -  return `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(
    +  const ret = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(
         t.getDate()
       ).padStart(2, '0')}`;
    +  return !long ? ret : `${ret}T00:00:00`;
     };
     ```
     
     ```js
     tomorrow(); // 2017-12-27 (if current date is 2017-12-26)
    +tomorrow(true); // 2017-12-27T00:00:00 (if current date is 2017-12-26)
     ```
    diff --git a/snippets_archive/isSimilar.md b/snippets_archive/isSimilar.md
    new file mode 100644
    index 000000000..7ed53b2ae
    --- /dev/null
    +++ b/snippets_archive/isSimilar.md
    @@ -0,0 +1,19 @@
    +### isSimilar
    +
    +Determines if the `pattern` matches with `str`.
    +
    +Use `String.toLowerCase()` to convert both strings to lowercase, then loop through `str` and determine if it contains all characters of `pattern` and in the correct order.
    +Adapted from [here](https://github.com/forrestthewoods/lib_fts/blob/80f3f8c52db53428247e741b9efe2cde9667050c/code/fts_fuzzy_match.js#L18).
    +
    +``` js
    +const isSimilar = (pattern, str) =>
    +	[...str].reduce(
    +		(matchIndex, char) => char.toLowerCase() === (pattern[matchIndex]  || '').toLowerCase() ? matchIndex + 1 : matchIndex, 0
    +	) === pattern.length ? true : false;
    +```
    +
    +
    +``` js
    +isSimilar('rt','Rohit'); // true
    +isSimilar('tr','Rohit'); // false
    +```
    diff --git a/static-parts/index-start.html b/static-parts/index-start.html
    index e5c0702d1..29cc93b13 100644
    --- a/static-parts/index-start.html
    +++ b/static-parts/index-start.html
    @@ -34,11 +34,30 @@
               document.querySelector('main').scrollTo(0, c - c / 4);
             }
           };
    +      function scrollTo(element, to, id, duration) {
    +        if (duration <= 0) return;
    +        var difference = to - element.scrollTop;
    +        var perTick = difference / duration * 40;
    +
    +        setTimeout(function() {
    +            element.scrollTop = element.scrollTop + perTick;
    +            if (element.scrollTop === to) {
    +              window.location.href = "#"+id;
    +              return;
    +            }
    +            scrollTo(element, to, id, duration - 40);
    +        }, 40);
    +      };
           function loader() {
             registerClickListener();
           }
           function registerClickListener() {
             document.addEventListener('click', function (event) {
    +          if( document.getElementById('doc-drawer-checkbox').checked ) {
    +            if(!document.querySelector('nav').contains(event.target) && !event.target.classList.contains('drawer-toggle') && !event.target.classList.contains('drawer')) {
    +              document.getElementById('doc-drawer-checkbox').checked = false;
    +            }
    +          }
               if ( event.target.classList.contains('collapse') ) {
                 event.target.classList = event.target.classList.contains('toggled') ? 'collapse' : 'collapse toggled';
               }
    @@ -64,23 +83,26 @@
               else if (event.target.classList.contains('scroll-to-top')){
                 scrollToTop();
               }
    +          else if (event.target.classList.contains('sublink-1')){
    +            event.preventDefault();
    +            scrollTo(document.querySelector('main'), document.getElementById(event.target.href.split('#')[1]).parentElement.offsetTop - 60, event.target.href.split('#')[1], 400);
    +            document.getElementById('doc-drawer-checkbox').checked = false;
    +          }
             }, false);
           }
         
       
       
    -    
    -    
    -

    logo 30 seconds of code + +
    +

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

    -
    +