From 2f29187eeaac45cd40f55d9f2b96e52dc57793df Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Wed, 17 Jan 2018 20:11:19 +0000 Subject: [PATCH] Travis build: 1297 [cron] --- dist/_30s.es5.js | 126 +- dist/_30s.es5.min.js | 2 +- dist/_30s.esm.js | 55 +- dist/_30s.js | 55 +- dist/_30s.min.js | 2 +- snippets_archive/README.md | 208 +-- test/hashBrowser/hashBrowser.js | 9 + test/hashBrowser/hashBrowser.test.js | 13 + test/hashNode/hashNode.js | 15 + test/hashNode/hashNode.test.js | 13 + test/is/is.js | 2 + test/is/is.test.js | 13 + test/testlog | 2432 +++++++++++++------------- 13 files changed, 1575 insertions(+), 1370 deletions(-) create mode 100644 test/hashBrowser/hashBrowser.js create mode 100644 test/hashBrowser/hashBrowser.test.js create mode 100644 test/hashNode/hashNode.js create mode 100644 test/hashNode/hashNode.test.js create mode 100644 test/is/is.js create mode 100644 test/is/is.test.js diff --git a/dist/_30s.es5.js b/dist/_30s.es5.js index f15107273..50ad0901a 100644 --- a/dist/_30s.es5.js +++ b/dist/_30s.es5.js @@ -13,6 +13,14 @@ var RGBToHex = function RGBToHex(r, g, b) { return ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); }; +var URLJoin = function URLJoin() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return args.join('/').replace(/[\/]+/g, '/').replace(/^(.+):\//, '$1://').replace(/^file:/, 'file:/').replace(/\/(\?|&|#[^!])/g, '$1').replace(/\?/g, '&').replace('&', '?'); +}; + var UUIDGeneratorBrowser = function UUIDGeneratorBrowser() { return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) { return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16); @@ -334,12 +342,6 @@ var distance = function distance(x0, y0, x1, y1) { return Math.hypot(x1 - x0, y1 - y0); }; -function _toConsumableArray$2(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 distinctValuesOfArray = function distinctValuesOfArray(arr) { - return [].concat(_toConsumableArray$2(new Set(arr))); -}; - var dropElements = function dropElements(arr, func) { while (arr.length > 0 && !func(arr[0])) { arr = arr.slice(1); @@ -521,11 +523,11 @@ var functionName = function functionName(fn) { return console.debug(fn.name), fn; }; -function _toConsumableArray$3(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$2(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 functions = function functions(obj) { var inherited = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - return (inherited ? [].concat(_toConsumableArray$3(Object.keys(obj)), _toConsumableArray$3(Object.keys(Object.getPrototypeOf(obj)))) : Object.keys(obj)).filter(function (key) { + return (inherited ? [].concat(_toConsumableArray$2(Object.keys(obj)), _toConsumableArray$2(Object.keys(Object.getPrototypeOf(obj)))) : Object.keys(obj)).filter(function (key) { return typeof obj[key] === 'function'; }); }; @@ -604,16 +606,35 @@ var hasFlags = function hasFlags() { }); }; +var hashBrowser = function hashBrowser(val) { + return crypto.subtle.digest('SHA-256', new TextEncoder('utf-8').encode(val)).then(function (h) { + var hexes = [], + view = new DataView(h); + for (var i = 0; i < view.byteLength; i += 4) { + hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8)); + }return hexes.join(''); + }); +}; + +var crypto$2 = typeof require !== "undefined" && require('crypto'); +var hashNode = function hashNode(val) { + return new Promise(function (resolve) { + return setTimeout(function () { + return resolve(crypto$2.createHash('sha256').update(val).digest('hex')); + }, 0); + }); +}; + var head = function head(arr) { return arr[0]; }; -function _toConsumableArray$4(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$3(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 hexToRGB = function hexToRGB(hex) { var alpha = false, h = hex.slice(hex.startsWith('#') ? 1 : 0); - if (h.length === 3) h = [].concat(_toConsumableArray$4(h)).map(function (x) { + if (h.length === 3) h = [].concat(_toConsumableArray$3(h)).map(function (x) { return x + x; }).join('');else if (h.length === 8) alpha = true; h = parseInt(h, 16); @@ -644,8 +665,7 @@ var httpGet = function httpGet(url, callback) { request.send(); }; -var httpPost = function httpPost(url, callback) { - var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; +var httpPost = function httpPost(url, data, callback) { var err = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : console.error; var request = new XMLHttpRequest(); @@ -698,6 +718,14 @@ var initializeArrayWithRange = function initializeArrayWithRange(end) { }); }; +var initializeArrayWithRangeRight = function initializeArrayWithRangeRight(end) { + var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + var step = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; + return Array.from({ length: Math.ceil((end + 1 - start) / step) }).map(function (v, i, arr) { + return (arr.length - i - 1) * step + start; + }); +}; + var initializeArrayWithValues = function initializeArrayWithValues(n) { var val = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; return Array(n).fill(val); @@ -717,20 +745,20 @@ var invertKeyValues = function invertKeyValues(obj) { }, {}); }; +var is = function is(type, val) { + return val instanceof type; +}; + var isAbsoluteURL = function isAbsoluteURL(str) { return (/^[a-z][a-z0-9+.-]*:/.test(str) ); }; -var isArray = function isArray(val) { - return Array.isArray(val); -}; - -function _toConsumableArray$5(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$4(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) { try { - return [].concat(_toConsumableArray$5(val)), true; + return [].concat(_toConsumableArray$4(val)), true; } catch (e) { return false; } @@ -756,6 +784,10 @@ var isLowerCase = function isLowerCase(str) { return str === str.toLowerCase(); }; +var isNil = function isNil(val) { + return val === undefined || val === null; +}; + var isNull = function isNull(val) { return val === null; }; @@ -836,6 +868,10 @@ var isTravisCI = function isTravisCI() { return 'TRAVIS' in process.env && 'CI' in process.env; }; +var isUndefined = function isUndefined(val) { + return val === undefined; +}; + var isUpperCase = function isUpperCase(str) { return str === str.toUpperCase(); }; @@ -934,28 +970,28 @@ var mask = function mask(cc) { return ('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num); }; -function _toConsumableArray$6(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$5(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 maxBy = function maxBy(arr, fn) { - return Math.max.apply(Math, _toConsumableArray$6(arr.map(typeof fn === 'function' ? fn : function (val) { + return Math.max.apply(Math, _toConsumableArray$5(arr.map(typeof fn === 'function' ? fn : function (val) { return val[fn]; }))); }; -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); } } +function _toConsumableArray$6(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 maxN = function maxN(arr) { var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; - return [].concat(_toConsumableArray$7(arr)).sort(function (a, b) { + return [].concat(_toConsumableArray$6(arr)).sort(function (a, b) { return b - a; }).slice(0, n); }; -function _toConsumableArray$8(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$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 median = function median(arr) { var mid = Math.floor(arr.length / 2), - nums = [].concat(_toConsumableArray$8(arr)).sort(function (a, b) { + nums = [].concat(_toConsumableArray$7(arr)).sort(function (a, b) { return a - b; }); return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2; @@ -983,19 +1019,19 @@ var merge = function merge() { }, {}); }; -function _toConsumableArray$9(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$8(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 minBy = function minBy(arr, fn) { - return Math.min.apply(Math, _toConsumableArray$9(arr.map(typeof fn === 'function' ? fn : function (val) { + return Math.min.apply(Math, _toConsumableArray$8(arr.map(typeof fn === 'function' ? fn : function (val) { return val[fn]; }))); }; -function _toConsumableArray$10(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$9(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 minN = function minN(arr) { var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; - return [].concat(_toConsumableArray$10(arr)).sort(function (a, b) { + return [].concat(_toConsumableArray$9(arr)).sort(function (a, b) { return a - b; }).slice(0, n); }; @@ -1085,10 +1121,10 @@ var once = function once(fn) { var _slicedToArray$2 = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); -function _toConsumableArray$11(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$10(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 orderBy = function orderBy(arr, props, orders) { - return [].concat(_toConsumableArray$11(arr)).sort(function (a, b) { + return [].concat(_toConsumableArray$10(arr)).sort(function (a, b) { return props.reduce(function (acc, prop, i) { if (acc === 0) { var _ref = orders && orders[i] === 'desc' ? [b[prop], a[prop]] : [a[prop], b[prop]], @@ -1302,10 +1338,10 @@ var remove = function remove(arr, func) { }, []) : []; }; -function _toConsumableArray$12(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$11(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$12(str)).reverse().join(''); + return [].concat(_toConsumableArray$11(str)).reverse().join(''); }; var round = function round(n) { @@ -1441,10 +1477,10 @@ var sleep = function sleep(ms) { }); }; -function _toConsumableArray$13(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$12(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$13(str)).sort(function (a, b) { + return [].concat(_toConsumableArray$12(str)).sort(function (a, b) { return a.localeCompare(b); }).join(''); }; @@ -1461,11 +1497,11 @@ var splitLines = function splitLines(str) { return str.split(/\r?\n/); }; -function _toConsumableArray$14(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$13(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var spreadOver = function spreadOver(fn) { return function (argsArr) { - return fn.apply(undefined, _toConsumableArray$14(argsArr)); + return fn.apply(undefined, _toConsumableArray$13(argsArr)); }; }; @@ -1510,14 +1546,14 @@ var sumPower = function sumPower(end) { }, 0); }; -function _toConsumableArray$15(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } +function _toConsumableArray$14(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var symmetricDifference = function symmetricDifference(a, b) { var sA = new Set(a), sB = new Set(b); - return [].concat(_toConsumableArray$15(a.filter(function (x) { + return [].concat(_toConsumableArray$14(a.filter(function (x) { return !sB.has(x); - })), _toConsumableArray$15(b.filter(function (x) { + })), _toConsumableArray$14(b.filter(function (x) { return !sA.has(x); }))); }; @@ -1615,10 +1651,16 @@ var unescapeHTML = function unescapeHTML(str) { }); }; -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$15(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } var union = function union(a, b) { - return Array.from(new Set([].concat(_toConsumableArray$16(a), _toConsumableArray$16(b)))); + return Array.from(new Set([].concat(_toConsumableArray$15(a), _toConsumableArray$15(b)))); +}; + +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 uniqueElements = function uniqueElements(arr) { + return [].concat(_toConsumableArray$16(new Set(arr))); }; var untildify = function untildify(str) { @@ -1673,7 +1715,7 @@ var zipObject = function zipObject(props, values) { }, {}); }; -var imports = { JSONToFile: JSONToFile, RGBToHex: RGBToHex, UUIDGeneratorBrowser: UUIDGeneratorBrowser, UUIDGeneratorNode: UUIDGeneratorNode, anagrams: anagrams, arrayToHtmlList: arrayToHtmlList, average: average, averageBy: averageBy, bottomVisible: bottomVisible, byteSize: byteSize, call: call, capitalize: capitalize, capitalizeEveryWord: capitalizeEveryWord, chainAsync: chainAsync, chunk: chunk, clampNumber: clampNumber, cleanObj: cleanObj, cloneRegExp: cloneRegExp, coalesce: coalesce, coalesceFactory: coalesceFactory, collectInto: collectInto, colorize: colorize, compact: compact, compose: compose, copyToClipboard: copyToClipboard, countBy: countBy, countOccurrences: countOccurrences, createElement: createElement, createEventHub: createEventHub, currentURL: currentURL, curry: curry, decapitalize: decapitalize, deepFlatten: deepFlatten, defer: defer, detectDeviceType: detectDeviceType, difference: difference, differenceWith: differenceWith, digitize: digitize, distance: distance, distinctValuesOfArray: distinctValuesOfArray, dropElements: dropElements, dropRight: dropRight, elementIsVisibleInViewport: elementIsVisibleInViewport, elo: elo, equals: equals, escapeHTML: escapeHTML, escapeRegExp: escapeRegExp, everyNth: everyNth, extendHex: extendHex, factorial: factorial, fibonacci: fibonacci, filterNonUnique: filterNonUnique, findLast: findLast, flatten: flatten, flip: flip, forEachRight: forEachRight, formatDuration: formatDuration, fromCamelCase: fromCamelCase, functionName: functionName, functions: functions, gcd: gcd, geometricProgression: geometricProgression, getDaysDiffBetweenDates: getDaysDiffBetweenDates, getScrollPosition: getScrollPosition, getStyle: getStyle, getType: getType, getURLParameters: getURLParameters, groupBy: groupBy, hammingDistance: hammingDistance, hasClass: hasClass, hasFlags: hasFlags, head: head, hexToRGB: hexToRGB, hide: hide, httpGet: httpGet, httpPost: httpPost, httpsRedirect: httpsRedirect, inRange: inRange, indexOfAll: indexOfAll, initial: initial, initialize2DArray: initialize2DArray, initializeArrayWithRange: initializeArrayWithRange, initializeArrayWithValues: initializeArrayWithValues, intersection: intersection, invertKeyValues: invertKeyValues, isAbsoluteURL: isAbsoluteURL, isArray: isArray, isArrayLike: isArrayLike, isBoolean: isBoolean, isDivisible: isDivisible, isEven: isEven, isFunction: isFunction, isLowerCase: isLowerCase, isNull: isNull, isNumber: isNumber, isObject: isObject, isPrime: isPrime, isPrimitive: isPrimitive, isPromiseLike: isPromiseLike, isSorted: isSorted, isString: isString, isSymbol: isSymbol, isTravisCI: isTravisCI, isUpperCase: isUpperCase, isValidJSON: isValidJSON, join: join, last: last, lcm: lcm, longestItem: longestItem, lowercaseKeys: lowercaseKeys, luhnCheck: luhnCheck, mapKeys: mapKeys, mapObject: mapObject, mapValues: mapValues, mask: mask, maxBy: maxBy, maxN: maxN, median: median, memoize: memoize, merge: merge, minBy: minBy, minN: minN, negate: negate, nthElement: nthElement, objectFromPairs: objectFromPairs, objectToPairs: objectToPairs, observeMutations: observeMutations, off: off, on: on, onUserInputChange: onUserInputChange, once: once, orderBy: orderBy, palindrome: palindrome, parseCookie: parseCookie, partition: partition, percentile: percentile, pick: pick, pipeFunctions: pipeFunctions, pluralize: pluralize, powerset: powerset, prettyBytes: prettyBytes, primes: primes, promisify: promisify, pull: pull, pullAtIndex: pullAtIndex, pullAtValue: pullAtValue, randomHexColorCode: randomHexColorCode, randomIntArrayInRange: randomIntArrayInRange, randomIntegerInRange: randomIntegerInRange, randomNumberInRange: randomNumberInRange, readFileLines: readFileLines, redirect: redirect, reducedFilter: reducedFilter, remove: remove, reverseString: reverseString, round: round, runAsync: runAsync, runPromisesInSeries: runPromisesInSeries, sample: sample, sampleSize: sampleSize, scrollToTop: scrollToTop, sdbm: sdbm, select: select, serializeCookie: serializeCookie, setStyle: setStyle, shallowClone: shallowClone, show: show, shuffle: shuffle, similarity: similarity, size: size, sleep: sleep, sortCharactersInString: sortCharactersInString, sortedIndex: sortedIndex, splitLines: splitLines, spreadOver: spreadOver, standardDeviation: standardDeviation, sum: sum, sumBy: sumBy, sumPower: sumPower, symmetricDifference: symmetricDifference, tail: tail, take: take, takeRight: takeRight, timeTaken: timeTaken, toCamelCase: toCamelCase, toDecimalMark: toDecimalMark, toKebabCase: toKebabCase, toOrdinalSuffix: toOrdinalSuffix, toSafeInteger: toSafeInteger, toSnakeCase: toSnakeCase, toggleClass: toggleClass, tomorrow: tomorrow, transform: transform, truncateString: truncateString, truthCheckCollection: truthCheckCollection, unescapeHTML: unescapeHTML, union: union, untildify: untildify, validateNumber: validateNumber, without: without, words: words, yesNo: yesNo, zip: zip, zipObject: zipObject }; +var imports = { JSONToFile: JSONToFile, RGBToHex: RGBToHex, URLJoin: URLJoin, UUIDGeneratorBrowser: UUIDGeneratorBrowser, UUIDGeneratorNode: UUIDGeneratorNode, anagrams: anagrams, arrayToHtmlList: arrayToHtmlList, average: average, averageBy: averageBy, bottomVisible: bottomVisible, byteSize: byteSize, call: call, capitalize: capitalize, capitalizeEveryWord: capitalizeEveryWord, chainAsync: chainAsync, chunk: chunk, clampNumber: clampNumber, cleanObj: cleanObj, cloneRegExp: cloneRegExp, coalesce: coalesce, coalesceFactory: coalesceFactory, collectInto: collectInto, colorize: colorize, compact: compact, compose: compose, copyToClipboard: copyToClipboard, countBy: countBy, countOccurrences: countOccurrences, createElement: createElement, createEventHub: createEventHub, currentURL: currentURL, curry: curry, decapitalize: decapitalize, deepFlatten: deepFlatten, defer: defer, detectDeviceType: detectDeviceType, difference: difference, differenceWith: differenceWith, digitize: digitize, distance: distance, dropElements: dropElements, dropRight: dropRight, elementIsVisibleInViewport: elementIsVisibleInViewport, elo: elo, equals: equals, escapeHTML: escapeHTML, escapeRegExp: escapeRegExp, everyNth: everyNth, extendHex: extendHex, factorial: factorial, fibonacci: fibonacci, filterNonUnique: filterNonUnique, findLast: findLast, flatten: flatten, flip: flip, forEachRight: forEachRight, formatDuration: formatDuration, fromCamelCase: fromCamelCase, functionName: functionName, functions: functions, gcd: gcd, geometricProgression: geometricProgression, getDaysDiffBetweenDates: getDaysDiffBetweenDates, getScrollPosition: getScrollPosition, getStyle: getStyle, getType: getType, getURLParameters: getURLParameters, groupBy: groupBy, hammingDistance: hammingDistance, hasClass: hasClass, hasFlags: hasFlags, hashBrowser: hashBrowser, hashNode: hashNode, head: head, hexToRGB: hexToRGB, hide: hide, httpGet: httpGet, httpPost: httpPost, httpsRedirect: httpsRedirect, inRange: inRange, indexOfAll: indexOfAll, initial: initial, initialize2DArray: initialize2DArray, initializeArrayWithRange: initializeArrayWithRange, initializeArrayWithRangeRight: initializeArrayWithRangeRight, initializeArrayWithValues: initializeArrayWithValues, intersection: intersection, invertKeyValues: invertKeyValues, is: is, isAbsoluteURL: isAbsoluteURL, isArrayLike: isArrayLike, isBoolean: isBoolean, isDivisible: isDivisible, isEven: isEven, isFunction: isFunction, isLowerCase: isLowerCase, isNil: isNil, isNull: isNull, isNumber: isNumber, isObject: isObject, 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, maxBy: maxBy, maxN: maxN, median: median, memoize: memoize, merge: merge, minBy: minBy, minN: minN, negate: negate, nthElement: nthElement, objectFromPairs: objectFromPairs, objectToPairs: objectToPairs, observeMutations: observeMutations, off: off, on: on, onUserInputChange: onUserInputChange, once: once, orderBy: orderBy, palindrome: palindrome, parseCookie: parseCookie, partition: partition, percentile: percentile, pick: pick, pipeFunctions: pipeFunctions, pluralize: pluralize, powerset: powerset, prettyBytes: prettyBytes, primes: primes, promisify: promisify, pull: pull, pullAtIndex: pullAtIndex, pullAtValue: pullAtValue, randomHexColorCode: randomHexColorCode, randomIntArrayInRange: randomIntArrayInRange, randomIntegerInRange: randomIntegerInRange, randomNumberInRange: randomNumberInRange, readFileLines: readFileLines, redirect: redirect, reducedFilter: reducedFilter, remove: remove, reverseString: reverseString, round: round, runAsync: runAsync, runPromisesInSeries: runPromisesInSeries, sample: sample, sampleSize: sampleSize, scrollToTop: scrollToTop, sdbm: sdbm, select: select, serializeCookie: serializeCookie, setStyle: setStyle, shallowClone: shallowClone, show: show, shuffle: shuffle, similarity: similarity, size: size, sleep: sleep, sortCharactersInString: sortCharactersInString, sortedIndex: sortedIndex, splitLines: splitLines, spreadOver: spreadOver, standardDeviation: standardDeviation, sum: sum, sumBy: sumBy, sumPower: sumPower, symmetricDifference: symmetricDifference, tail: tail, take: take, takeRight: takeRight, timeTaken: timeTaken, toCamelCase: toCamelCase, toDecimalMark: toDecimalMark, toKebabCase: toKebabCase, toOrdinalSuffix: toOrdinalSuffix, toSafeInteger: toSafeInteger, toSnakeCase: toSnakeCase, toggleClass: toggleClass, tomorrow: tomorrow, transform: transform, truncateString: truncateString, truthCheckCollection: truthCheckCollection, unescapeHTML: unescapeHTML, union: union, uniqueElements: uniqueElements, untildify: untildify, validateNumber: validateNumber, without: without, words: words, yesNo: yesNo, zip: zip, zipObject: zipObject }; return imports; diff --git a/dist/_30s.es5.min.js b/dist/_30s.es5.min.js index fbe29289a..0fa20af5f 100644 --- a/dist/_30s.es5.min.js +++ b/dist/_30s.es5.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';function a(a){return Array.isArray(a)?a:Array.from(a)}function b(a){return Array.isArray(a)?a:Array.from(a)}function c(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b>a/4).toString(16)})},UUIDGeneratorNode:function(){return'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,function(a){return(a^F.randomBytes(1)[0]&15>>a/4).toString(16)})},anagrams:function a(b){return 2>=b.length?2===b.length?[b,b[1]+b[0]]:[b]:b.split('').reduce(function(c,d,e){return c.concat(a(b.slice(0,e)+b.slice(e+1)).map(function(a){return d+a}))},[])},arrayToHtmlList:function(a,b){return a.map(function(a){return document.querySelector('#'+b).innerHTML+='
  • '+a+'
  • '})},average:function(){for(var a=arguments.length,b=Array(a),c=0;c=(document.documentElement.scrollHeight||document.documentElement.clientHeight)},byteSize:function(a){return new Blob([a]).size},call:function(a){for(var b=arguments.length,c=Array(1'"]/g,function(a){return{"&":'&',"<":'<',">":'>',"'":''','"':'"'}[a]||a})},escapeRegExp:function(a){return a.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')},everyNth:function(a,b){return a.filter(function(a,c){return c%b==b-1})},extendHex:function(a){return'#'+a.slice(a.startsWith('#')?1:0).split('').map(function(a){return a+a}).join('')},factorial:function a(b){return 0>b?function(){throw new TypeError('Negative numbers are not allowed!')}():1>=b?1:b*a(b-1)},fibonacci:function(a){return Array.from({length:a}).reduce(function(a,b,c){return a.concat(1a&&(a=-a);var b={day:z(a/8.64e7),hour:z(a/3.6e6)%24,minute:z(a/6e4)%60,second:z(a/1e3)%60,millisecond:z(a)%1e3};return Object.entries(b).filter(function(a){return 0!==a[1]}).map(function(a){return a[1]+' '+(1===a[1]?a[0]:a[0]+'s')}).join(', ')},fromCamelCase:function(a){var b=1>>(b?24:16))+', '+((c&(b?16711680:65280))>>>(b?16:8))+', '+((c&(b?65280:255))>>>(b?8:0))+(b?', '+(255&c):'')+')'},hide:function(){for(var a=arguments.length,b=Array(a),c=0;cc&&(c=b),null==c?0<=a&&a=b&&aa[1]?-1:1,d=!0,e=!1;try{for(var f,g=a.entries()[Symbol.iterator]();!(d=(f=g.next()).done);d=!0){var h=f.value,j=K(h,2),k=j[0],i=j[1];if(k===a.length-1)return c;if(0<(i-a[k+1])*c)return 0}}catch(a){e=!0,b=a}finally{try{!d&&g.return&&g.return()}finally{if(e)throw b}}},isString:function(a){return'string'==typeof a},isSymbol:function(a){return'symbol'===('undefined'==typeof a?'undefined':L(a))},isTravisCI:function(){return'TRAVIS'in process.env&&'CI'in process.env},isUpperCase:function(a){return a===a.toUpperCase()},isValidJSON:function(a){try{return JSON.parse(a),!0}catch(a){return!1}},join:function(a){var b=1e-c&&(b='mouse',a(b),document.removeEventListener('mousemove',d)),c=e};document.addEventListener('touchstart',function(){'touch'==b||(b='touch',a(b),document.addEventListener('mousemove',d))})},once:function(a){var b=!1;return function(){if(!b){b=!0;for(var c=arguments.length,d=Array(c),e=0;ej?1:iMath.abs(a))return a+(c?' ':'')+d[0];var e=B(z(Math.log10(0>a?-a:a)/3),d.length-1),f=+((0>a?-a:a)/A(1e3,e)).toPrecision(b);return(0>a?'-':'')+f+(c?' ':'')+d[e]},primes:function(a){var b=Array.from({length:a-1}).map(function(a,b){return b+2}),c=z(y(a)),d=Array.from({length:c-1}).map(function(a,b){return b+2});return d.forEach(function(a){return b=b.filter(function(b){return 0!=b%a||b==a})}),b},promisify:function(a){return function(){for(var b=arguments.length,c=Array(b),d=0;da[a.length-1],d=a.findIndex(function(a){return c?b>=a:b<=a});return-1===d?a.length:d},splitLines:function(a){return a.split(/\r?\n/)},spreadOver:function(a){return function(b){return a.apply(void 0,t(b))}},standardDeviation:function(a){var b=1b?a.slice(0,3',"'":'\'',""":'"'}[a]||a})},union:function(c,a){return Array.from(new Set([].concat(v(c),v(a))))},untildify:function(a){return a.replace(/^~($|\/|\\)/,('undefined'!=typeof require&&require('os').homedir())+'$1')},validateNumber:function(a){return!isNaN(parseFloat(a))&&isFinite(a)&&+a==a},without:function(a){for(var b=arguments.length,c=Array(1>a/4).toString(16)})},UUIDGeneratorNode:function(){return'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,function(a){return(a^F.randomBytes(1)[0]&15>>a/4).toString(16)})},anagrams:function a(b){return 2>=b.length?2===b.length?[b,b[1]+b[0]]:[b]:b.split('').reduce(function(c,d,e){return c.concat(a(b.slice(0,e)+b.slice(e+1)).map(function(a){return d+a}))},[])},arrayToHtmlList:function(a,b){return a.map(function(a){return document.querySelector('#'+b).innerHTML+='
  • '+a+'
  • '})},average:function(){for(var a=arguments.length,b=Array(a),c=0;c=(document.documentElement.scrollHeight||document.documentElement.clientHeight)},byteSize:function(a){return new Blob([a]).size},call:function(a){for(var b=arguments.length,c=Array(1'"]/g,function(a){return{"&":'&',"<":'<',">":'>',"'":''','"':'"'}[a]||a})},escapeRegExp:function(a){return a.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')},everyNth:function(a,b){return a.filter(function(a,c){return c%b==b-1})},extendHex:function(a){return'#'+a.slice(a.startsWith('#')?1:0).split('').map(function(a){return a+a}).join('')},factorial:function a(b){return 0>b?function(){throw new TypeError('Negative numbers are not allowed!')}():1>=b?1:b*a(b-1)},fibonacci:function(a){return Array.from({length:a}).reduce(function(a,b,c){return a.concat(1a&&(a=-a);var b={day:z(a/8.64e7),hour:z(a/3.6e6)%24,minute:z(a/6e4)%60,second:z(a/1e3)%60,millisecond:z(a)%1e3};return Object.entries(b).filter(function(a){return 0!==a[1]}).map(function(a){return a[1]+' '+(1===a[1]?a[0]:a[0]+'s')}).join(', ')},fromCamelCase:function(a){var b=1>>(b?24:16))+', '+((c&(b?16711680:65280))>>>(b?16:8))+', '+((c&(b?65280:255))>>>(b?8:0))+(b?', '+(255&c):'')+')'},hide:function(){for(var a=arguments.length,b=Array(a),c=0;cc&&(c=b),null==c?0<=a&&a=b&&aa[1]?-1:1,d=!0,e=!1;try{for(var f,g=a.entries()[Symbol.iterator]();!(d=(f=g.next()).done);d=!0){var h=f.value,j=L(h,2),k=j[0],i=j[1];if(k===a.length-1)return c;if(0<(i-a[k+1])*c)return 0}}catch(a){e=!0,b=a}finally{try{!d&&g.return&&g.return()}finally{if(e)throw b}}},isString:function(a){return'string'==typeof a},isSymbol:function(a){return'symbol'===('undefined'==typeof a?'undefined':M(a))},isTravisCI:function(){return'TRAVIS'in process.env&&'CI'in process.env},isUndefined:function(a){return a===void 0},isUpperCase:function(a){return a===a.toUpperCase()},isValidJSON:function(a){try{return JSON.parse(a),!0}catch(a){return!1}},join:function(a){var b=1e-c&&(b='mouse',a(b),document.removeEventListener('mousemove',d)),c=e};document.addEventListener('touchstart',function(){'touch'==b||(b='touch',a(b),document.addEventListener('mousemove',d))})},once:function(a){var b=!1;return function(){if(!b){b=!0;for(var c=arguments.length,d=Array(c),e=0;ej?1:iMath.abs(a))return a+(c?' ':'')+d[0];var e=B(z(Math.log10(0>a?-a:a)/3),d.length-1),f=+((0>a?-a:a)/A(1e3,e)).toPrecision(b);return(0>a?'-':'')+f+(c?' ':'')+d[e]},primes:function(a){var b=Array.from({length:a-1}).map(function(a,b){return b+2}),c=z(y(a)),d=Array.from({length:c-1}).map(function(a,b){return b+2});return d.forEach(function(a){return b=b.filter(function(b){return 0!=b%a||b==a})}),b},promisify:function(a){return function(){for(var b=arguments.length,c=Array(b),d=0;da[a.length-1],d=a.findIndex(function(a){return c?b>=a:b<=a});return-1===d?a.length:d},splitLines:function(a){return a.split(/\r?\n/)},spreadOver:function(a){return function(b){return a.apply(void 0,s(b))}},standardDeviation:function(a){var b=1b?a.slice(0,3',"'":'\'',""":'"'}[a]||a})},union:function(c,a){return Array.from(new Set([].concat(u(c),u(a))))},uniqueElements:function(a){return[].concat(v(new Set(a)))},untildify:function(a){return a.replace(/^~($|\/|\\)/,('undefined'!=typeof require&&require('os').homedir())+'$1')},validateNumber:function(a){return!isNaN(parseFloat(a))&&isFinite(a)&&+a==a},without:function(a){for(var b=arguments.length,c=Array(1 const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); +const URLJoin = (...args) => + args + .join('/') + .replace(/[\/]+/g, '/') + .replace(/^(.+):\//, '$1://') + .replace(/^file:/, 'file:/') + .replace(/\/(\?|&|#[^!])/g, '$1') + .replace(/\?/g, '&') + .replace('&', '?'); + const UUIDGeneratorBrowser = () => ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16) @@ -178,8 +188,6 @@ const digitize = n => [...`${n}`].map(i => parseInt(i)); const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); -const distinctValuesOfArray = arr => [...new Set(arr)]; - const dropElements = (arr, func) => { while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1); return arr; @@ -351,6 +359,30 @@ const hasClass = (el, className) => el.classList.contains(className); const hasFlags = (...flags) => flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag)); +const hashBrowser = val => + crypto.subtle.digest('SHA-256', new TextEncoder('utf-8').encode(val)).then(h => { + let hexes = [], + view = new DataView(h); + for (let i = 0; i < view.byteLength; i += 4) + hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8)); + return hexes.join(''); + }); + +const crypto$2 = typeof require !== "undefined" && require('crypto'); +const hashNode = val => + new Promise(resolve => + setTimeout( + () => + resolve( + crypto$2 + .createHash('sha256') + .update(val) + .digest('hex') + ), + 0 + ) + ); + const head = arr => arr[0]; const hexToRGB = hex => { @@ -383,7 +415,7 @@ const httpGet = (url, callback, err = console.error) => { request.send(); }; -const httpPost = (url, callback, data = null, err = console.error) => { +const httpPost = (url, data, callback, err = console.error) => { const request = new XMLHttpRequest(); request.open('POST', url, true); request.setRequestHeader('Content-type', 'application/json; charset=utf-8'); @@ -415,6 +447,11 @@ const initialize2DArray = (w, h, val = null) => const initializeArrayWithRange = (end, start = 0, step = 1) => Array.from({ length: Math.ceil((end + 1 - start) / step) }).map((v, i) => i * step + start); +const initializeArrayWithRangeRight = (end, start = 0, step = 1) => + Array.from({ length: Math.ceil((end + 1 - start) / step) }).map( + (v, i, arr) => (arr.length - i - 1) * step + start + ); + const initializeArrayWithValues = (n, val = 0) => Array(n).fill(val); const intersection = (a, b) => { @@ -428,9 +465,9 @@ const invertKeyValues = obj => return acc; }, {}); -const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); +const is = (type, val) => val instanceof type; -const isArray = val => Array.isArray(val); +const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); const isArrayLike = val => { try { @@ -450,6 +487,8 @@ const isFunction = val => typeof val === 'function'; const isLowerCase = str => str === str.toLowerCase(); +const isNil = val => val === undefined || val === null; + const isNull = val => val === null; const isNumber = val => typeof val === 'number'; @@ -482,6 +521,8 @@ const isSymbol = val => typeof val === 'symbol'; const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; +const isUndefined = val => val === undefined; + const isUpperCase = str => str === str.toUpperCase(); const isValidJSON = obj => { @@ -980,6 +1021,8 @@ const unescapeHTML = str => const union = (a, b) => Array.from(new Set([...a, ...b])); +const uniqueElements = arr => [...new Set(arr)]; + const untildify = str => str.replace(/^~($|\/|\\)/, `${typeof require !== "undefined" && require('os').homedir()}$1`); const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; @@ -1001,6 +1044,6 @@ const zip = (...arrays) => { const zipObject = (props, values) => props.reduce((obj, prop, index) => (obj[prop] = values[index], obj), {}); -var imports = {JSONToFile,RGBToHex,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,average,averageBy,bottomVisible,byteSize,call,capitalize,capitalizeEveryWord,chainAsync,chunk,clampNumber,cleanObj,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,decapitalize,deepFlatten,defer,detectDeviceType,difference,differenceWith,digitize,distance,distinctValuesOfArray,dropElements,dropRight,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findLast,flatten,flip,forEachRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithValues,intersection,invertKeyValues,isAbsoluteURL,isArray,isArrayLike,isBoolean,isDivisible,isEven,isFunction,isLowerCase,isNull,isNumber,isObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthElement,objectFromPairs,objectToPairs,observeMutations,off,on,onUserInputChange,once,orderBy,palindrome,parseCookie,partition,percentile,pick,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,select,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,splitLines,spreadOver,standardDeviation,sum,sumBy,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unescapeHTML,union,untildify,validateNumber,without,words,yesNo,zip,zipObject,} +var imports = {JSONToFile,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,average,averageBy,bottomVisible,byteSize,call,capitalize,capitalizeEveryWord,chainAsync,chunk,clampNumber,cleanObj,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,decapitalize,deepFlatten,defer,detectDeviceType,difference,differenceWith,digitize,distance,dropElements,dropRight,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findLast,flatten,flip,forEachRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,intersection,invertKeyValues,is,isAbsoluteURL,isArrayLike,isBoolean,isDivisible,isEven,isFunction,isLowerCase,isNil,isNull,isNumber,isObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthElement,objectFromPairs,objectToPairs,observeMutations,off,on,onUserInputChange,once,orderBy,palindrome,parseCookie,partition,percentile,pick,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,select,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,splitLines,spreadOver,standardDeviation,sum,sumBy,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unescapeHTML,union,uniqueElements,untildify,validateNumber,without,words,yesNo,zip,zipObject,} export default imports; diff --git a/dist/_30s.js b/dist/_30s.js index 182c248d3..11acc6178 100644 --- a/dist/_30s.js +++ b/dist/_30s.js @@ -10,6 +10,16 @@ const JSONToFile = (obj, filename) => const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); +const URLJoin = (...args) => + args + .join('/') + .replace(/[\/]+/g, '/') + .replace(/^(.+):\//, '$1://') + .replace(/^file:/, 'file:/') + .replace(/\/(\?|&|#[^!])/g, '$1') + .replace(/\?/g, '&') + .replace('&', '?'); + const UUIDGeneratorBrowser = () => ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16) @@ -184,8 +194,6 @@ const digitize = n => [...`${n}`].map(i => parseInt(i)); const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); -const distinctValuesOfArray = arr => [...new Set(arr)]; - const dropElements = (arr, func) => { while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1); return arr; @@ -357,6 +365,30 @@ const hasClass = (el, className) => el.classList.contains(className); const hasFlags = (...flags) => flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag)); +const hashBrowser = val => + crypto.subtle.digest('SHA-256', new TextEncoder('utf-8').encode(val)).then(h => { + let hexes = [], + view = new DataView(h); + for (let i = 0; i < view.byteLength; i += 4) + hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8)); + return hexes.join(''); + }); + +const crypto$2 = typeof require !== "undefined" && require('crypto'); +const hashNode = val => + new Promise(resolve => + setTimeout( + () => + resolve( + crypto$2 + .createHash('sha256') + .update(val) + .digest('hex') + ), + 0 + ) + ); + const head = arr => arr[0]; const hexToRGB = hex => { @@ -389,7 +421,7 @@ const httpGet = (url, callback, err = console.error) => { request.send(); }; -const httpPost = (url, callback, data = null, err = console.error) => { +const httpPost = (url, data, callback, err = console.error) => { const request = new XMLHttpRequest(); request.open('POST', url, true); request.setRequestHeader('Content-type', 'application/json; charset=utf-8'); @@ -421,6 +453,11 @@ const initialize2DArray = (w, h, val = null) => const initializeArrayWithRange = (end, start = 0, step = 1) => Array.from({ length: Math.ceil((end + 1 - start) / step) }).map((v, i) => i * step + start); +const initializeArrayWithRangeRight = (end, start = 0, step = 1) => + Array.from({ length: Math.ceil((end + 1 - start) / step) }).map( + (v, i, arr) => (arr.length - i - 1) * step + start + ); + const initializeArrayWithValues = (n, val = 0) => Array(n).fill(val); const intersection = (a, b) => { @@ -434,9 +471,9 @@ const invertKeyValues = obj => return acc; }, {}); -const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); +const is = (type, val) => val instanceof type; -const isArray = val => Array.isArray(val); +const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); const isArrayLike = val => { try { @@ -456,6 +493,8 @@ const isFunction = val => typeof val === 'function'; const isLowerCase = str => str === str.toLowerCase(); +const isNil = val => val === undefined || val === null; + const isNull = val => val === null; const isNumber = val => typeof val === 'number'; @@ -488,6 +527,8 @@ const isSymbol = val => typeof val === 'symbol'; const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; +const isUndefined = val => val === undefined; + const isUpperCase = str => str === str.toUpperCase(); const isValidJSON = obj => { @@ -986,6 +1027,8 @@ const unescapeHTML = str => const union = (a, b) => Array.from(new Set([...a, ...b])); +const uniqueElements = arr => [...new Set(arr)]; + const untildify = str => str.replace(/^~($|\/|\\)/, `${typeof require !== "undefined" && require('os').homedir()}$1`); const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; @@ -1007,7 +1050,7 @@ const zip = (...arrays) => { const zipObject = (props, values) => props.reduce((obj, prop, index) => (obj[prop] = values[index], obj), {}); -var imports = {JSONToFile,RGBToHex,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,average,averageBy,bottomVisible,byteSize,call,capitalize,capitalizeEveryWord,chainAsync,chunk,clampNumber,cleanObj,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,decapitalize,deepFlatten,defer,detectDeviceType,difference,differenceWith,digitize,distance,distinctValuesOfArray,dropElements,dropRight,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findLast,flatten,flip,forEachRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithValues,intersection,invertKeyValues,isAbsoluteURL,isArray,isArrayLike,isBoolean,isDivisible,isEven,isFunction,isLowerCase,isNull,isNumber,isObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthElement,objectFromPairs,objectToPairs,observeMutations,off,on,onUserInputChange,once,orderBy,palindrome,parseCookie,partition,percentile,pick,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,select,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,splitLines,spreadOver,standardDeviation,sum,sumBy,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unescapeHTML,union,untildify,validateNumber,without,words,yesNo,zip,zipObject,} +var imports = {JSONToFile,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,anagrams,arrayToHtmlList,average,averageBy,bottomVisible,byteSize,call,capitalize,capitalizeEveryWord,chainAsync,chunk,clampNumber,cleanObj,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compose,copyToClipboard,countBy,countOccurrences,createElement,createEventHub,currentURL,curry,decapitalize,deepFlatten,defer,detectDeviceType,difference,differenceWith,digitize,distance,dropElements,dropRight,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterNonUnique,findLast,flatten,flip,forEachRight,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,getDaysDiffBetweenDates,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,inRange,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,intersection,invertKeyValues,is,isAbsoluteURL,isArrayLike,isBoolean,isDivisible,isEven,isFunction,isLowerCase,isNil,isNull,isNumber,isObject,isPrime,isPrimitive,isPromiseLike,isSorted,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapObject,mapValues,mask,maxBy,maxN,median,memoize,merge,minBy,minN,negate,nthElement,objectFromPairs,objectToPairs,observeMutations,off,on,onUserInputChange,once,orderBy,palindrome,parseCookie,partition,percentile,pick,pipeFunctions,pluralize,powerset,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,redirect,reducedFilter,remove,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,select,serializeCookie,setStyle,shallowClone,show,shuffle,similarity,size,sleep,sortCharactersInString,sortedIndex,splitLines,spreadOver,standardDeviation,sum,sumBy,sumPower,symmetricDifference,tail,take,takeRight,timeTaken,toCamelCase,toDecimalMark,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toggleClass,tomorrow,transform,truncateString,truthCheckCollection,unescapeHTML,union,uniqueElements,untildify,validateNumber,without,words,yesNo,zip,zipObject,} return imports; diff --git a/dist/_30s.min.js b/dist/_30s.min.js index 4a9a366ef..4bab5c6d5 100644 --- a/dist/_30s.min.js +++ b/dist/_30s.min.js @@ -1 +1 @@ -(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?module.exports=b():'function'==typeof define&&define.amd?define(b):a._30s=b()})(this,function(){'use strict';var a=Math.round,b=Math.sqrt,c=Math.log,d=Math.floor,e=Math.min,f=Math.max,g=Math.ceil;const h='undefined'!=typeof require&&require('fs'),i='undefined'!=typeof require&&require('crypto'),j=(a)=>2>=a.length?2===a.length?[a,a[1]+a[0]]:[a]:a.split('').reduce((b,c,d)=>b.concat(j(a.slice(0,d)+a.slice(d+1)).map((a)=>c+a)),[]),k=(a,b=[],c)=>(Object.keys(a).forEach((d)=>{d===c?k(a[d],b,c):!b.includes(d)&&delete a[d]}),a),l=(a,b=a.length,...c)=>b<=c.length?a(...c):l.bind(null,a,b,...c),m=(a)=>[].concat(...a.map((a)=>Array.isArray(a)?m(a):a)),n=([...c],d=32,e)=>{const[f,a]=c,b=(a,b)=>1/(1+10**((b-a)/400)),g=(c,g)=>(e||c)+d*(g-b(g?f:a,g?a:f));if(2===c.length)return[g(f,1),g(a,0)];for(let a,b=0;b{if(c===d)return!0;if(c instanceof Date&&d instanceof Date)return c.getTime()===d.getTime();if(!c||!d||'object'!=typeof c&&'object'!=typeof d)return c===d;if(null===c||void 0===c||null===d||void 0===d)return!1;if(c.prototype!==d.prototype)return!1;let e=Object.keys(c);return!(e.length!==Object.keys(d).length)&&e.every((a)=>o(c[a],d[a]))},p=(a)=>0>a?(()=>{throw new TypeError('Negative numbers are not allowed!')})():1>=a?1:a*p(a-1),q=(a,b=1)=>1==b?a.reduce((b,a)=>b.concat(a),[]):a.reduce((c,a)=>c.concat(Array.isArray(a)?q(a,b-1):a),[]),r=(...a)=>{const c=(a,b)=>b?r(b,a%b):a;return[...a].reduce((d,a)=>c(d,a))},s='undefined'!=typeof require&&require('fs'),t=()=>{const a=document.documentElement.scrollTop||document.body.scrollTop;0h.writeFile(`${b}.json`,JSON.stringify(a,null,2)),RGBToHex:(a,c,d)=>((a<<16)+(c<<8)+d).toString(16).padStart(6,'0'),UUIDGeneratorBrowser:()=>'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,(a)=>(a^crypto.getRandomValues(new Uint8Array(1))[0]&15>>a/4).toString(16)),UUIDGeneratorNode:()=>'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,(a)=>(a^i.randomBytes(1)[0]&15>>a/4).toString(16)),anagrams:j,arrayToHtmlList:(a,b)=>a.map((a)=>document.querySelector('#'+b).innerHTML+=`
  • ${a}
  • `),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,bottomVisible:()=>document.documentElement.clientHeight+window.scrollY>=(document.documentElement.scrollHeight||document.documentElement.clientHeight),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()),chainAsync:(a)=>{let b=0;const c=()=>a[b++](c);c()},chunk:(a,b)=>Array.from({length:g(a.length/b)},(c,d)=>a.slice(d*b,d*b+b)),clampNumber:(c,d,a)=>f(e(c,f(d,a)),e(d,a)),cleanObj:k,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))),copyToClipboard:(a)=>{const b=document.createElement('textarea');b.value=a,b.setAttribute('readonly',''),b.style.position='absolute',b.style.left='-9999px',document.body.appendChild(b);const c=!!(0a.map('function'==typeof b?b:(a)=>a[b]).reduce((a,b)=>(a[b]=(a[b]||0)+1,a),{}),countOccurrences:(a,b)=>a.reduce((c,a)=>a===b?c+1:c+0,0),createElement:(a)=>{const b=document.createElement('div');return b.innerHTML=a,b.firstElementChild},createEventHub:()=>({hub:Object.create(null),emit(a,b){(this.hub[a]||[]).forEach((a)=>a(b))},on(a,b){this.hub[a]||(this.hub[a]=[]),this.hub[a].push(b)},off(a,b){const c=(this.hub[a]||[]).findIndex((a)=>a===b);-1window.location.href,curry:l,decapitalize:([a,...b],c=!1)=>a.toLowerCase()+(c?b.join('').toUpperCase():b.join('')),deepFlatten:m,defer:(a,...b)=>setTimeout(a,1,...b),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))},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),distinctValuesOfArray:(a)=>[...new Set(a)],dropElements:(a,b)=>{for(;0a.slice(0,-b),elementIsVisibleInViewport:(a,b=!1)=>{const{top:c,left:d,bottom:e,right:f}=a.getBoundingClientRect(),{innerHeight:g,innerWidth:h}=window;return b?(0a.replace(/[&<>'"]/g,(a)=>({"&":'&',"<":'<',">":'>',"'":''','"':'"'})[a]||a),escapeRegExp:(a)=>a.replace(/[.*+?^${}()|[\]\\]/g,'\\$&'),everyNth:(a,b)=>a.filter((a,c)=>c%b==b-1),extendHex:(a)=>'#'+a.slice(a.startsWith('#')?1:0).split('').map((a)=>a+a).join(''),factorial:p,fibonacci:(a)=>Array.from({length:a}).reduce((a,b,c)=>a.concat(1a.filter((b)=>a.indexOf(b)===a.lastIndexOf(b)),findLast:(a,b)=>a.filter(b).slice(-1),flatten:q,flip:(a)=>(...b)=>a(b.pop(),...b),forEachRight:(a,b)=>a.slice(0).reverse().forEach(b),formatDuration:(a)=>{0>a&&(a=-a);const b={day:d(a/8.64e7),hour:d(a/3.6e6)%24,minute:d(a/6e4)%60,second:d(a/1e3)%60,millisecond:d(a)%1e3};return Object.entries(b).filter((a)=>0!==a[1]).map((a)=>a[1]+' '+(1===a[1]?a[0]:a[0]+'s')).join(', ')},fromCamelCase:(a,b='_')=>a.replace(/([a-z\d])([A-Z])/g,'$1'+b+'$2').replace(/([A-Z]+)([A-Z][a-z\d]+)/g,'$1'+b+'$2').toLowerCase(),functionName:(a)=>(console.debug(a.name),a),functions:(a,b=!1)=>(b?[...Object.keys(a),...Object.keys(Object.getPrototypeOf(a))]:Object.keys(a)).filter((b)=>'function'==typeof a[b]),gcd:r,geometricProgression:(a,b=1,e=2)=>Array.from({length:d(c(a/b)/c(e))+1}).map((a,c)=>b*e**c),getDaysDiffBetweenDates:(a,b)=>(b-a)/86400000,getScrollPosition:(a=window)=>({x:a.pageXOffset===void 0?a.scrollLeft:a.pageXOffset,y:a.pageYOffset===void 0?a.scrollTop:a.pageYOffset}),getStyle:(a,b)=>getComputedStyle(a)[b],getType:(a)=>a===void 0?'undefined':null===a?'null':a.constructor.name.toLowerCase(),getURLParameters:(a)=>a.match(/([^?=&]+)(=([^&]*))/g).reduce((b,a)=>(b[a.slice(0,a.indexOf('='))]=a.slice(a.indexOf('=')+1),b),{}),groupBy:(a,b)=>a.map('function'==typeof b?b:(a)=>a[b]).reduce((b,c,d)=>(b[c]=(b[c]||[]).concat(a[d]),b),{}),hammingDistance:(a,b)=>((a^b).toString(2).match(/1/g)||'').length,hasClass:(a,b)=>a.classList.contains(b),hasFlags:(...a)=>a.every((a)=>process.argv.includes(/^-{1,2}/.test(a)?a:'--'+a)),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=null,d=console.error)=>{const e=new XMLHttpRequest;e.open('POST',a,!0),e.setRequestHeader('Content-type','application/json; charset=utf-8'),e.onload=()=>b(e.responseText),e.onerror=()=>d(e),e.send(c)},httpsRedirect:()=>{'https:'!==location.protocol&&location.replace('https://'+location.href.split('//')[1])},inRange:(a,b,c=null)=>(c&&b>c&&(c=b),null==c?0<=a&&a=b&&a{const c=[];return a.forEach((a,d)=>a===b&&c.push(d)),c},initial:(a)=>a.slice(0,-1),initialize2DArray:(a,b,c=null)=>Array.from({length:b}).map(()=>Array.from({length:a}).fill(c)),initializeArrayWithRange:(a,b=0,c=1)=>Array.from({length:g((a+1-b)/c)}).map((a,d)=>d*c+b),initializeArrayWithValues:(a,b=0)=>Array(a).fill(b),intersection:(c,a)=>{const b=new Set(a);return c.filter((a)=>b.has(a))},invertKeyValues:(a)=>Object.keys(a).reduce((b,c)=>(b[a[c]]=c,b),{}),isAbsoluteURL:(a)=>/^[a-z][a-z0-9+.-]*:/.test(a),isArray:(a)=>Array.isArray(a),isArrayLike:(a)=>{try{return[...a],!0}catch(a){return!1}},isBoolean:(a)=>'boolean'==typeof a,isDivisible:(a,b)=>0==a%b,isEven:(a)=>0==a%2,isFunction:(a)=>'function'==typeof a,isLowerCase:(a)=>a===a.toLowerCase(),isNull:(a)=>null===a,isNumber:(a)=>'number'==typeof a,isObject:(a)=>a===Object(a),isPrime:(a)=>{const c=d(b(a));for(var e=2;e<=c;e++)if(0==a%e)return!1;return 2<=a},isPrimitive:(a)=>!['object','function'].includes(typeof a)||null===a,isPromiseLike:(a)=>null!==a&&('object'==typeof a||'function'==typeof a)&&'function'==typeof a.then,isSorted:(a)=>{const b=a[0]>a[1]?-1:1;for(let[c,d]of a.entries()){if(c===a.length-1)return b;if(0<(d-a[c+1])*b)return 0}},isString:(a)=>'string'==typeof a,isSymbol:(a)=>'symbol'==typeof a,isTravisCI:()=>'TRAVIS'in process.env&&'CI'in process.env,isUpperCase:(a)=>a===a.toUpperCase(),isValidJSON:(a)=>{try{return JSON.parse(a),!0}catch(a){return!1}},join:(a,b=',',c=b)=>a.reduce((d,e,f)=>f==a.length-2?d+e+c:f==a.length-1?d+e:d+e+b,''),last:(a)=>a[a.length-1],lcm:(...a)=>{const b=(a,c)=>c?b(c,a%c):a,c=(a,c)=>a*c/b(a,c);return[...a].reduce((d,a)=>c(d,a))},longestItem:(...a)=>[...a].sort((c,a)=>a.length-c.length)[0],lowercaseKeys:(a)=>Object.keys(a).reduce((b,c)=>(b[c.toLowerCase()]=a[c],b),{}),luhnCheck:(a)=>{let b=(a+'').split('').reverse().map((a)=>parseInt(a)),c=b.splice(0,1)[0],d=b.reduce((a,b,c)=>0==c%2?a+2*b%9||9:a+b,0);return d+=c,0==d%10},mapKeys:(a,b)=>Object.keys(a).reduce((c,d)=>(c[b(a[d],d,a)]=a[d],c),{}),mapObject:(b,c)=>((d)=>(d=[b,b.map(c)],d[0].reduce((a,b,c)=>(a[b]=d[1][c],a),{})))(),mapValues:(a,b)=>Object.keys(a).reduce((c,d)=>(c[d]=b(a[d],d,a),c),{}),mask:(a,b=4,c='*')=>(''+a).slice(0,-b).replace(/./g,c)+(''+a).slice(-b),maxBy:(a,b)=>f(...a.map('function'==typeof b?b:(a)=>a[b])),maxN:(a,b=1)=>[...a].sort((c,a)=>a-c).slice(0,b),median:(a)=>{const b=d(a.length/2),c=[...a].sort((c,a)=>c-a);return 0==a.length%2?(c[b-1]+c[b])/2:c[b]},memoize:(a)=>{const b=new Map,c=function(c){return b.has(c)?b.get(c):b.set(c,a.call(this,c))&&b.get(c)};return c.cache=b,c},merge:(...a)=>[...a].reduce((b,c)=>Object.keys(c).reduce((d,a)=>(b[a]=b.hasOwnProperty(a)?[].concat(b[a]).concat(c[a]):c[a],b),{}),{}),minBy:(a,b)=>e(...a.map('function'==typeof b?b:(a)=>a[b])),minN:(a,b=1)=>[...a].sort((c,a)=>c-a).slice(0,b),negate:(a)=>(...b)=>!a(...b),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),on:(a,b,c,d={})=>{const e=(a)=>a.target.matches(d.target)&&c.call(a.target,a);if(a.addEventListener(b,d.target?e:c,d.options||!1),d.target)return e},onUserInputChange:(a)=>{let b='mouse',c=0;const d=()=>{const e=performance.now();20>e-c&&(b='mouse',a(b),document.removeEventListener('mousemove',d)),c=e};document.addEventListener('touchstart',()=>{'touch'==b||(b='touch',a(b),document.addEventListener('mousemove',d))})},once:(a)=>{let b=!1;return function(...c){if(!b)return b=!0,a.apply(this,c)}},orderBy:(a,c,d)=>[...a].sort((e,a)=>c.reduce((b,c,f)=>{if(0===b){const[g,h]=d&&'desc'===d[f]?[a[c],e[c]]:[e[c],a[c]];b=g>h?1:g{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),{}),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),{}),pipeFunctions:(...a)=>a.reduce((a,b)=>(...c)=>b(a(...c))),pluralize:(a,b,c=b+'s')=>{const d=(a,b,c=b+'s')=>[1,-1].includes(+a)?b:c;return'object'==typeof a?(b,c)=>d(b,c,a[c]):d(a,b,c)},powerset:(a)=>a.reduce((b,a)=>b.concat(b.map((b)=>[a].concat(b))),[[]]),prettyBytes:(a,b=3,c=!0)=>{const f=['B','KB','MB','GB','TB','PB','EB','ZB','YB'];if(1>Math.abs(a))return a+(c?' ':'')+f[0];const g=e(d(Math.log10(0>a?-a:a)/3),f.length-1),h=+((0>a?-a:a)/1e3**g).toPrecision(b);return(0>a?'-':'')+h+(c?' ':'')+f[g]},primes:(a)=>{let c=Array.from({length:a-1}).map((a,b)=>b+2),e=d(b(a)),f=Array.from({length:e-1}).map((a,b)=>b+2);return f.forEach((a)=>c=c.filter((b)=>0!=b%a||b==a)),c},promisify:(a)=>(...b)=>new Promise((c,d)=>a(...b,(a,b)=>a?d(a):c(b))),pull:(a,...b)=>{let c=Array.isArray(b[0])?b[0]:b,d=a.filter((a)=>!c.includes(a));a.length=0,d.forEach((b)=>a.push(b))},pullAtIndex:(a,b)=>{let c=[],d=a.map((a,d)=>b.includes(d)?c.push(a):a).filter((a,c)=>!b.includes(c));return a.length=0,d.forEach((b)=>a.push(b)),c},pullAtValue:(a,b)=>{let c=[],d=a.forEach((a)=>b.includes(a)?c.push(a):a),e=a.filter((a)=>!b.includes(a));return a.length=0,e.forEach((b)=>a.push(b)),c},randomHexColorCode:()=>{let a=(0|1048575*Math.random()).toString(16);return'#'+(6===a.length?a:(0|15*Math.random()).toString(16)+a)},randomIntArrayInRange:(a,b,c=1)=>Array.from({length:c},()=>d(Math.random()*(b-a+1))+a),randomIntegerInRange:(a,b)=>d(Math.random()*(b-a+1))+a,randomNumberInRange:(a,b)=>Math.random()*(b-a)+a,readFileLines:(a)=>s.readFileSync(a).toString('UTF8').split('\n'),redirect:(a,b=!0)=>b?window.location.href=a:window.location.replace(a),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)),[]):[],reverseString:(a)=>[...a].join(''),round:(b,c=0)=>+`${a(`${b}e${c}`)}e-${c}`,runAsync:(a)=>{const b=`var fn = ${a.toString()}; postMessage(fn());`,c=new Worker(URL.createObjectURL(new Blob([b]),{type:'application/javascript; charset=utf-8'}));return new Promise((a,b)=>{c.onmessage=({data:b})=>{a(b),c.terminate()},c.onerror=(a)=>{b(a),c.terminate()}})},runPromisesInSeries:(a)=>a.reduce((a,b)=>a.then(b),Promise.resolve()),sample:(a)=>a[d(Math.random()*a.length)],sampleSize:([...a],b=1)=>{for(let c=a.length;c;){const b=d(Math.random()*c--);[a[c],a[b]]=[a[b],a[c]]}return a.slice(0,b)},scrollToTop:t,sdbm:(a)=>{let b=a.split('');return b.reduce((a,b)=>a=b.charCodeAt(0)+(a<<6)+(a<<16)-a,0)},select:(a,...b)=>[...b].map((b)=>b.split('.').reduce((a,b)=>a&&a[b],a)),serializeCookie:(a,b)=>`${encodeURIComponent(a)}=${encodeURIComponent(b)}`,setStyle:(a,b,c)=>a.style[b]=c,shallowClone:(a)=>Object.assign({},a),show:(...a)=>[...a].forEach((a)=>a.style.display=''),shuffle:([...a])=>{for(let b=a.length;b;){const c=d(Math.random()*b--);[a[b],a[c]]=[a[c],a[b]]}return a},similarity:(a,b)=>a.filter((a)=>b.includes(a)),size:(a)=>Array.isArray(a)?a.length:a&&'object'==typeof a?a.size||a.length||Object.keys(a).length:'string'==typeof a?new Blob([a]).size:0,sleep:(a)=>new Promise((b)=>setTimeout(b,a)),sortCharactersInString:(a)=>[...a].sort((c,a)=>c.localeCompare(a)).join(''),sortedIndex:(a,b)=>{const c=a[0]>a[a.length-1],d=a.findIndex((a)=>c?b>=a:b<=a);return-1===d?a.length:d},splitLines:(a)=>a.split(/\r?\n/),spreadOver:(a)=>(b)=>a(...b),standardDeviation:(a,c=!1)=>{const d=a.reduce((a,b)=>a+b,0)/a.length;return b(a.reduce((a,b)=>a.concat((b-d)**2),[]).reduce((a,b)=>a+b,0)/(a.length-(c?0:1)))},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))]},tail:(a)=>1a.slice(0,b),takeRight:(a,b=1)=>a.slice(a.length-b,a.length),timeTaken:(a)=>{console.time('timeTaken');const b=a();return console.timeEnd('timeTaken'),b},toCamelCase:(a)=>{let b=a&&a.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map((a)=>a.slice(0,1).toUpperCase()+a.slice(1).toLowerCase()).join('');return b.slice(0,1).toLowerCase()+b.slice(1)},toDecimalMark:(a)=>a.toLocaleString('en-US'),toKebabCase:(a)=>a&&a.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map((a)=>a.toLowerCase()).join('-'),toOrdinalSuffix:(a)=>{const b=parseInt(a),c=[b%10,b%100],d=['st','nd','rd','th'];return[1,2,3,4].includes(c[0])&&![11,12,13,14,15,16,17,18,19].includes(c[1])?b+d[c[0]-1]:b+d[3]},toSafeInteger:(b)=>a(f(e(b,Number.MAX_SAFE_INTEGER),Number.MIN_SAFE_INTEGER)),toSnakeCase:(a)=>a&&a.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map((a)=>a.toLowerCase()).join('_'),toggleClass:(a,b)=>a.classList.toggle(b),tomorrow:()=>new Date(new Date().getTime()+8.64e7).toISOString().split('T')[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]),unescapeHTML:(a)=>a.replace(/&|<|>|'|"/g,(a)=>({"&":'&',"<":'<',">":'>',"'":'\'',""":'"'})[a]||a),union:(c,a)=>Array.from(new Set([...c,...a])),untildify:(a)=>a.replace(/^~($|\/|\\)/,`${'undefined'!=typeof require&&require('os').homedir()}$1`),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),yesNo:(a,b=!1)=>!!/^(y|yes)$/i.test(a)||!/^(n|no)$/i.test(a)&&b,zip:(...a)=>{const b=f(...a.map((a)=>a.length));return Array.from({length:b}).map((b,c)=>Array.from({length:a.length},(b,d)=>a[d][c]))},zipObject:(a,b)=>a.reduce((a,c,d)=>(a[c]=b[d],a),{})}}); +(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?module.exports=b():'function'==typeof define&&define.amd?define(b):a._30s=b()})(this,function(){'use strict';var a=Math.round,b=Math.sqrt,c=Math.log,d=Math.floor,e=Math.min,f=Math.max,g=Math.ceil;const h='undefined'!=typeof require&&require('fs'),i='undefined'!=typeof require&&require('crypto'),j=(a)=>2>=a.length?2===a.length?[a,a[1]+a[0]]:[a]:a.split('').reduce((b,c,d)=>b.concat(j(a.slice(0,d)+a.slice(d+1)).map((a)=>c+a)),[]),k=(a,b=[],c)=>(Object.keys(a).forEach((d)=>{d===c?k(a[d],b,c):!b.includes(d)&&delete a[d]}),a),l=(a,b=a.length,...c)=>b<=c.length?a(...c):l.bind(null,a,b,...c),m=(a)=>[].concat(...a.map((a)=>Array.isArray(a)?m(a):a)),n=([...c],d=32,e)=>{const[f,a]=c,b=(a,b)=>1/(1+10**((b-a)/400)),g=(c,g)=>(e||c)+d*(g-b(g?f:a,g?a:f));if(2===c.length)return[g(f,1),g(a,0)];for(let a,b=0;b{if(c===d)return!0;if(c instanceof Date&&d instanceof Date)return c.getTime()===d.getTime();if(!c||!d||'object'!=typeof c&&'object'!=typeof d)return c===d;if(null===c||void 0===c||null===d||void 0===d)return!1;if(c.prototype!==d.prototype)return!1;let e=Object.keys(c);return!(e.length!==Object.keys(d).length)&&e.every((a)=>o(c[a],d[a]))},p=(a)=>0>a?(()=>{throw new TypeError('Negative numbers are not allowed!')})():1>=a?1:a*p(a-1),q=(a,b=1)=>1==b?a.reduce((b,a)=>b.concat(a),[]):a.reduce((c,a)=>c.concat(Array.isArray(a)?q(a,b-1):a),[]),r=(...a)=>{const c=(a,b)=>b?r(b,a%b):a;return[...a].reduce((d,a)=>c(d,a))},s='undefined'!=typeof require&&require('crypto'),t='undefined'!=typeof require&&require('fs'),u=()=>{const a=document.documentElement.scrollTop||document.body.scrollTop;0h.writeFile(`${b}.json`,JSON.stringify(a,null,2)),RGBToHex:(a,c,d)=>((a<<16)+(c<<8)+d).toString(16).padStart(6,'0'),URLJoin:(...a)=>a.join('/').replace(/[\/]+/g,'/').replace(/^(.+):\//,'$1://').replace(/^file:/,'file:/').replace(/\/(\?|&|#[^!])/g,'$1').replace(/\?/g,'&').replace('&','?'),UUIDGeneratorBrowser:()=>'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,(a)=>(a^crypto.getRandomValues(new Uint8Array(1))[0]&15>>a/4).toString(16)),UUIDGeneratorNode:()=>'10000000-1000-4000-8000-100000000000'.replace(/[018]/g,(a)=>(a^i.randomBytes(1)[0]&15>>a/4).toString(16)),anagrams:j,arrayToHtmlList:(a,b)=>a.map((a)=>document.querySelector('#'+b).innerHTML+=`
  • ${a}
  • `),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,bottomVisible:()=>document.documentElement.clientHeight+window.scrollY>=(document.documentElement.scrollHeight||document.documentElement.clientHeight),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()),chainAsync:(a)=>{let b=0;const c=()=>a[b++](c);c()},chunk:(a,b)=>Array.from({length:g(a.length/b)},(c,d)=>a.slice(d*b,d*b+b)),clampNumber:(c,d,a)=>f(e(c,f(d,a)),e(d,a)),cleanObj:k,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))),copyToClipboard:(a)=>{const b=document.createElement('textarea');b.value=a,b.setAttribute('readonly',''),b.style.position='absolute',b.style.left='-9999px',document.body.appendChild(b);const c=!!(0a.map('function'==typeof b?b:(a)=>a[b]).reduce((a,b)=>(a[b]=(a[b]||0)+1,a),{}),countOccurrences:(a,b)=>a.reduce((c,a)=>a===b?c+1:c+0,0),createElement:(a)=>{const b=document.createElement('div');return b.innerHTML=a,b.firstElementChild},createEventHub:()=>({hub:Object.create(null),emit(a,b){(this.hub[a]||[]).forEach((a)=>a(b))},on(a,b){this.hub[a]||(this.hub[a]=[]),this.hub[a].push(b)},off(a,b){const c=(this.hub[a]||[]).findIndex((a)=>a===b);-1window.location.href,curry:l,decapitalize:([a,...b],c=!1)=>a.toLowerCase()+(c?b.join('').toUpperCase():b.join('')),deepFlatten:m,defer:(a,...b)=>setTimeout(a,1,...b),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))},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),dropElements:(a,b)=>{for(;0a.slice(0,-b),elementIsVisibleInViewport:(a,b=!1)=>{const{top:c,left:d,bottom:e,right:f}=a.getBoundingClientRect(),{innerHeight:g,innerWidth:h}=window;return b?(0a.replace(/[&<>'"]/g,(a)=>({"&":'&',"<":'<',">":'>',"'":''','"':'"'})[a]||a),escapeRegExp:(a)=>a.replace(/[.*+?^${}()|[\]\\]/g,'\\$&'),everyNth:(a,b)=>a.filter((a,c)=>c%b==b-1),extendHex:(a)=>'#'+a.slice(a.startsWith('#')?1:0).split('').map((a)=>a+a).join(''),factorial:p,fibonacci:(a)=>Array.from({length:a}).reduce((a,b,c)=>a.concat(1a.filter((b)=>a.indexOf(b)===a.lastIndexOf(b)),findLast:(a,b)=>a.filter(b).slice(-1),flatten:q,flip:(a)=>(...b)=>a(b.pop(),...b),forEachRight:(a,b)=>a.slice(0).reverse().forEach(b),formatDuration:(a)=>{0>a&&(a=-a);const b={day:d(a/8.64e7),hour:d(a/3.6e6)%24,minute:d(a/6e4)%60,second:d(a/1e3)%60,millisecond:d(a)%1e3};return Object.entries(b).filter((a)=>0!==a[1]).map((a)=>a[1]+' '+(1===a[1]?a[0]:a[0]+'s')).join(', ')},fromCamelCase:(a,b='_')=>a.replace(/([a-z\d])([A-Z])/g,'$1'+b+'$2').replace(/([A-Z]+)([A-Z][a-z\d]+)/g,'$1'+b+'$2').toLowerCase(),functionName:(a)=>(console.debug(a.name),a),functions:(a,b=!1)=>(b?[...Object.keys(a),...Object.keys(Object.getPrototypeOf(a))]:Object.keys(a)).filter((b)=>'function'==typeof a[b]),gcd:r,geometricProgression:(a,b=1,e=2)=>Array.from({length:d(c(a/b)/c(e))+1}).map((a,c)=>b*e**c),getDaysDiffBetweenDates:(a,b)=>(b-a)/86400000,getScrollPosition:(a=window)=>({x:a.pageXOffset===void 0?a.scrollLeft:a.pageXOffset,y:a.pageYOffset===void 0?a.scrollTop:a.pageYOffset}),getStyle:(a,b)=>getComputedStyle(a)[b],getType:(a)=>a===void 0?'undefined':null===a?'null':a.constructor.name.toLowerCase(),getURLParameters:(a)=>a.match(/([^?=&]+)(=([^&]*))/g).reduce((b,a)=>(b[a.slice(0,a.indexOf('='))]=a.slice(a.indexOf('=')+1),b),{}),groupBy:(a,b)=>a.map('function'==typeof b?b:(a)=>a[b]).reduce((b,c,d)=>(b[c]=(b[c]||[]).concat(a[d]),b),{}),hammingDistance:(a,b)=>((a^b).toString(2).match(/1/g)||'').length,hasClass:(a,b)=>a.classList.contains(b),hasFlags:(...a)=>a.every((a)=>process.argv.includes(/^-{1,2}/.test(a)?a:'--'+a)),hashBrowser:(a)=>crypto.subtle.digest('SHA-256',new TextEncoder('utf-8').encode(a)).then((a)=>{let b=[],c=new DataView(a);for(let d=0;dnew Promise((b)=>setTimeout(()=>b(s.createHash('sha256').update(a).digest('hex')),0)),head:(a)=>a[0],hexToRGB:(a)=>{let b=!1,c=a.slice(a.startsWith('#')?1:0);return 3===c.length?c=[...c].map((a)=>a+a).join(''):8===c.length&&(b=!0),c=parseInt(c,16),'rgb'+(b?'a':'')+'('+(c>>>(b?24:16))+', '+((c&(b?16711680:65280))>>>(b?16:8))+', '+((c&(b?65280:255))>>>(b?8:0))+(b?`, ${255&c}`:'')+')'},hide:(...a)=>[...a].forEach((a)=>a.style.display='none'),httpGet:(a,b,c=console.error)=>{const d=new XMLHttpRequest;d.open('GET',a,!0),d.onload=()=>b(d.responseText),d.onerror=()=>c(d),d.send()},httpPost:(a,b,c,d=console.error)=>{const e=new XMLHttpRequest;e.open('POST',a,!0),e.setRequestHeader('Content-type','application/json; charset=utf-8'),e.onload=()=>c(e.responseText),e.onerror=()=>d(e),e.send(b)},httpsRedirect:()=>{'https:'!==location.protocol&&location.replace('https://'+location.href.split('//')[1])},inRange:(a,b,c=null)=>(c&&b>c&&(c=b),null==c?0<=a&&a=b&&a{const c=[];return a.forEach((a,d)=>a===b&&c.push(d)),c},initial:(a)=>a.slice(0,-1),initialize2DArray:(a,b,c=null)=>Array.from({length:b}).map(()=>Array.from({length:a}).fill(c)),initializeArrayWithRange:(a,b=0,c=1)=>Array.from({length:g((a+1-b)/c)}).map((a,d)=>d*c+b),initializeArrayWithRangeRight:(a,b=0,c=1)=>Array.from({length:g((a+1-b)/c)}).map((a,d,e)=>(e.length-d-1)*c+b),initializeArrayWithValues:(a,b=0)=>Array(a).fill(b),intersection:(c,a)=>{const b=new Set(a);return c.filter((a)=>b.has(a))},invertKeyValues:(a)=>Object.keys(a).reduce((b,c)=>(b[a[c]]=c,b),{}),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,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),isPrime:(a)=>{const c=d(b(a));for(var e=2;e<=c;e++)if(0==a%e)return!1;return 2<=a},isPrimitive:(a)=>!['object','function'].includes(typeof a)||null===a,isPromiseLike:(a)=>null!==a&&('object'==typeof a||'function'==typeof a)&&'function'==typeof a.then,isSorted:(a)=>{const b=a[0]>a[1]?-1:1;for(let[c,d]of a.entries()){if(c===a.length-1)return b;if(0<(d-a[c+1])*b)return 0}},isString:(a)=>'string'==typeof a,isSymbol:(a)=>'symbol'==typeof a,isTravisCI:()=>'TRAVIS'in process.env&&'CI'in process.env,isUndefined:(a)=>a===void 0,isUpperCase:(a)=>a===a.toUpperCase(),isValidJSON:(a)=>{try{return JSON.parse(a),!0}catch(a){return!1}},join:(a,b=',',c=b)=>a.reduce((d,e,f)=>f==a.length-2?d+e+c:f==a.length-1?d+e:d+e+b,''),last:(a)=>a[a.length-1],lcm:(...a)=>{const b=(a,c)=>c?b(c,a%c):a,c=(a,c)=>a*c/b(a,c);return[...a].reduce((d,a)=>c(d,a))},longestItem:(...a)=>[...a].sort((c,a)=>a.length-c.length)[0],lowercaseKeys:(a)=>Object.keys(a).reduce((b,c)=>(b[c.toLowerCase()]=a[c],b),{}),luhnCheck:(a)=>{let b=(a+'').split('').reverse().map((a)=>parseInt(a)),c=b.splice(0,1)[0],d=b.reduce((a,b,c)=>0==c%2?a+2*b%9||9:a+b,0);return d+=c,0==d%10},mapKeys:(a,b)=>Object.keys(a).reduce((c,d)=>(c[b(a[d],d,a)]=a[d],c),{}),mapObject:(b,c)=>((d)=>(d=[b,b.map(c)],d[0].reduce((a,b,c)=>(a[b]=d[1][c],a),{})))(),mapValues:(a,b)=>Object.keys(a).reduce((c,d)=>(c[d]=b(a[d],d,a),c),{}),mask:(a,b=4,c='*')=>(''+a).slice(0,-b).replace(/./g,c)+(''+a).slice(-b),maxBy:(a,b)=>f(...a.map('function'==typeof b?b:(a)=>a[b])),maxN:(a,b=1)=>[...a].sort((c,a)=>a-c).slice(0,b),median:(a)=>{const b=d(a.length/2),c=[...a].sort((c,a)=>c-a);return 0==a.length%2?(c[b-1]+c[b])/2:c[b]},memoize:(a)=>{const b=new Map,c=function(c){return b.has(c)?b.get(c):b.set(c,a.call(this,c))&&b.get(c)};return c.cache=b,c},merge:(...a)=>[...a].reduce((b,c)=>Object.keys(c).reduce((d,a)=>(b[a]=b.hasOwnProperty(a)?[].concat(b[a]).concat(c[a]):c[a],b),{}),{}),minBy:(a,b)=>e(...a.map('function'==typeof b?b:(a)=>a[b])),minN:(a,b=1)=>[...a].sort((c,a)=>c-a).slice(0,b),negate:(a)=>(...b)=>!a(...b),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),on:(a,b,c,d={})=>{const e=(a)=>a.target.matches(d.target)&&c.call(a.target,a);if(a.addEventListener(b,d.target?e:c,d.options||!1),d.target)return e},onUserInputChange:(a)=>{let b='mouse',c=0;const d=()=>{const e=performance.now();20>e-c&&(b='mouse',a(b),document.removeEventListener('mousemove',d)),c=e};document.addEventListener('touchstart',()=>{'touch'==b||(b='touch',a(b),document.addEventListener('mousemove',d))})},once:(a)=>{let b=!1;return function(...c){if(!b)return b=!0,a.apply(this,c)}},orderBy:(a,c,d)=>[...a].sort((e,a)=>c.reduce((b,c,f)=>{if(0===b){const[g,h]=d&&'desc'===d[f]?[a[c],e[c]]:[e[c],a[c]];b=g>h?1:g{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),{}),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),{}),pipeFunctions:(...a)=>a.reduce((a,b)=>(...c)=>b(a(...c))),pluralize:(a,b,c=b+'s')=>{const d=(a,b,c=b+'s')=>[1,-1].includes(+a)?b:c;return'object'==typeof a?(b,c)=>d(b,c,a[c]):d(a,b,c)},powerset:(a)=>a.reduce((b,a)=>b.concat(b.map((b)=>[a].concat(b))),[[]]),prettyBytes:(a,b=3,c=!0)=>{const f=['B','KB','MB','GB','TB','PB','EB','ZB','YB'];if(1>Math.abs(a))return a+(c?' ':'')+f[0];const g=e(d(Math.log10(0>a?-a:a)/3),f.length-1),h=+((0>a?-a:a)/1e3**g).toPrecision(b);return(0>a?'-':'')+h+(c?' ':'')+f[g]},primes:(a)=>{let c=Array.from({length:a-1}).map((a,b)=>b+2),e=d(b(a)),f=Array.from({length:e-1}).map((a,b)=>b+2);return f.forEach((a)=>c=c.filter((b)=>0!=b%a||b==a)),c},promisify:(a)=>(...b)=>new Promise((c,d)=>a(...b,(a,b)=>a?d(a):c(b))),pull:(a,...b)=>{let c=Array.isArray(b[0])?b[0]:b,d=a.filter((a)=>!c.includes(a));a.length=0,d.forEach((b)=>a.push(b))},pullAtIndex:(a,b)=>{let c=[],d=a.map((a,d)=>b.includes(d)?c.push(a):a).filter((a,c)=>!b.includes(c));return a.length=0,d.forEach((b)=>a.push(b)),c},pullAtValue:(a,b)=>{let c=[],d=a.forEach((a)=>b.includes(a)?c.push(a):a),e=a.filter((a)=>!b.includes(a));return a.length=0,e.forEach((b)=>a.push(b)),c},randomHexColorCode:()=>{let a=(0|1048575*Math.random()).toString(16);return'#'+(6===a.length?a:(0|15*Math.random()).toString(16)+a)},randomIntArrayInRange:(a,b,c=1)=>Array.from({length:c},()=>d(Math.random()*(b-a+1))+a),randomIntegerInRange:(a,b)=>d(Math.random()*(b-a+1))+a,randomNumberInRange:(a,b)=>Math.random()*(b-a)+a,readFileLines:(a)=>t.readFileSync(a).toString('UTF8').split('\n'),redirect:(a,b=!0)=>b?window.location.href=a:window.location.replace(a),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)),[]):[],reverseString:(a)=>[...a].join(''),round:(b,c=0)=>+`${a(`${b}e${c}`)}e-${c}`,runAsync:(a)=>{const b=`var fn = ${a.toString()}; postMessage(fn());`,c=new Worker(URL.createObjectURL(new Blob([b]),{type:'application/javascript; charset=utf-8'}));return new Promise((a,b)=>{c.onmessage=({data:b})=>{a(b),c.terminate()},c.onerror=(a)=>{b(a),c.terminate()}})},runPromisesInSeries:(a)=>a.reduce((a,b)=>a.then(b),Promise.resolve()),sample:(a)=>a[d(Math.random()*a.length)],sampleSize:([...a],b=1)=>{for(let c=a.length;c;){const b=d(Math.random()*c--);[a[c],a[b]]=[a[b],a[c]]}return a.slice(0,b)},scrollToTop:u,sdbm:(a)=>{let b=a.split('');return b.reduce((a,b)=>a=b.charCodeAt(0)+(a<<6)+(a<<16)-a,0)},select:(a,...b)=>[...b].map((b)=>b.split('.').reduce((a,b)=>a&&a[b],a)),serializeCookie:(a,b)=>`${encodeURIComponent(a)}=${encodeURIComponent(b)}`,setStyle:(a,b,c)=>a.style[b]=c,shallowClone:(a)=>Object.assign({},a),show:(...a)=>[...a].forEach((a)=>a.style.display=''),shuffle:([...a])=>{for(let b=a.length;b;){const c=d(Math.random()*b--);[a[b],a[c]]=[a[c],a[b]]}return a},similarity:(a,b)=>a.filter((a)=>b.includes(a)),size:(a)=>Array.isArray(a)?a.length:a&&'object'==typeof a?a.size||a.length||Object.keys(a).length:'string'==typeof a?new Blob([a]).size:0,sleep:(a)=>new Promise((b)=>setTimeout(b,a)),sortCharactersInString:(a)=>[...a].sort((c,a)=>c.localeCompare(a)).join(''),sortedIndex:(a,b)=>{const c=a[0]>a[a.length-1],d=a.findIndex((a)=>c?b>=a:b<=a);return-1===d?a.length:d},splitLines:(a)=>a.split(/\r?\n/),spreadOver:(a)=>(b)=>a(...b),standardDeviation:(a,c=!1)=>{const d=a.reduce((a,b)=>a+b,0)/a.length;return b(a.reduce((a,b)=>a.concat((b-d)**2),[]).reduce((a,b)=>a+b,0)/(a.length-(c?0:1)))},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))]},tail:(a)=>1a.slice(0,b),takeRight:(a,b=1)=>a.slice(a.length-b,a.length),timeTaken:(a)=>{console.time('timeTaken');const b=a();return console.timeEnd('timeTaken'),b},toCamelCase:(a)=>{let b=a&&a.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map((a)=>a.slice(0,1).toUpperCase()+a.slice(1).toLowerCase()).join('');return b.slice(0,1).toLowerCase()+b.slice(1)},toDecimalMark:(a)=>a.toLocaleString('en-US'),toKebabCase:(a)=>a&&a.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map((a)=>a.toLowerCase()).join('-'),toOrdinalSuffix:(a)=>{const b=parseInt(a),c=[b%10,b%100],d=['st','nd','rd','th'];return[1,2,3,4].includes(c[0])&&![11,12,13,14,15,16,17,18,19].includes(c[1])?b+d[c[0]-1]:b+d[3]},toSafeInteger:(b)=>a(f(e(b,Number.MAX_SAFE_INTEGER),Number.MIN_SAFE_INTEGER)),toSnakeCase:(a)=>a&&a.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map((a)=>a.toLowerCase()).join('_'),toggleClass:(a,b)=>a.classList.toggle(b),tomorrow:()=>new Date(new Date().getTime()+8.64e7).toISOString().split('T')[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]),unescapeHTML:(a)=>a.replace(/&|<|>|'|"/g,(a)=>({"&":'&',"<":'<',">":'>',"'":'\'',""":'"'})[a]||a),union:(c,a)=>Array.from(new Set([...c,...a])),uniqueElements:(a)=>[...new Set(a)],untildify:(a)=>a.replace(/^~($|\/|\\)/,`${'undefined'!=typeof require&&require('os').homedir()}$1`),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),yesNo:(a,b=!1)=>!!/^(y|yes)$/i.test(a)||!/^(n|no)$/i.test(a)&&b,zip:(...a)=>{const b=f(...a.map((a)=>a.length));return Array.from({length:b}).map((b,c)=>Array.from({length:a.length},(b,d)=>a[d][c]))},zipObject:(a,b)=>a.reduce((a,c,d)=>(a[c]=b[d],a),{})}}); diff --git a/snippets_archive/README.md b/snippets_archive/README.md index bd7001585..e51a9be23 100644 --- a/snippets_archive/README.md +++ b/snippets_archive/README.md @@ -6,24 +6,78 @@ These snippets, while useful and interesting, didn't quite make it into the repo ## Table of Contents -* [`binarySearch`](#binarysearch) +* [`JSONToDate`](#jsontodate) * [`speechSynthesis`](#speechsynthesis) +* [`binarySearch`](#binarysearch) +* [`collatz`](#collatz) * [`countVowels`](#countvowels) * [`factors`](#factors) * [`fibonacciCountUntilNum`](#fibonaccicountuntilnum) * [`fibonacciUntilNum`](#fibonacciuntilnum) -* [`howManyTimes`](#howmanytimes) * [`httpDelete`](#httpdelete) -* [`collatz`](#collatz) +* [`httpPut`](#httpput) * [`isArmstrongNumber`](#isarmstrongnumber) -* [`JSONToDate`](#jsontodate) * [`quickSort`](#quicksort) * [`removeVowels`](#removevowels) * [`solveRPN`](#solverpn) -* [`httpPut`](#httpput) +* [`howManyTimes`](#howmanytimes) --- +### JSONToDate + +Converts a JSON object to a date. + +Use `Date()`, to convert dates in JSON format to readable format (`dd/mm/yyyy`). + +```js +const JSONToDate = arr => { + const dt = new Date(parseInt(arr.toString().substr(6))); + return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`; +}; +``` + +
    +Examples + +```js +JSONToDate(/Date(1489525200000)/); // "14/3/2017" +``` + +
    + +
    [⬆ Back to top](#table-of-contents) + + +### speechSynthesis + +Performs speech synthesis (experimental). + +Use `SpeechSynthesisUtterance.voice` and `window.speechSynthesis.getVoices()` to convert a message to speech. +Use `window.speechSynthesis.speak()` to play the message. + +Learn more about the [SpeechSynthesisUtterance interface of the Web Speech API](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance). + +```js +const speechSynthesis = message => { + const msg = new SpeechSynthesisUtterance(message); + msg.voice = window.speechSynthesis.getVoices()[0]; + window.speechSynthesis.speak(msg); +}; +``` + +
    +Examples + +```js +speechSynthesis('Hello, World'); // // plays the message +``` + +
    + +
    [⬆ Back to top](#table-of-contents) + + ### binarySearch Use recursion. Similar to `Array.indexOf()` that finds the index of a value within an array. @@ -57,28 +111,21 @@ binarySearch([1, 4, 6, 7, 12, 13, 15, 18, 19, 20, 22, 24], 21); // -1
    [⬆ Back to top](#table-of-contents) -### speechSynthesis +### collatz -Performs speech synthesis (experimental). +Applies the Collatz algorithm. -Use `SpeechSynthesisUtterance.voice` and `window.speechSynthesis.getVoices()` to convert a message to speech. -Use `window.speechSynthesis.speak()` to play the message. - -Learn more about the [SpeechSynthesisUtterance interface of the Web Speech API](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance). +If `n` is even, return `n/2`. Otherwise, return `3n+1`. ```js -const speechSynthesis = message => { - const msg = new SpeechSynthesisUtterance(message); - msg.voice = window.speechSynthesis.getVoices()[0]; - window.speechSynthesis.speak(msg); -}; +const collatz = n => (n % 2 == 0 ? n / 2 : 3 * n + 1); ```
    Examples ```js -speechSynthesis('Hello, World'); // // plays the message +collatz(8); // 4 ```
    @@ -213,44 +260,6 @@ fibonacciUntilNum(10); // [ 0, 1, 1, 2, 3, 5, 8 ]
    [⬆ Back to top](#table-of-contents) -### howManyTimes - -Returns the number of times `num` can be divided by `divisor` (integer or fractional) without getting a fractional answer. -Works for both negative and positive integers. - -If `divisor` is `-1` or `1` return `Infinity`. -If `divisor` is `-0` or `0` return `0`. -Otherwise, keep dividing `num` with `divisor` and incrementing `i`, while the result is an integer. -Return the number of times the loop was executed, `i`. - -```js -const howManyTimes = (num, divisor) => { - if (divisor === 1 || divisor === -1) return Infinity; - if (divisor === 0) return 0; - let i = 0; - while (Number.isInteger(num / divisor)) { - i++; - num = num / divisor; - } - return i; -}; -``` - -
    -Examples - -```js -howManyTimes(100, 2); // 2 -howManyTimes(100, 2.5); // 2 -howManyTimes(100, 0); // 0 -howManyTimes(100, -1); // Infinity -``` - -
    - -
    [⬆ Back to top](#table-of-contents) - - ### httpDelete Makes a `DELETE` request to the passed URL. @@ -284,21 +293,36 @@ httpDelete('https://website.com/users/123', request => {
    [⬆ Back to top](#table-of-contents) -### collatz +### httpPut -Applies the Collatz algorithm. +Makes a `PUT` request to the passed URL. -If `n` is even, return `n/2`. Otherwise, return `3n+1`. +Use `XMLHttpRequest` web api to make a `put` request to the given `url`. +Set the value of an `HTTP` request header with `setRequestHeader` method. +Handle the `onload` event, by running the provided `callback` function. +Handle the `onerror` event, by running the provided `err` function. +Omit the last argument, `err` to log the request to the console's error stream by default. ```js -const collatz = n => (n % 2 == 0 ? n / 2 : 3 * n + 1); +const httpPut = (url, data, callback, err = console.error) => { + const request = new XMLHttpRequest(); + request.open("PUT", url, true); + request.setRequestHeader('Content-type','application/json; charset=utf-8'); + request.onload = () => callback(request); + request.onerror = () => err(request); + request.send(data); +}; ```
    Examples ```js -collatz(8); // 4 +const password = "fooBaz"; +const data = JSON.stringify(password); +httpPut('https://website.com/users/123', data, request => { + console.log(request.responseText); +}); // 'Updates a user's password in database' ```
    @@ -332,31 +356,6 @@ isArmstrongNumber(56); // false
    [⬆ Back to top](#table-of-contents) -### JSONToDate - -Converts a JSON object to a date. - -Use `Date()`, to convert dates in JSON format to readable format (`dd/mm/yyyy`). - -```js -const JSONToDate = arr => { - const dt = new Date(parseInt(arr.toString().substr(6))); - return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`; -}; -``` - -
    -Examples - -```js -JSONToDate(/Date(1489525200000)/); // "14/3/2017" -``` - -
    - -
    [⬆ Back to top](#table-of-contents) - - ### quickSort QuickSort an Array (ascending sort by default). @@ -467,24 +466,26 @@ solveRPN('2 3 ^'); // 8
    [⬆ Back to top](#table-of-contents) -### httpPut +### howManyTimes -Makes a `PUT` request to the passed URL. +Returns the number of times `num` can be divided by `divisor` (integer or fractional) without getting a fractional answer. +Works for both negative and positive integers. -Use `XMLHttpRequest` web api to make a `put` request to the given `url`. -Set the value of an `HTTP` request header with `setRequestHeader` method. -Handle the `onload` event, by running the provided `callback` function. -Handle the `onerror` event, by running the provided `err` function. -Omit the last argument, `err` to log the request to the console's error stream by default. +If `divisor` is `-1` or `1` return `Infinity`. +If `divisor` is `-0` or `0` return `0`. +Otherwise, keep dividing `num` with `divisor` and incrementing `i`, while the result is an integer. +Return the number of times the loop was executed, `i`. ```js -const httpPut = (url, data, callback, err = console.error) => { - const request = new XMLHttpRequest(); - request.open("PUT", url, true); - request.setRequestHeader('Content-type','application/json; charset=utf-8'); - request.onload = () => callback(request); - request.onerror = () => err(request); - request.send(data); +const howManyTimes = (num, divisor) => { + if (divisor === 1 || divisor === -1) return Infinity; + if (divisor === 0) return 0; + let i = 0; + while (Number.isInteger(num / divisor)) { + i++; + num = num / divisor; + } + return i; }; ``` @@ -492,11 +493,10 @@ const httpPut = (url, data, callback, err = console.error) => { Examples ```js -const password = "fooBaz"; -const data = JSON.stringify(password); -httpPut('https://website.com/users/123', data, request => { - console.log(request.responseText); -}); // 'Updates a user's password in database' +howManyTimes(100, 2); // 2 +howManyTimes(100, 2.5); // 2 +howManyTimes(100, 0); // 0 +howManyTimes(100, -1); // Infinity ``` diff --git a/test/hashBrowser/hashBrowser.js b/test/hashBrowser/hashBrowser.js new file mode 100644 index 000000000..59db15021 --- /dev/null +++ b/test/hashBrowser/hashBrowser.js @@ -0,0 +1,9 @@ +const hashBrowser = val => +crypto.subtle.digest('SHA-256', new TextEncoder('utf-8').encode(val)).then(h => { +let hexes = [], +view = new DataView(h); +for (let i = 0; i < view.byteLength; i += 4) +hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8)); +return hexes.join(''); +}); + module.exports = hashBrowser \ No newline at end of file diff --git a/test/hashBrowser/hashBrowser.test.js b/test/hashBrowser/hashBrowser.test.js new file mode 100644 index 000000000..93ad07918 --- /dev/null +++ b/test/hashBrowser/hashBrowser.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const hashBrowser = require('./hashBrowser.js'); + +test('Testing hashBrowser', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof hashBrowser === 'function', 'hashBrowser is a Function'); + //t.deepEqual(hashBrowser(args..), 'Expected'); + //t.equal(hashBrowser(args..), 'Expected'); + //t.false(hashBrowser(args..), 'Expected'); + //t.throws(hashBrowser(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/hashNode/hashNode.js b/test/hashNode/hashNode.js new file mode 100644 index 000000000..e6124fe5d --- /dev/null +++ b/test/hashNode/hashNode.js @@ -0,0 +1,15 @@ +const crypto = require('crypto'); +const hashNode = val => +new Promise(resolve => +setTimeout( +() => +resolve( +crypto +.createHash('sha256') +.update(val) +.digest('hex') +), +0 +) +); + module.exports = hashNode \ No newline at end of file diff --git a/test/hashNode/hashNode.test.js b/test/hashNode/hashNode.test.js new file mode 100644 index 000000000..31d0a0324 --- /dev/null +++ b/test/hashNode/hashNode.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const hashNode = require('./hashNode.js'); + +test('Testing hashNode', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof hashNode === 'function', 'hashNode is a Function'); + //t.deepEqual(hashNode(args..), 'Expected'); + //t.equal(hashNode(args..), 'Expected'); + //t.false(hashNode(args..), 'Expected'); + //t.throws(hashNode(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/is/is.js b/test/is/is.js new file mode 100644 index 000000000..829c5d16e --- /dev/null +++ b/test/is/is.js @@ -0,0 +1,2 @@ +const is = (type, val) => val instanceof type; + module.exports = is \ No newline at end of file diff --git a/test/is/is.test.js b/test/is/is.test.js new file mode 100644 index 000000000..78d7b1e3a --- /dev/null +++ b/test/is/is.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const is = require('./is.js'); + +test('Testing is', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof is === 'function', 'is is a Function'); + //t.deepEqual(is(args..), 'Expected'); + //t.equal(is(args..), 'Expected'); + //t.false(is(args..), 'Expected'); + //t.throws(is(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/testlog b/test/testlog index d21866fa7..e394b27f1 100644 --- a/test/testlog +++ b/test/testlog @@ -1,1256 +1,1268 @@ -Test log for: Wed Jan 17 2018 13:39:53 GMT-0500 (Eastern Standard Time) +Test log for: Wed Jan 17 2018 20:11:11 GMT+0000 (UTC) -> 30-seconds-of-code@0.0.1 test C:\Users\King David\Desktop\github-repo\30-seconds-of-code +> 30-seconds-of-code@0.0.1 test /home/travis/build/Chalarangelo/30-seconds-of-code > tape test/**/*.test.js | tap-spec - Testing anagrams - - √ anagrams is a Function - √ Generates all anagrams of a string - - Testing arrayToHtmlList - - √ arrayToHtmlList is a Function - - Testing average - - √ average is a Function - √ average(true) returns 0 - √ average(false) returns 1 - √ average(9, 1) returns 5 - √ average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631) returns 32163.909090909092 - √ average(1, 2, 3) returns 2 - √ average(null) returns 0 - √ average(1, 2, 3) returns NaN - √ average(String) returns NaN - √ average({ a: 123}) returns NaN - √ average([undefined, 0, string]) returns NaN - √ head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run - - Testing averageBy - - √ averageBy is a Function - - Testing binarySearch - - √ binarySearch is a Function - - Testing bottomVisible - - √ bottomVisible is a Function - - Testing byteSize - - √ byteSize is a Function - - Testing call - - √ call is a Function - - Testing capitalize - - √ capitalize is a Function - √ Capitalizes the first letter of a string - √ Capitalizes the first letter of a string - - Testing capitalizeEveryWord - - √ capitalizeEveryWord is a Function - √ Capitalizes the first letter of every word in a string - - Testing chainAsync - - √ chainAsync is a Function - - Testing chunk - - √ chunk is a Function - √ chunk([1, 2, 3, 4, 5], 2) returns [[1,2],[3,4],[5]] - √ chunk([]) returns [] - √ chunk(123) returns [] - √ chunk({ a: 123}) returns [] - √ chunk(string, 2) returns [ st, ri, ng ] - √ chunk() throws an error - √ chunk(undefined) throws an error - √ chunk(null) throws an error - √ chunk(This is a string, 2) takes less than 2s to run - - Testing clampNumber - - √ clampNumber is a Function - √ Clamps num within the inclusive range specified by the boundary values a and b - - Testing cleanObj - - √ cleanObj is a Function - √ Removes any properties except the ones specified from a JSON object - - Testing cloneRegExp - - √ cloneRegExp is a Function - - Testing coalesce - - √ coalesce is a Function - √ Returns the first non-null/undefined argument - - Testing coalesceFactory - - √ coalesceFactory is a Function - √ Returns a customized coalesce function - - Testing collatz - - √ collatz is a Function - - Testing collectInto - - √ collectInto is a Function - - Testing colorize - - √ colorize is a Function - - Testing compact - - √ compact is a Function - √ Removes falsey values from an array - - Testing compose - - √ compose is a Function - √ Performs right-to-left function composition - - Testing copyToClipboard - - √ copyToClipboard is a Function - - Testing countBy - - √ countBy is a Function - - Testing countOccurrences - - √ countOccurrences is a Function - √ Counts the occurrences of a value in an array - - Testing countVowels - - √ countVowels is a Function - - Testing createElement - - √ createElement is a Function - - Testing createEventHub - - √ createEventHub is a Function - - Testing currentURL - - √ currentURL is a Function - - Testing curry - - √ curry is a Function - √ curries a Math.pow - √ curries a Math.min - - Testing decapitalize - - √ decapitalize is a Function - - Testing deepFlatten - - √ deepFlatten is a Function - √ Deep flattens an array - - Testing defer - - √ defer is a Function - - Testing detectDeviceType - - √ detectDeviceType is a Function - - Testing difference - - √ difference is a Function - √ Returns the difference between two arrays - - Testing differenceWith - - √ differenceWith is a Function - √ Filters out all values from an array - - Testing digitize - - √ digitize is a Function - √ Converts a number to an array of digits - - Testing distance - - √ distance is a Function - - Testing dropElements - - √ dropElements is a Function - √ Removes elements in an array until the passed function returns true - - Testing dropRight - - √ dropRight is a Function - √ Returns a new array with n elements removed from the right - √ Returns a new array with n elements removed from the right - √ Returns a new array with n elements removed from the right - - Testing elementIsVisibleInViewport - - √ elementIsVisibleInViewport is a Function - - Testing elo - - √ elo is a Function - √ Standard 1v1s - √ should be equivalent - √ 4 player FFA, all same rank - - Testing equals - - √ equals is a Function - √ { a: [2, {e: 3}], b: [4], c: 'foo' } is equal to { a: [2, {e: 3}], b: [4], c: 'foo' } - √ [1,2,3] is equal to [1,2,3] - √ { a: [2, 3], b: [4] } is not equal to { a: [2, 3], b: [6] } - √ [1,2,3] is not equal to [1,2,4] - √ [1, 2, 3] should be equal to { 0: 1, 1: 2, 2: 3 }) - type is different, but their enumerable properties match. - - Testing escapeHTML - - √ escapeHTML is a Function - √ Escapes a string for use in HTML - - Testing escapeRegExp - - √ escapeRegExp is a Function - √ Escapes a string to use in a regular expression - - Testing everyNth - - √ everyNth is a Function - √ Returns every nth element in an array - - Testing extendHex - - √ extendHex is a Function - √ Extends a 3-digit color code to a 6-digit color code - √ Extends a 3-digit color code to a 6-digit color code - - Testing factorial - - √ factorial is a Function - √ Calculates the factorial of 720 - √ Calculates the factorial of 0 - √ Calculates the factorial of 1 - √ Calculates the factorial of 4 - √ Calculates the factorial of 10 - - Testing factors - - √ factors is a Function - - Testing fibonacci - - √ fibonacci is a Function - √ Generates an array, containing the Fibonacci sequence - - Testing fibonacciCountUntilNum - - √ fibonacciCountUntilNum is a Function - - Testing fibonacciUntilNum - - √ fibonacciUntilNum is a Function - - Testing filterNonUnique - - √ filterNonUnique is a Function - √ Filters out the non-unique values in an array - - Testing findLast - - √ findLast is a Function - - Testing flatten - - √ flatten is a Function - √ Flattens an array - √ Flattens an array - - Testing flip - - √ flip is a Function - - Testing forEachRight - - √ forEachRight is a Function - - Testing formatDuration - - √ formatDuration is a Function - √ Returns the human readable format of the given number of milliseconds - √ Returns the human readable format of the given number of milliseconds - - Testing fromCamelCase - - √ fromCamelCase is a Function - √ Converts a string from camelcase - √ Converts a string from camelcase - √ Converts a string from camelcase - - Testing functionName - - √ functionName is a Function - - Testing functions - - √ functions is a Function - - Testing gcd - - √ gcd is a Function - √ Calculates the greatest common divisor between two or more numbers/arrays - √ Calculates the greatest common divisor between two or more numbers/arrays - - Testing geometricProgression - - √ geometricProgression is a Function - √ Initializes an array containing the numbers in the specified range - √ Initializes an array containing the numbers in the specified range - √ Initializes an array containing the numbers in the specified range - - Testing getDaysDiffBetweenDates - - √ getDaysDiffBetweenDates is a Function - √ Returns the difference in days between two dates - - Testing getScrollPosition - - √ getScrollPosition is a Function - - Testing getStyle - - √ getStyle is a Function - - Testing getType - - √ getType is a Function - √ Returns the native type of a value - - Testing getURLParameters - - √ getURLParameters is a Function - √ Returns an object containing the parameters of the current URL - - Testing groupBy - - √ groupBy is a Function - √ Groups the elements of an array based on the given function - √ Groups the elements of an array based on the given function - - Testing hammingDistance - - √ hammingDistance is a Function - √ retuns hamming disance between 2 values - - Testing hasClass - - √ hasClass is a Function - - Testing hasFlags - - √ hasFlags is a Function - - Testing head - - √ head is a Function - √ head({ a: 1234}) returns undefined - √ head([1, 2, 3]) returns 1 - √ head({ 0: false}) returns false - √ head(String) returns S - √ head(null) throws an Error - √ head(undefined) throws an Error - √ head() throws an Error - √ head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run - - Testing hexToRGB - - √ hexToRGB is a Function - √ Converts a color code to a rgb() or rgba() string - √ Converts a color code to a rgb() or rgba() string - √ Converts a color code to a rgb() or rgba() string - - Testing hide - - √ hide is a Function - - Testing howManyTimes - - √ howManyTimes is a Function - - Testing httpDelete - - √ httpDelete is a Function - - Testing httpGet - - √ httpGet is a Function - - Testing httpPost - - √ httpPost is a Function - - Testing httpPut - - √ httpPut is a Function - - Testing httpsRedirect - - √ httpsRedirect is a Function - - Testing indexOfAll - - √ indexOfAll is a Function - √ Returns all indices of val in an array - √ Returns all indices of val in an array - - Testing initial - - √ initial is a Function - √ Returns all the elements of an array except the last one - - Testing initialize2DArray - - √ initialize2DArray is a Function - √ Initializes a 2D array of given width and height and value - - Testing initializeArrayWithRange - - √ initializeArrayWithRange is a Function - √ Initializes an array containing the numbers in the specified range - - Testing initializeArrayWithRangeRight - - √ initializeArrayWithRangeRight is a Function - - Testing initializeArrayWithValues - - √ initializeArrayWithValues is a Function - √ Initializes and fills an array with the specified values - - Testing inRange - - √ inRange is a Function - √ The given number falls within the given range - √ The given number falls within the given range - √ The given number does not falls within the given range - √ The given number does not falls within the given range - - Testing intersection - - √ intersection is a Function - √ Returns a list of elements that exist in both arrays - - Testing invertKeyValues - - √ invertKeyValues is a Function - √ Inverts the key-value pairs of an object - - Testing isAbsoluteURL - - √ isAbsoluteURL is a Function - √ Given string is an absolute URL - √ Given string is an absolute URL - √ Given string is not an absolute URL - - Testing isArmstrongNumber - - √ isArmstrongNumber is a Function - - Testing isArray - - √ isArray is a Function - √ passed value is an array - √ passed value is not an array - - Testing isArrayBuffer - - √ isArrayBuffer is a Function - - Testing isArrayLike - - √ isArrayLike is a Function - - Testing isBoolean - - √ isBoolean is a Function - √ passed value is not a boolean - √ passed value is not a boolean - - Testing isDivisible - - √ isDivisible is a Function - √ The number 6 is divisible by 3 - - Testing isEven - - √ isEven is a Function - √ 4 is even number - √ undefined - - Testing isFunction - - √ isFunction is a Function - √ passed value is a function - √ passed value is not a function - - Testing isLowerCase - - √ isLowerCase is a Function - √ passed string is a lowercase - √ passed string is a lowercase - √ passed value is not a lowercase - - Testing isMap - - √ isMap is a Function - - Testing isNil - - √ isNil is a Function - - Testing isNull - - √ isNull is a Function - √ passed argument is a null - √ passed argument is a null - - Testing isNumber - - √ isNumber is a Function - √ passed argument is a number - √ passed argument is not a number - - Testing isObject - - √ isObject is a Function - √ isObject([1, 2, 3, 4]) is a object - √ isObject([]) is a object - √ isObject({ a:1 }) is a object - √ isObject(true) is not a object - - Testing isPrime - - √ isPrime is a Function - √ passed number is a prime - - Testing isPrimitive - - √ isPrimitive is a Function - √ isPrimitive(null) is primitive - √ isPrimitive(undefined) is primitive - √ isPrimitive(string) is primitive - √ isPrimitive(true) is primitive - √ isPrimitive(50) is primitive - √ isPrimitive('Hello') is primitive - √ isPrimitive(false) is primitive - √ isPrimitive(Symbol()) is primitive - √ isPrimitive([1, 2, 3]) is not primitive - √ isPrimitive({ a: 123 }) is not primitive - √ isPrimitive({ a: 123 }) takes less than 2s to run - - Testing isPromiseLike - - √ isPromiseLike is a Function - - Testing isRegExp - - √ isRegExp is a Function - - Testing isSet - - √ isSet is a Function - - Testing isSorted - - √ isSorted is a Function - √ Array is sorted in ascending order - √ Array is sorted in descending order - √ Array is not sorted, direction changed in array - - Testing isString - - √ isString is a Function - √ foo is a string - √ "10" is a string - √ Empty string is a string - √ 10 is not a string - √ true is not string - - Testing isSymbol - - √ isSymbol is a Function - √ Checks if the given argument is a symbol - - Testing isTravisCI - - √ isTravisCI is a Function - - Testing isTypedArray - - √ isTypedArray is a Function - - Testing isUndefined - - √ isUndefined is a Function - - Testing isUpperCase - - √ isUpperCase is a Function - √ ABC is all upper case - √ abc is not all upper case - √ A3@$ is all uppercase - - Testing isValidJSON - - √ isValidJSON is a Function - √ {"name":"Adam","age":20} is a valid JSON - √ {"name":"Adam",age:"20"} is not a valid JSON - √ null is a valid JSON - - Testing isWeakMap - - √ isWeakMap is a Function - - Testing isWeakSet - - √ isWeakSet is a Function - - Testing join - - √ join is a Function - √ Joins all elements of an array into a string and returns this string - √ Joins all elements of an array into a string and returns this string - √ Joins all elements of an array into a string and returns this string - Testing JSONToDate - √ JSONToDate is a Function + ✔ JSONToDate is a Function Testing JSONToFile - √ JSONToFile is a Function - - Testing last - - √ last is a Function - √ last({ a: 1234}) returns undefined - √ last([1, 2, 3]) returns 3 - √ last({ 0: false}) returns undefined - √ last(String) returns g - √ last(null) throws an Error - √ last(undefined) throws an Error - √ last() throws an Error - √ last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run - - Testing lcm - - √ lcm is a Function - √ Returns the least common multiple of two or more numbers. - √ Returns the least common multiple of two or more numbers. - - Testing longestItem - - √ longestItem is a Function - √ Returns the longest object - - Testing lowercaseKeys - - √ lowercaseKeys is a Function - - Testing luhnCheck - - √ luhnCheck is a Function - √ validates identification number - √ validates identification number - √ validates identification number - - Testing mapKeys - - √ mapKeys is a Function - - Testing mapObject - - √ mapObject is a Function - √ Maps the values of an array to an object using a function - - Testing mapValues - - √ mapValues is a Function - - Testing mask - - √ mask is a Function - √ Replaces all but the last num of characters with the specified mask character - √ Replaces all but the last num of characters with the specified mask character - √ Replaces all but the last num of characters with the specified mask character - - Testing maxBy - - √ maxBy is a Function - - Testing maxN - - √ maxN is a Function - √ Returns the n maximum elements from the provided array - √ Returns the n maximum elements from the provided array - - Testing median - - √ median is a Function - √ Returns the median of an array of numbers - √ Returns the median of an array of numbers - - Testing memoize - - √ memoize is a Function - - Testing merge - - √ merge is a Function - - Testing minBy - - √ minBy is a Function - - Testing minN - - √ minN is a Function - √ Returns the n minimum elements from the provided array - √ Returns the n minimum elements from the provided array - - Testing negate - - √ negate is a Function - √ Negates a predicate function - - Testing nthElement - - √ nthElement is a Function - √ Returns the nth element of an array. - √ Returns the nth element of an array. - - Testing objectFromPairs - - √ objectFromPairs is a Function - √ Creates an object from the given key-value pairs. - - Testing objectToPairs - - √ objectToPairs is a Function - √ Creates an array of key-value pair arrays from an object. - - Testing observeMutations - - √ observeMutations is a Function - - Testing off - - √ off is a Function - - Testing on - - √ on is a Function - - Testing once - - √ once is a Function - - Testing onUserInputChange - - √ onUserInputChange is a Function - - Testing orderBy - - √ orderBy is a Function - √ Returns a sorted array of objects ordered by properties and orders. - √ Returns a sorted array of objects ordered by properties and orders. - - Testing palindrome - - √ palindrome is a Function - √ Given string is a palindrome - √ Given string is not a palindrome - - Testing parseCookie - - √ parseCookie is a Function - - Testing partition - - √ partition is a Function - √ Groups the elements into two arrays, depending on the provided function's truthiness for each element. - - Testing percentile - - √ percentile is a Function - √ Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value. - - Testing pick - - √ pick is a Function - √ Picks the key-value pairs corresponding to the given keys from an object. - - Testing pipeFunctions - - √ pipeFunctions is a Function - - Testing pluralize - - √ pluralize is a Function - - Testing powerset - - √ powerset is a Function - √ Returns the powerset of a given array of numbers. - - Testing prettyBytes - - √ prettyBytes is a Function - √ Converts a number in bytes to a human-readable string. - √ Converts a number in bytes to a human-readable string. - √ Converts a number in bytes to a human-readable string. - - Testing primes - - √ primes is a Function - √ Generates primes up to a given number, using the Sieve of Eratosthenes. - - Testing promisify - - √ promisify is a Function - - Testing pull - - √ pull is a Function - - Testing pullAtIndex - - √ pullAtIndex is a Function - - Testing pullAtValue - - √ pullAtValue is a Function - - Testing quickSort - - √ quickSort is a Function - √ quickSort([5, 6, 4, 3, 1, 2]) returns [1, 2, 3, 4, 5, 6] - √ quickSort([-1, 0, -2]) returns [-2, -1, 0] - √ quickSort() throws an error - √ quickSort(123) throws an error - √ quickSort({ 234: string}) throws an error - √ quickSort(null) throws an error - √ quickSort(undefined) throws an error - √ quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]) takes less than 2s to run - - Testing randomHexColorCode - - √ randomHexColorCode is a Function - - Testing randomIntArrayInRange - - √ randomIntArrayInRange is a Function - - Testing randomIntegerInRange - - √ randomIntegerInRange is a Function - - Testing randomNumberInRange - - √ randomNumberInRange is a Function - - Testing readFileLines - - √ readFileLines is a Function + ✔ JSONToFile is a Function Testing README - √ README is a Function - - Testing redirect - - √ redirect is a Function - - Testing reducedFilter - - √ reducedFilter is a Function - √ Filter an array of objects based on a condition while also filtering out unspecified keys. - - Testing remove - - √ remove is a Function - √ Removes elements from an array for which the given function returns false - - Testing removeVowels - - √ removeVowels is a Function - - Testing reverseString - - √ reverseString is a Function - √ Reverses a string. + ✔ README is a Function Testing RGBToHex - √ RGBToHex is a Function - √ Converts the values of RGB components to a color code. - - Testing round - - √ round is a Function - √ Rounds a number to a specified amount of digits. - - Testing runAsync - - √ runAsync is a Function - - Testing runPromisesInSeries - - √ runPromisesInSeries is a Function - - Testing sample - - √ sample is a Function - - Testing sampleSize - - √ sampleSize is a Function - - Testing scrollToTop - - √ scrollToTop is a Function - - Testing sdbm - - √ sdbm is a Function - √ Hashes the input string into a whole number. - - Testing select - - √ select is a Function - √ Retrieve a property indicated by the selector from an object. - - Testing serializeCookie - - √ serializeCookie is a Function - - Testing setStyle - - √ setStyle is a Function - - Testing shallowClone - - √ shallowClone is a Function - - Testing show - - √ show is a Function - - Testing shuffle - - √ shuffle is a Function - - Testing similarity - - √ similarity is a Function - √ Returns an array of elements that appear in both arrays. - - Testing size - - √ size is a Function - √ Get size of arrays, objects or strings. - √ Get size of arrays, objects or strings. - - Testing sleep - - √ sleep is a Function - - Testing solveRPN - - √ solveRPN is a Function - - Testing sortCharactersInString - - √ sortCharactersInString is a Function - √ Alphabetically sorts the characters in a string. - - Testing sortedIndex - - √ sortedIndex is a Function - √ Returns the lowest index at which value should be inserted into array in order to maintain its sort order. - √ Returns the lowest index at which value should be inserted into array in order to maintain its sort order. - - Testing speechSynthesis - - √ speechSynthesis is a Function - - Testing splitLines - - √ splitLines is a Function - √ Splits a multiline string into an array of lines. - - Testing spreadOver - - √ spreadOver is a Function - √ Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. - - Testing standardDeviation - - √ standardDeviation is a Function - √ Returns the standard deviation of an array of numbers - √ Returns the standard deviation of an array of numbers - - Testing sum - - √ sum is a Function - √ Returns the sum of two or more numbers/arrays. - - Testing sumBy - - √ sumBy is a Function - - Testing sumPower - - √ sumPower is a Function - √ Returns the sum of the powers of all the numbers from start to end - √ Returns the sum of the powers of all the numbers from start to end - √ Returns the sum of the powers of all the numbers from start to end - - Testing symmetricDifference - - √ symmetricDifference is a Function - √ Returns the symmetric difference between two arrays. - - Testing tail - - √ tail is a Function - √ Returns tail - √ Returns tail - - Testing take - - √ take is a Function - √ Returns an array with n elements removed from the beginning. - √ Returns an array with n elements removed from the beginning. - - Testing takeRight - - √ takeRight is a Function - √ Returns an array with n elements removed from the end - √ Returns an array with n elements removed from the end - - Testing timeTaken - - √ timeTaken is a Function - - Testing toCamelCase - - √ toCamelCase is a Function - √ Converts a string to camelCase - √ Converts a string to camelCase - √ Converts a string to camelCase - √ Converts a string to camelCase - - Testing toDecimalMark - - √ toDecimalMark is a Function - √ convert a float-point arithmetic to the Decimal mark form - - Testing toggleClass - - √ toggleClass is a Function - - Testing toKebabCase - - √ toKebabCase is a Function - √ string converts to snake case - √ string converts to snake case - √ string converts to snake case - √ string converts to snake case - - Testing tomorrow - - √ tomorrow is a Function - - Testing toOrdinalSuffix - - √ toOrdinalSuffix is a Function - √ Adds an ordinal suffix to a number - √ Adds an ordinal suffix to a number - √ Adds an ordinal suffix to a number - √ Adds an ordinal suffix to a number - - Testing toSafeInteger - - √ toSafeInteger is a Function - √ Converts a value to a safe integer - √ Converts a value to a safe integer - √ Converts a value to a safe integer - √ Converts a value to a safe integer - √ Converts a value to a safe integer - - Testing toSnakeCase - - √ toSnakeCase is a Function - √ string converts to snake case - √ string converts to snake case - √ string converts to snake case - √ string converts to snake case - - Testing transform - - √ transform is a Function - - Testing truncateString - - √ truncateString is a Function - √ Truncates a "boomerang" up to a specified length. - - Testing truthCheckCollection - - √ truthCheckCollection is a Function - √ second argument is truthy on all elements of a collection - - Testing unescapeHTML - - √ unescapeHTML is a Function - √ Unescapes escaped HTML characters. - - Testing union - - √ union is a Function - √ Returns every element that exists in any of the two arrays once - - Testing uniqueElements - - √ uniqueElements is a Function - √ Returns all unique values of an array - - Testing untildify - - √ untildify is a Function + ✔ RGBToHex is a Function + ✔ Converts the values of RGB components to a color code. Testing URLJoin - √ URLJoin is a Function - √ Returns proper URL - √ Returns proper URL + ✔ URLJoin is a Function + ✔ Returns proper URL + ✔ Returns proper URL Testing UUIDGeneratorBrowser - √ UUIDGeneratorBrowser is a Function + ✔ UUIDGeneratorBrowser is a Function Testing UUIDGeneratorNode - √ UUIDGeneratorNode is a Function + ✔ UUIDGeneratorNode is a Function + + Testing anagrams + + ✔ anagrams is a Function + ✔ Generates all anagrams of a string + + Testing arrayToHtmlList + + ✔ arrayToHtmlList is a Function + + Testing average + + ✔ average is a Function + ✔ average(true) returns 0 + ✔ average(false) returns 1 + ✔ average(9, 1) returns 5 + ✔ average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631) returns 32163.909090909092 + ✔ average(1, 2, 3) returns 2 + ✔ average(null) returns 0 + ✔ average(1, 2, 3) returns NaN + ✔ average(String) returns NaN + ✔ average({ a: 123}) returns NaN + ✔ average([undefined, 0, string]) returns NaN + ✔ head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run + + Testing averageBy + + ✔ averageBy is a Function + + Testing binarySearch + + ✔ binarySearch is a Function + + Testing bottomVisible + + ✔ bottomVisible is a Function + + Testing byteSize + + ✔ byteSize is a Function + + Testing call + + ✔ call is a Function + + Testing capitalize + + ✔ capitalize is a Function + ✔ Capitalizes the first letter of a string + ✔ Capitalizes the first letter of a string + + Testing capitalizeEveryWord + + ✔ capitalizeEveryWord is a Function + ✔ Capitalizes the first letter of every word in a string + + Testing chainAsync + + ✔ chainAsync is a Function + + Testing chunk + + ✔ chunk is a Function + ✔ chunk([1, 2, 3, 4, 5], 2) returns [[1,2],[3,4],[5]] + ✔ chunk([]) returns [] + ✔ chunk(123) returns [] + ✔ chunk({ a: 123}) returns [] + ✔ chunk(string, 2) returns [ st, ri, ng ] + ✔ chunk() throws an error + ✔ chunk(undefined) throws an error + ✔ chunk(null) throws an error + ✔ chunk(This is a string, 2) takes less than 2s to run + + Testing clampNumber + + ✔ clampNumber is a Function + ✔ Clamps num within the inclusive range specified by the boundary values a and b + + Testing cleanObj + + ✔ cleanObj is a Function + ✔ Removes any properties except the ones specified from a JSON object + + Testing cloneRegExp + + ✔ cloneRegExp is a Function + + Testing coalesce + + ✔ coalesce is a Function + ✔ Returns the first non-null/undefined argument + + Testing coalesceFactory + + ✔ coalesceFactory is a Function + ✔ Returns a customized coalesce function + + Testing collatz + + ✔ collatz is a Function + + Testing collectInto + + ✔ collectInto is a Function + + Testing colorize + + ✔ colorize is a Function + + Testing compact + + ✔ compact is a Function + ✔ Removes falsey values from an array + + Testing compose + + ✔ compose is a Function + ✔ Performs right-to-left function composition + + Testing copyToClipboard + + ✔ copyToClipboard is a Function + + Testing countBy + + ✔ countBy is a Function + + Testing countOccurrences + + ✔ countOccurrences is a Function + ✔ Counts the occurrences of a value in an array + + Testing countVowels + + ✔ countVowels is a Function + + Testing createElement + + ✔ createElement is a Function + + Testing createEventHub + + ✔ createEventHub is a Function + + Testing currentURL + + ✔ currentURL is a Function + + Testing curry + + ✔ curry is a Function + ✔ curries a Math.pow + ✔ curries a Math.min + + Testing decapitalize + + ✔ decapitalize is a Function + + Testing deepFlatten + + ✔ deepFlatten is a Function + ✔ Deep flattens an array + + Testing defer + + ✔ defer is a Function + + Testing detectDeviceType + + ✔ detectDeviceType is a Function + + Testing difference + + ✔ difference is a Function + ✔ Returns the difference between two arrays + + Testing differenceWith + + ✔ differenceWith is a Function + ✔ Filters out all values from an array + + Testing digitize + + ✔ digitize is a Function + ✔ Converts a number to an array of digits + + Testing distance + + ✔ distance is a Function + + Testing dropElements + + ✔ dropElements is a Function + ✔ Removes elements in an array until the passed function returns true + + Testing dropRight + + ✔ dropRight is a Function + ✔ Returns a new array with n elements removed from the right + ✔ Returns a new array with n elements removed from the right + ✔ Returns a new array with n elements removed from the right + + Testing elementIsVisibleInViewport + + ✔ elementIsVisibleInViewport is a Function + + Testing elo + + ✔ elo is a Function + ✔ Standard 1v1s + ✔ should be equivalent + ✔ 4 player FFA, all same rank + + Testing equals + + ✔ equals is a Function + ✔ { a: [2, {e: 3}], b: [4], c: 'foo' } is equal to { a: [2, {e: 3}], b: [4], c: 'foo' } + ✔ [1,2,3] is equal to [1,2,3] + ✔ { a: [2, 3], b: [4] } is not equal to { a: [2, 3], b: [6] } + ✔ [1,2,3] is not equal to [1,2,4] + ✔ [1, 2, 3] should be equal to { 0: 1, 1: 2, 2: 3 }) - type is different, but their enumerable properties match. + + Testing escapeHTML + + ✔ escapeHTML is a Function + ✔ Escapes a string for use in HTML + + Testing escapeRegExp + + ✔ escapeRegExp is a Function + ✔ Escapes a string to use in a regular expression + + Testing everyNth + + ✔ everyNth is a Function + ✔ Returns every nth element in an array + + Testing extendHex + + ✔ extendHex is a Function + ✔ Extends a 3-digit color code to a 6-digit color code + ✔ Extends a 3-digit color code to a 6-digit color code + + Testing factorial + + ✔ factorial is a Function + ✔ Calculates the factorial of 720 + ✔ Calculates the factorial of 0 + ✔ Calculates the factorial of 1 + ✔ Calculates the factorial of 4 + ✔ Calculates the factorial of 10 + + Testing factors + + ✔ factors is a Function + + Testing fibonacci + + ✔ fibonacci is a Function + ✔ Generates an array, containing the Fibonacci sequence + + Testing fibonacciCountUntilNum + + ✔ fibonacciCountUntilNum is a Function + + Testing fibonacciUntilNum + + ✔ fibonacciUntilNum is a Function + + Testing filterNonUnique + + ✔ filterNonUnique is a Function + ✔ Filters out the non-unique values in an array + + Testing findLast + + ✔ findLast is a Function + + Testing flatten + + ✔ flatten is a Function + ✔ Flattens an array + ✔ Flattens an array + + Testing flip + + ✔ flip is a Function + + Testing forEachRight + + ✔ forEachRight is a Function + + Testing formatDuration + + ✔ formatDuration is a Function + ✔ Returns the human readable format of the given number of milliseconds + ✔ Returns the human readable format of the given number of milliseconds + + Testing fromCamelCase + + ✔ fromCamelCase is a Function + ✔ Converts a string from camelcase + ✔ Converts a string from camelcase + ✔ Converts a string from camelcase + + Testing functionName + + ✔ functionName is a Function + + Testing functions + + ✔ functions is a Function + + Testing gcd + + ✔ gcd is a Function + ✔ Calculates the greatest common divisor between two or more numbers/arrays + ✔ Calculates the greatest common divisor between two or more numbers/arrays + + Testing geometricProgression + + ✔ geometricProgression is a Function + ✔ Initializes an array containing the numbers in the specified range + ✔ Initializes an array containing the numbers in the specified range + ✔ Initializes an array containing the numbers in the specified range + + Testing getDaysDiffBetweenDates + + ✔ getDaysDiffBetweenDates is a Function + ✔ Returns the difference in days between two dates + + Testing getScrollPosition + + ✔ getScrollPosition is a Function + + Testing getStyle + + ✔ getStyle is a Function + + Testing getType + + ✔ getType is a Function + ✔ Returns the native type of a value + + Testing getURLParameters + + ✔ getURLParameters is a Function + ✔ Returns an object containing the parameters of the current URL + + Testing groupBy + + ✔ groupBy is a Function + ✔ Groups the elements of an array based on the given function + ✔ Groups the elements of an array based on the given function + + Testing hammingDistance + + ✔ hammingDistance is a Function + ✔ retuns hamming disance between 2 values + + Testing hasClass + + ✔ hasClass is a Function + + Testing hasFlags + + ✔ hasFlags is a Function + + Testing hashBrowser + + ✔ hashBrowser is a Function + + Testing hashNode + + ✔ hashNode is a Function + + Testing head + + ✔ head is a Function + ✔ head({ a: 1234}) returns undefined + ✔ head([1, 2, 3]) returns 1 + ✔ head({ 0: false}) returns false + ✔ head(String) returns S + ✔ head(null) throws an Error + ✔ head(undefined) throws an Error + ✔ head() throws an Error + ✔ head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run + + Testing hexToRGB + + ✔ hexToRGB is a Function + ✔ Converts a color code to a rgb() or rgba() string + ✔ Converts a color code to a rgb() or rgba() string + ✔ Converts a color code to a rgb() or rgba() string + + Testing hide + + ✔ hide is a Function + + Testing howManyTimes + + ✔ howManyTimes is a Function + + Testing httpDelete + + ✔ httpDelete is a Function + + Testing httpGet + + ✔ httpGet is a Function + + Testing httpPost + + ✔ httpPost is a Function + + Testing httpPut + + ✔ httpPut is a Function + + Testing httpsRedirect + + ✔ httpsRedirect is a Function + + Testing inRange + + ✔ inRange is a Function + ✔ The given number falls within the given range + ✔ The given number falls within the given range + ✔ The given number does not falls within the given range + ✔ The given number does not falls within the given range + + Testing indexOfAll + + ✔ indexOfAll is a Function + ✔ Returns all indices of val in an array + ✔ Returns all indices of val in an array + + Testing initial + + ✔ initial is a Function + ✔ Returns all the elements of an array except the last one + + Testing initialize2DArray + + ✔ initialize2DArray is a Function + ✔ Initializes a 2D array of given width and height and value + + Testing initializeArrayWithRange + + ✔ initializeArrayWithRange is a Function + ✔ Initializes an array containing the numbers in the specified range + + Testing initializeArrayWithRangeRight + + ✔ initializeArrayWithRangeRight is a Function + + Testing initializeArrayWithValues + + ✔ initializeArrayWithValues is a Function + ✔ Initializes and fills an array with the specified values + + Testing intersection + + ✔ intersection is a Function + ✔ Returns a list of elements that exist in both arrays + + Testing invertKeyValues + + ✔ invertKeyValues is a Function + ✔ Inverts the key-value pairs of an object + + Testing is + + ✔ is is a Function + + Testing isAbsoluteURL + + ✔ isAbsoluteURL is a Function + ✔ Given string is an absolute URL + ✔ Given string is an absolute URL + ✔ Given string is not an absolute URL + + Testing isArmstrongNumber + + ✔ isArmstrongNumber is a Function + + Testing isArray + + ✔ isArray is a Function + ✔ passed value is an array + ✔ passed value is not an array + + Testing isArrayBuffer + + ✔ isArrayBuffer is a Function + + Testing isArrayLike + + ✔ isArrayLike is a Function + + Testing isBoolean + + ✔ isBoolean is a Function + ✔ passed value is not a boolean + ✔ passed value is not a boolean + + Testing isDivisible + + ✔ isDivisible is a Function + ✔ The number 6 is divisible by 3 + + Testing isEven + + ✔ isEven is a Function + ✔ 4 is even number + ✔ undefined + + Testing isFunction + + ✔ isFunction is a Function + ✔ passed value is a function + ✔ passed value is not a function + + Testing isLowerCase + + ✔ isLowerCase is a Function + ✔ passed string is a lowercase + ✔ passed string is a lowercase + ✔ passed value is not a lowercase + + Testing isMap + + ✔ isMap is a Function + + Testing isNil + + ✔ isNil is a Function + + Testing isNull + + ✔ isNull is a Function + ✔ passed argument is a null + ✔ passed argument is a null + + Testing isNumber + + ✔ isNumber is a Function + ✔ passed argument is a number + ✔ passed argument is not a number + + Testing isObject + + ✔ isObject is a Function + ✔ isObject([1, 2, 3, 4]) is a object + ✔ isObject([]) is a object + ✔ isObject({ a:1 }) is a object + ✔ isObject(true) is not a object + + Testing isPrime + + ✔ isPrime is a Function + ✔ passed number is a prime + + Testing isPrimitive + + ✔ isPrimitive is a Function + ✔ isPrimitive(null) is primitive + ✔ isPrimitive(undefined) is primitive + ✔ isPrimitive(string) is primitive + ✔ isPrimitive(true) is primitive + ✔ isPrimitive(50) is primitive + ✔ isPrimitive('Hello') is primitive + ✔ isPrimitive(false) is primitive + ✔ isPrimitive(Symbol()) is primitive + ✔ isPrimitive([1, 2, 3]) is not primitive + ✔ isPrimitive({ a: 123 }) is not primitive + ✔ isPrimitive({ a: 123 }) takes less than 2s to run + + Testing isPromiseLike + + ✔ isPromiseLike is a Function + + Testing isRegExp + + ✔ isRegExp is a Function + + Testing isSet + + ✔ isSet is a Function + + Testing isSorted + + ✔ isSorted is a Function + ✔ Array is sorted in ascending order + ✔ Array is sorted in descending order + ✔ Array is not sorted, direction changed in array + + Testing isString + + ✔ isString is a Function + ✔ foo is a string + ✔ "10" is a string + ✔ Empty string is a string + ✔ 10 is not a string + ✔ true is not string + + Testing isSymbol + + ✔ isSymbol is a Function + ✔ Checks if the given argument is a symbol + + Testing isTravisCI + + ✔ isTravisCI is a Function + + Testing isTypedArray + + ✔ isTypedArray is a Function + + Testing isUndefined + + ✔ isUndefined is a Function + + Testing isUpperCase + + ✔ isUpperCase is a Function + ✔ ABC is all upper case + ✔ abc is not all upper case + ✔ A3@$ is all uppercase + + Testing isValidJSON + + ✔ isValidJSON is a Function + ✔ {"name":"Adam","age":20} is a valid JSON + ✔ {"name":"Adam",age:"20"} is not a valid JSON + ✔ null is a valid JSON + + Testing isWeakMap + + ✔ isWeakMap is a Function + + Testing isWeakSet + + ✔ isWeakSet is a Function + + Testing join + + ✔ join is a Function + ✔ Joins all elements of an array into a string and returns this string + ✔ Joins all elements of an array into a string and returns this string + ✔ Joins all elements of an array into a string and returns this string + + Testing last + + ✔ last is a Function + ✔ last({ a: 1234}) returns undefined + ✔ last([1, 2, 3]) returns 3 + ✔ last({ 0: false}) returns undefined + ✔ last(String) returns g + ✔ last(null) throws an Error + ✔ last(undefined) throws an Error + ✔ last() throws an Error + ✔ last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run + + Testing lcm + + ✔ lcm is a Function + ✔ Returns the least common multiple of two or more numbers. + ✔ Returns the least common multiple of two or more numbers. + + Testing longestItem + + ✔ longestItem is a Function + ✔ Returns the longest object + + Testing lowercaseKeys + + ✔ lowercaseKeys is a Function + + Testing luhnCheck + + ✔ luhnCheck is a Function + ✔ validates identification number + ✔ validates identification number + ✔ validates identification number + + Testing mapKeys + + ✔ mapKeys is a Function + + Testing mapObject + + ✔ mapObject is a Function + ✔ Maps the values of an array to an object using a function + + Testing mapValues + + ✔ mapValues is a Function + + Testing mask + + ✔ mask is a Function + ✔ Replaces all but the last num of characters with the specified mask character + ✔ Replaces all but the last num of characters with the specified mask character + ✔ Replaces all but the last num of characters with the specified mask character + + Testing maxBy + + ✔ maxBy is a Function + + Testing maxN + + ✔ maxN is a Function + ✔ Returns the n maximum elements from the provided array + ✔ Returns the n maximum elements from the provided array + + Testing median + + ✔ median is a Function + ✔ Returns the median of an array of numbers + ✔ Returns the median of an array of numbers + + Testing memoize + + ✔ memoize is a Function + + Testing merge + + ✔ merge is a Function + + Testing minBy + + ✔ minBy is a Function + + Testing minN + + ✔ minN is a Function + ✔ Returns the n minimum elements from the provided array + ✔ Returns the n minimum elements from the provided array + + Testing negate + + ✔ negate is a Function + ✔ Negates a predicate function + + Testing nthElement + + ✔ nthElement is a Function + ✔ Returns the nth element of an array. + ✔ Returns the nth element of an array. + + Testing objectFromPairs + + ✔ objectFromPairs is a Function + ✔ Creates an object from the given key-value pairs. + + Testing objectToPairs + + ✔ objectToPairs is a Function + ✔ Creates an array of key-value pair arrays from an object. + + Testing observeMutations + + ✔ observeMutations is a Function + + Testing off + + ✔ off is a Function + + Testing on + + ✔ on is a Function + + Testing onUserInputChange + + ✔ onUserInputChange is a Function + + Testing once + + ✔ once is a Function + + Testing orderBy + + ✔ orderBy is a Function + ✔ Returns a sorted array of objects ordered by properties and orders. + ✔ Returns a sorted array of objects ordered by properties and orders. + + Testing palindrome + + ✔ palindrome is a Function + ✔ Given string is a palindrome + ✔ Given string is not a palindrome + + Testing parseCookie + + ✔ parseCookie is a Function + + Testing partition + + ✔ partition is a Function + ✔ Groups the elements into two arrays, depending on the provided function's truthiness for each element. + + Testing percentile + + ✔ percentile is a Function + ✔ Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value. + + Testing pick + + ✔ pick is a Function + ✔ Picks the key-value pairs corresponding to the given keys from an object. + + Testing pipeFunctions + + ✔ pipeFunctions is a Function + + Testing pluralize + + ✔ pluralize is a Function + + Testing powerset + + ✔ powerset is a Function + ✔ Returns the powerset of a given array of numbers. + + Testing prettyBytes + + ✔ prettyBytes is a Function + ✔ Converts a number in bytes to a human-readable string. + ✔ Converts a number in bytes to a human-readable string. + ✔ Converts a number in bytes to a human-readable string. + + Testing primes + + ✔ primes is a Function + ✔ Generates primes up to a given number, using the Sieve of Eratosthenes. + + Testing promisify + + ✔ promisify is a Function + + Testing pull + + ✔ pull is a Function + + Testing pullAtIndex + + ✔ pullAtIndex is a Function + + Testing pullAtValue + + ✔ pullAtValue is a Function + + Testing quickSort + + ✔ quickSort is a Function + ✔ quickSort([5, 6, 4, 3, 1, 2]) returns [1, 2, 3, 4, 5, 6] + ✔ quickSort([-1, 0, -2]) returns [-2, -1, 0] + ✔ quickSort() throws an error + ✔ quickSort(123) throws an error + ✔ quickSort({ 234: string}) throws an error + ✔ quickSort(null) throws an error + ✔ quickSort(undefined) throws an error + ✔ quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]) takes less than 2s to run + + Testing randomHexColorCode + + ✔ randomHexColorCode is a Function + + Testing randomIntArrayInRange + + ✔ randomIntArrayInRange is a Function + + Testing randomIntegerInRange + + ✔ randomIntegerInRange is a Function + + Testing randomNumberInRange + + ✔ randomNumberInRange is a Function + + Testing readFileLines + + ✔ readFileLines is a Function + + Testing redirect + + ✔ redirect is a Function + + Testing reducedFilter + + ✔ reducedFilter is a Function + ✔ Filter an array of objects based on a condition while also filtering out unspecified keys. + + Testing remove + + ✔ remove is a Function + ✔ Removes elements from an array for which the given function returns false + + Testing removeVowels + + ✔ removeVowels is a Function + + Testing reverseString + + ✔ reverseString is a Function + ✔ Reverses a string. + + Testing round + + ✔ round is a Function + ✔ Rounds a number to a specified amount of digits. + + Testing runAsync + + ✔ runAsync is a Function + + Testing runPromisesInSeries + + ✔ runPromisesInSeries is a Function + + Testing sample + + ✔ sample is a Function + + Testing sampleSize + + ✔ sampleSize is a Function + + Testing scrollToTop + + ✔ scrollToTop is a Function + + Testing sdbm + + ✔ sdbm is a Function + ✔ Hashes the input string into a whole number. + + Testing select + + ✔ select is a Function + ✔ Retrieve a property indicated by the selector from an object. + + Testing serializeCookie + + ✔ serializeCookie is a Function + + Testing setStyle + + ✔ setStyle is a Function + + Testing shallowClone + + ✔ shallowClone is a Function + + Testing show + + ✔ show is a Function + + Testing shuffle + + ✔ shuffle is a Function + + Testing similarity + + ✔ similarity is a Function + ✔ Returns an array of elements that appear in both arrays. + + Testing size + + ✔ size is a Function + ✔ Get size of arrays, objects or strings. + ✔ Get size of arrays, objects or strings. + + Testing sleep + + ✔ sleep is a Function + + Testing solveRPN + + ✔ solveRPN is a Function + + Testing sortCharactersInString + + ✔ sortCharactersInString is a Function + ✔ Alphabetically sorts the characters in a string. + + Testing sortedIndex + + ✔ sortedIndex is a Function + ✔ Returns the lowest index at which value should be inserted into array in order to maintain its sort order. + ✔ Returns the lowest index at which value should be inserted into array in order to maintain its sort order. + + Testing speechSynthesis + + ✔ speechSynthesis is a Function + + Testing splitLines + + ✔ splitLines is a Function + ✔ Splits a multiline string into an array of lines. + + Testing spreadOver + + ✔ spreadOver is a Function + ✔ Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. + + Testing standardDeviation + + ✔ standardDeviation is a Function + ✔ Returns the standard deviation of an array of numbers + ✔ Returns the standard deviation of an array of numbers + + Testing sum + + ✔ sum is a Function + ✔ Returns the sum of two or more numbers/arrays. + + Testing sumBy + + ✔ sumBy is a Function + + Testing sumPower + + ✔ sumPower is a Function + ✔ Returns the sum of the powers of all the numbers from start to end + ✔ Returns the sum of the powers of all the numbers from start to end + ✔ Returns the sum of the powers of all the numbers from start to end + + Testing symmetricDifference + + ✔ symmetricDifference is a Function + ✔ Returns the symmetric difference between two arrays. + + Testing tail + + ✔ tail is a Function + ✔ Returns tail + ✔ Returns tail + + Testing take + + ✔ take is a Function + ✔ Returns an array with n elements removed from the beginning. + ✔ Returns an array with n elements removed from the beginning. + + Testing takeRight + + ✔ takeRight is a Function + ✔ Returns an array with n elements removed from the end + ✔ Returns an array with n elements removed from the end + + Testing timeTaken + + ✔ timeTaken is a Function + + Testing toCamelCase + + ✔ toCamelCase is a Function + ✔ Converts a string to camelCase + ✔ Converts a string to camelCase + ✔ Converts a string to camelCase + ✔ Converts a string to camelCase + + Testing toDecimalMark + + ✔ toDecimalMark is a Function + ✔ convert a float-point arithmetic to the Decimal mark form + + Testing toKebabCase + + ✔ toKebabCase is a Function + ✔ string converts to snake case + ✔ string converts to snake case + ✔ string converts to snake case + ✔ string converts to snake case + + Testing toOrdinalSuffix + + ✔ toOrdinalSuffix is a Function + ✔ Adds an ordinal suffix to a number + ✔ Adds an ordinal suffix to a number + ✔ Adds an ordinal suffix to a number + ✔ Adds an ordinal suffix to a number + + Testing toSafeInteger + + ✔ toSafeInteger is a Function + ✔ Converts a value to a safe integer + ✔ Converts a value to a safe integer + ✔ Converts a value to a safe integer + ✔ Converts a value to a safe integer + ✔ Converts a value to a safe integer + + Testing toSnakeCase + + ✔ toSnakeCase is a Function + ✔ string converts to snake case + ✔ string converts to snake case + ✔ string converts to snake case + ✔ string converts to snake case + + Testing toggleClass + + ✔ toggleClass is a Function + + Testing tomorrow + + ✔ tomorrow is a Function + + Testing transform + + ✔ transform is a Function + + Testing truncateString + + ✔ truncateString is a Function + ✔ Truncates a "boomerang" up to a specified length. + + Testing truthCheckCollection + + ✔ truthCheckCollection is a Function + ✔ second argument is truthy on all elements of a collection + + Testing unescapeHTML + + ✔ unescapeHTML is a Function + ✔ Unescapes escaped HTML characters. + + Testing union + + ✔ union is a Function + ✔ Returns every element that exists in any of the two arrays once + + Testing uniqueElements + + ✔ uniqueElements is a Function + ✔ Returns all unique values of an array + + Testing untildify + + ✔ untildify is a Function Testing validateNumber - √ validateNumber is a Function - √ validateNumber(9) returns true - √ validateNumber(234asd.slice(0, 2)) returns true - √ validateNumber(1232) returns true - √ validateNumber(1232 + 13423) returns true - √ validateNumber(1232 * 2342 * 123) returns true - √ validateNumber(1232.23423536) returns true - √ validateNumber(234asd) returns false - √ validateNumber(e234d) returns false - √ validateNumber(false) returns false - √ validateNumber(true) returns false - √ validateNumber(null) returns false - √ validateNumber(123 * asd) returns false + ✔ validateNumber is a Function + ✔ validateNumber(9) returns true + ✔ validateNumber(234asd.slice(0, 2)) returns true + ✔ validateNumber(1232) returns true + ✔ validateNumber(1232 + 13423) returns true + ✔ validateNumber(1232 * 2342 * 123) returns true + ✔ validateNumber(1232.23423536) returns true + ✔ validateNumber(234asd) returns false + ✔ validateNumber(e234d) returns false + ✔ validateNumber(false) returns false + ✔ validateNumber(true) returns false + ✔ validateNumber(null) returns false + ✔ validateNumber(123 * asd) returns false Testing without - √ without is a Function - √ without([2, 1, 2, 3], 1, 2) returns [3] - √ without([]) returns [] - √ without([3, 1, true, '3', true], '3', true) returns [3, 1] - √ without('string'.split(''), 's', 't', 'g') returns ['r', 'i', 'n'] - √ without() throws an error - √ without(null) throws an error - √ without(undefined) throws an error - √ without() throws an error - √ without({}) throws an error + ✔ without is a Function + ✔ without([2, 1, 2, 3], 1, 2) returns [3] + ✔ without([]) returns [] + ✔ without([3, 1, true, '3', true], '3', true) returns [3, 1] + ✔ without('string'.split(''), 's', 't', 'g') returns ['r', 'i', 'n'] + ✔ without() throws an error + ✔ without(null) throws an error + ✔ without(undefined) throws an error + ✔ without() throws an error + ✔ without({}) throws an error Testing words - √ words is a Function - √ words('I love javaScript!!') returns [I, love, javaScript] - √ words('python, javaScript & coffee') returns [python, javaScript, coffee] - √ words(I love javaScript!!) returns an array - √ words() throws a error - √ words(null) throws a error - √ words(undefined) throws a error - √ words({}) throws a error - √ words([]) throws a error - √ words(1234) throws a error + ✔ words is a Function + ✔ words('I love javaScript!!') returns [I, love, javaScript] + ✔ words('python, javaScript & coffee') returns [python, javaScript, coffee] + ✔ words(I love javaScript!!) returns an array + ✔ words() throws a error + ✔ words(null) throws a error + ✔ words(undefined) throws a error + ✔ words({}) throws a error + ✔ words([]) throws a error + ✔ words(1234) throws a error Testing yesNo - √ yesNo is a Function - √ yesNo(Y) returns true - √ yesNo(yes) returns true - √ yesNo(foo, true) returns true - √ yesNo(No) returns false - √ yesNo() returns false - √ yesNo(null) returns false - √ yesNo(undefined) returns false - √ yesNo([123, null]) returns false - √ yesNo([Yes, No]) returns false - √ yesNo({ 2: Yes }) returns false - √ yesNo([Yes, No], true) returns true - √ yesNo({ 2: Yes }, true) returns true + ✔ yesNo is a Function + ✔ yesNo(Y) returns true + ✔ yesNo(yes) returns true + ✔ yesNo(foo, true) returns true + ✔ yesNo(No) returns false + ✔ yesNo() returns false + ✔ yesNo(null) returns false + ✔ yesNo(undefined) returns false + ✔ yesNo([123, null]) returns false + ✔ yesNo([Yes, No]) returns false + ✔ yesNo({ 2: Yes }) returns false + ✔ yesNo([Yes, No], true) returns true + ✔ yesNo({ 2: Yes }, true) returns true Testing zip - √ zip is a Function - √ zip([a, b], [1, 2], [true, false]) returns [[a, 1, true], [b, 2, false]] - √ zip([a], [1, 2], [true, false]) returns [[a, 1, true], [undefined, 2, false]] - √ zip([]) returns [] - √ zip(123) returns [] - √ zip([a, b], [1, 2], [true, false]) returns an Array - √ zip([a], [1, 2], [true, false]) returns an Array - √ zip(null) throws an error - √ zip(undefined) throws an error + ✔ zip is a Function + ✔ zip([a, b], [1, 2], [true, false]) returns [[a, 1, true], [b, 2, false]] + ✔ zip([a], [1, 2], [true, false]) returns [[a, 1, true], [undefined, 2, false]] + ✔ zip([]) returns [] + ✔ zip(123) returns [] + ✔ zip([a, b], [1, 2], [true, false]) returns an Array + ✔ zip([a], [1, 2], [true, false]) returns an Array + ✔ zip(null) throws an error + ✔ zip(undefined) throws an error Testing zipObject - √ zipObject is a Function - √ zipObject([a, b, c], [1, 2]) returns {a: 1, b: 2, c: undefined} - √ zipObject([a, b], [1, 2, 3]) returns {a: 1, b: 2} - √ zipObject([a, b, c], string) returns { a: s, b: t, c: r } - √ zipObject([a], string) returns { a: s } - √ zipObject() throws an error - √ zipObject([string], null) throws an error - √ zipObject(null, [1]) throws an error - √ zipObject(string) throws an error - √ zipObject(test, string) throws an error + ✔ zipObject is a Function + ✔ zipObject([a, b, c], [1, 2]) returns {a: 1, b: 2, c: undefined} + ✔ zipObject([a, b], [1, 2, 3]) returns {a: 1, b: 2} + ✔ zipObject([a, b, c], string) returns { a: s, b: t, c: r } + ✔ zipObject([a], string) returns { a: s } + ✔ zipObject() throws an error + ✔ zipObject([string], null) throws an error + ✔ zipObject(null, [1]) throws an error + ✔ zipObject(string) throws an error + ✔ zipObject(test, string) throws an error - total: 551 - passing: 551 - duration: 399ms + total: 554 + passing: 554 + duration: 329ms