Creates a function that accepts up to n arguments, ignoring any additional arguments.
Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).
const ary = ( fn, n) => ( ... args) => fn ( ... args. slice ( 0 , n));
+ }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray CSVToJSON decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Adapter ary Creates a function that accepts up to n arguments, ignoring any additional arguments.
Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).
const ary = ( fn, n) => ( ... args) => fn ( ... args. slice ( 0 , n));
Show examples const firstTwoMax = ary ( Math. max, 2 );
[[ 2 , 6 , 'a' ], [ 8 , 4 , 6 ], [ 10 ]]. map ( x => firstTwoMax ( ... x));
📋 Copy to clipboard call Given a key and a set of arguments, call them when given a context. Primarily useful in composition.
Use a closure to call a stored key with stored arguments.
const call = ( key, ... args) => context => context[ key]( ... args);
diff --git a/docs/array.html b/docs/array.html
index ece03846a..823d0232b 100644
--- a/docs/array.html
+++ b/docs/array.html
@@ -79,7 +79,7 @@
document.getElementById('doc-drawer-checkbox').checked = false;
}
}, false);
- }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Array all Returns true if the provided predicate function returns true for all elements in a collection, false otherwise.
Use Array.every() to test if all elements in the collection return true based on fn. Omit the second argument, fn, to use Boolean as a default.
const all = ( arr, fn = Boolean) => arr. every ( fn);
+ }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray CSVToJSON decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Array all Returns true if the provided predicate function returns true for all elements in a collection, false otherwise.
Use Array.every() to test if all elements in the collection return true based on fn. Omit the second argument, fn, to use Boolean as a default.
const all = ( arr, fn = Boolean) => arr. every ( fn);
Show examples all ([ 4 , 2 , 3 ], x => x > 1 );
all ([ 1 , 2 , 3 ]);
📋 Copy to clipboard any Returns true if the provided predicate function returns true for at least one element in a collection, false otherwise.
Use Array.some() to test if any elements in the collection return true based on fn. Omit the second argument, fn, to use Boolean as a default.
const any = ( arr, fn = Boolean) => arr. some ( fn);
diff --git a/docs/browser.html b/docs/browser.html
index 9b5a3cb83..b3e2d2c04 100644
--- a/docs/browser.html
+++ b/docs/browser.html
@@ -79,7 +79,7 @@
document.getElementById('doc-drawer-checkbox').checked = false;
}
}, false);
- }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Browser arrayToHtmlList Converts the given array elements into <li> tags and appends them to the list of the given id.
Use Array.map(), document.querySelector(), and an anonymous inner closure to create a list of html tags.
const arrayToHtmlList = ( arr, listID) =>
+ }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray CSVToJSON decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Browser arrayToHtmlList Converts the given array elements into <li> tags and appends them to the list of the given id.
Use Array.map(), document.querySelector(), and an anonymous inner closure to create a list of html tags.
const arrayToHtmlList = ( arr, listID) =>
( el => (
( el = document. querySelector ( '#' + listID)),
( el. innerHTML += arr. map ( item => `<li> ${ item} </li>` ). join ( '' ))
diff --git a/docs/date.html b/docs/date.html
index fcb5cf3c1..c49b7461b 100644
--- a/docs/date.html
+++ b/docs/date.html
@@ -79,7 +79,7 @@
document.getElementById('doc-drawer-checkbox').checked = false;
}
}, false);
- }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Date Returns the human readable format of the given number of milliseconds.
Divide ms with the appropriate values to obtain the appropriate values for day, hour, minute, second and millisecond. Use Object.entries() with Array.filter() to keep only non-zero values. Use Array.map() to create the string for each value, pluralizing appropriately. Use String.join(', ') to combine the values into a string.
const formatDuration = ms => {
+ }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray CSVToJSON decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Date Returns the human readable format of the given number of milliseconds.
Divide ms with the appropriate values to obtain the appropriate values for day, hour, minute, second and millisecond. Use Object.entries() with Array.filter() to keep only non-zero values. Use Array.map() to create the string for each value, pluralizing appropriately. Use String.join(', ') to combine the values into a string.
const formatDuration = ms => {
if ( ms < 0 ) ms = - ms;
const time = {
day: Math. floor ( ms / 86400000 ),
diff --git a/docs/function.html b/docs/function.html
index 9954e7c4d..ea5e9657d 100644
--- a/docs/function.html
+++ b/docs/function.html
@@ -79,7 +79,7 @@
document.getElementById('doc-drawer-checkbox').checked = false;
}
}, false);
- }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Function attempt Attempts to invoke a function with the provided arguments, returning either the result or the caught error object.
Use a try... catch block to return either the result of the function or an appropriate error.
const attempt = ( fn, ... args) => {
+ }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray CSVToJSON decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Function attempt Attempts to invoke a function with the provided arguments, returning either the result or the caught error object.
Use a try... catch block to return either the result of the function or an appropriate error.
const attempt = ( fn, ... args) => {
try {
return fn ( ... args);
} catch ( e ) {
diff --git a/docs/math.html b/docs/math.html
index f3e533bda..e201590a6 100644
--- a/docs/math.html
+++ b/docs/math.html
@@ -79,7 +79,7 @@
document.getElementById('doc-drawer-checkbox').checked = false;
}
}, false);
- }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Math approximatelyEqual Checks if two numbers are approximately equal to each other.
Use Math.abs() to compare the absolute difference of the two values to epsilon. Omit the third parameter, epsilon, to use a default value of 0.001.
const approximatelyEqual = ( v1, v2, epsilon = 0.001 ) => Math. abs ( v1 - v2) < epsilon;
+ }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray CSVToJSON decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Math approximatelyEqual Checks if two numbers are approximately equal to each other.
Use Math.abs() to compare the absolute difference of the two values to epsilon. Omit the third parameter, epsilon, to use a default value of 0.001.
const approximatelyEqual = ( v1, v2, epsilon = 0.001 ) => Math. abs ( v1 - v2) < epsilon;
Show examples approximatelyEqual ( Math. PI / 2.0 , 1.5708 );
📋 Copy to clipboard average Returns the average of two or more numbers.
Use Array.reduce() to add each value to an accumulator, initialized with a value of 0, divide by the length of the array.
const average = ( ... nums) => [ ... nums]. reduce (( acc, val) => acc + val, 0 ) / nums. length;
Show examples average ( ... [ 1 , 2 , 3 ]);
diff --git a/docs/node.html b/docs/node.html
index 679ab6f88..44d7f146d 100644
--- a/docs/node.html
+++ b/docs/node.html
@@ -79,7 +79,7 @@
document.getElementById('doc-drawer-checkbox').checked = false;
}
}, false);
- }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Node atob Decodes a string of data which has been encoded using base-64 encoding.
Create a Buffer for the given string with base-64 encoding and use Buffer.toString('binary') to return the decoded string.
const atob = str => new Buffer ( str, 'base64' ). toString ( 'binary' );
+ }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray CSVToJSON decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Node atob Decodes a string of data which has been encoded using base-64 encoding.
Create a Buffer for the given string with base-64 encoding and use Buffer.toString('binary') to return the decoded string.
const atob = str => new Buffer ( str, 'base64' ). toString ( 'binary' );
Show examples atob ( 'Zm9vYmFy' );
📋 Copy to clipboard btoa Creates a base-64 encoded ASCII string from a String object in which each character in the string is treated as a byte of binary data.
Create a Buffer for the given string with binary encoding and use Buffer.toString('base64') to return the encoded string.
const btoa = str => new Buffer ( str, 'binary' ). toString ( 'base64' );
Show examples btoa ( 'foobar' );
diff --git a/docs/object.html b/docs/object.html
index a4ecf1699..34eef1874 100644
--- a/docs/object.html
+++ b/docs/object.html
@@ -79,7 +79,7 @@
document.getElementById('doc-drawer-checkbox').checked = false;
}
}, false);
- }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Object bindAll Binds methods of an object to the object itself, overwriting the existing method.
Use Array.forEach() to return a function that uses Function.apply() to apply the given context (obj) to fn for each function specified.
const bindAll = ( obj, ... fns) =>
+ }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray CSVToJSON decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Object bindAll Binds methods of an object to the object itself, overwriting the existing method.
Use Array.forEach() to return a function that uses Function.apply() to apply the given context (obj) to fn for each function specified.
const bindAll = ( obj, ... fns) =>
fns. forEach (
fn => (
( f = obj[ fn]),
diff --git a/docs/string.html b/docs/string.html
index 9d5b56472..79acbb2b8 100644
--- a/docs/string.html
+++ b/docs/string.html
@@ -79,7 +79,7 @@
document.getElementById('doc-drawer-checkbox').checked = false;
}
}, false);
- }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo String byteSize Returns the length of a string in bytes.
Convert a given string to a Blob Object and find its size.
const byteSize = str => new Blob ([ str]). size;
+ }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray CSVToJSON decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo String byteSize Returns the length of a string in bytes.
Convert a given string to a Blob Object and find its size.
const byteSize = str => new Blob ([ str]). size;
Show examples byteSize ( '😀' );
byteSize ( 'Hello World' );
📋 Copy to clipboard capitalize Capitalizes the first letter of a string.
Use array destructuring and String.toUpperCase() to capitalize first letter, ...rest to get array of characters after first letter and then Array.join('') to make it a string again. Omit the lowerRest parameter to keep the rest of the string intact, or set it to true to convert to lowercase.
const capitalize = ([ first, ... rest], lowerRest = false ) =>
@@ -96,6 +96,18 @@
Show examples CSVToArray ( 'a,b\nc,d' );
CSVToArray ( 'a;b\nc;d' , ';' );
CSVToArray ( 'col1,col2\na,b\nc,d' , ',' , true );
+📋 Copy to clipboard CSVToJSONadvanced Converts a comma-separated values (CSV) string to a 2D array of objects. The first row of the string is used as the title row.
Use Array.slice() and Array.indexOf('\n') and String.split(delimiter) to separate the first row (title row) into values. Use String.split('\n') to create a string for each row, then Array.map() and String.split(delimiter) to separate the values in each row. Use Array.reduce() to create an object for each row's values, with the keys parsed from the title row. Omit the second argument, delimiter, to use a default delimiter of ,.
const CSVToJSON = ( data, delimiter = ',' ) => {
+ const titles = data. slice ( 0 , data. indexOf ( '\n' )). split ( delimiter);
+ return data
+ . slice ( data. indexOf ( '\n' ) + 1 )
+ . split ( '\n' )
+ . map ( v => {
+ const values = v. split ( delimiter);
+ return titles. reduce (( obj, title, index) => (( obj[ title] = values[ index]), obj), {});
+ });
+};
+Show examples CSVToJSON ( 'col1,col2\na,b\nc,d' );
+CSVToJSON ( 'col1;col2\na;b\nc;d' , ';' );
📋 Copy to clipboard decapitalize Decapitalizes the first letter of a string.
Use array destructuring and String.toLowerCase() to decapitalize first letter, ...rest to get array of characters after first letter and then Array.join('') to make it a string again. Omit the upperRest parameter to keep the rest of the string intact, or set it to true to convert to uppercase.
const decapitalize = ([ first, ... rest], upperRest = false ) =>
first. toLowerCase () + ( upperRest ? rest. join ( '' ). toUpperCase () : rest. join ( '' ));
Show examples decapitalize ( 'FooBar' );
diff --git a/docs/type.html b/docs/type.html
index 751305b4a..7d661ac41 100644
--- a/docs/type.html
+++ b/docs/type.html
@@ -79,7 +79,7 @@
document.getElementById('doc-drawer-checkbox').checked = false;
}
}, false);
- }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Type getType Returns the native type of a value.
Returns lowercased constructor name of value, "undefined" or "null" if value is undefined or null.
const getType = v =>
+ }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray CSVToJSON decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Type getType Returns the native type of a value.
Returns lowercased constructor name of value, "undefined" or "null" if value is undefined or null.
const getType = v =>
v === undefined ? 'undefined' : v === null ? 'null' : v. constructor. name. toLowerCase ();
Show examples getType ( new Set ([ 1 , 2 , 3 ]));
📋 Copy to clipboard is Checks if the provided value is of the specified type.
Ensure the value is not undefined or null using Array.includes(), and compare the constructor property on the value with type to check if the provided value is of the specified type.
const is = ( type, val) => ! [, null ]. includes ( val) && val. constructor === type;
diff --git a/docs/utility.html b/docs/utility.html
index 57a5643c4..63d301600 100644
--- a/docs/utility.html
+++ b/docs/utility.html
@@ -79,7 +79,7 @@
document.getElementById('doc-drawer-checkbox').checked = false;
}
}, false);
- }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Utility castArray Casts the provided value as an array if it's not one.
Use Array.isArray() to determine if val is an array and return it as-is or encapsulated in an array accordingly.
const castArray = val => ( Array. isArray ( val) ? val : [ val]);
+ }
Adapter ary call collectInto flip over overArgs pipeAsyncFunctions pipeFunctions promisify rearg spreadOver unary Array all any arrayToCSV bifurcate bifurcateBy chunk compact countBy countOccurrences deepFlatten difference differenceBy differenceWith drop dropRight dropRightWhile dropWhile everyNth filterNonUnique findLast findLastIndex flatten forEachRight groupBy head indexOfAll initial initialize2DArray initializeArrayWithRange initializeArrayWithRangeRight initializeArrayWithValues initializeNDArray intersection intersectionBy intersectionWith isSorted join last longestItem mapObject maxN minN none nthElement offset partition permutations pull pullAtIndex pullAtValue pullBy reducedFilter reduceSuccessive reduceWhich reject remove sample sampleSize shuffle similarity sortedIndex sortedIndexBy sortedLastIndex sortedLastIndexBy stableSort symmetricDifference symmetricDifferenceBy symmetricDifferenceWith tail take takeRight takeRightWhile takeWhile toHash union unionBy unionWith uniqueElements unzip unzipWith without xProd zip zipObject zipWith Browser arrayToHtmlList bottomVisible copyToClipboard counter createElement createEventHub currentURL detectDeviceType elementContains elementIsVisibleInViewport getScrollPosition getStyle hasClass hashBrowser hide httpsRedirect insertAfter insertBefore isBrowserTabFocused nodeListToArray observeMutations off on onUserInputChange prefix recordAnimationFrames redirect runAsync scrollToTop setStyle show smoothScroll toggleClass triggerEvent UUIDGeneratorBrowser Date formatDuration getColonTimeFromDate getDaysDiffBetweenDates getMeridiemSuffixOfInteger tomorrow Function attempt bind bindKey chainAsync compose composeRight converge curry debounce defer delay functionName hz memoize negate once partial partialRight runPromisesInSeries sleep throttle times uncurry unfold when Math approximatelyEqual average averageBy binomialCoefficient clampNumber degreesToRads digitize distance elo factorial fibonacci gcd geometricProgression hammingDistance inRange isDivisible isEven isPrime lcm luhnCheck maxBy median minBy percentile powerset primes radsToDegrees randomIntArrayInRange randomIntegerInRange randomNumberInRange round sdbm standardDeviation sum sumBy sumPower toSafeInteger Node atob btoa colorize hasFlags hashNode isTravisCI JSONToFile readFileLines untildify UUIDGeneratorNode Object bindAll deepClone defaults equals findKey findLastKey flattenObject forOwn forOwnRight functions get invertKeyValues lowercaseKeys mapKeys mapValues matches matchesWith merge nest objectFromPairs objectToPairs omit omitBy orderBy pick pickBy renameKeys shallowClone size transform truthCheckCollection unflattenObject String byteSize capitalize capitalizeEveryWord CSVToArray CSVToJSON decapitalize escapeHTML escapeRegExp fromCamelCase isAbsoluteURL isAnagram isLowerCase isUpperCase mask pad palindrome pluralize removeNonASCII reverseString sortCharactersInString splitLines stringPermutations stripHTMLTags toCamelCase toKebabCase toSnakeCase truncateString unescapeHTML URLJoin words Type getType is isArrayLike isBoolean isEmpty isFunction isNil isNull isNumber isObject isObjectLike isPlainObject isPrimitive isPromiseLike isString isSymbol isUndefined isValidJSON Utility castArray cloneRegExp coalesce coalesceFactory extendHex getURLParameters hexToRGB httpGet httpPost isBrowser mostPerformant nthArg parseCookie prettyBytes randomHexColorCode RGBToHex serializeCookie timeTaken toCurrency toDecimalMark toOrdinalSuffix validateNumber yesNo Utility castArray Casts the provided value as an array if it's not one.
Use Array.isArray() to determine if val is an array and return it as-is or encapsulated in an array accordingly.
const castArray = val => ( Array. isArray ( val) ? val : [ val]);
Show examples castArray ( 'foo' );
castArray ([ 1 ]);
📋 Copy to clipboard cloneRegExp Clones a regular expression.
Use new RegExp(), RegExp.source and RegExp.flags to clone the given regular expression.
const cloneRegExp = regExp => new RegExp ( regExp. source, regExp. flags);
diff --git a/snippets/CSVToJSON.md b/snippets/CSVToJSON.md
index 15809c916..e9117d8a3 100644
--- a/snippets/CSVToJSON.md
+++ b/snippets/CSVToJSON.md
@@ -10,12 +10,15 @@ Omit the second argument, `delimiter`, to use a default delimiter of `,`.
```js
const CSVToJSON = (data, delimiter = ',') => {
- const titles = data.slice(0,data.indexOf('\n')).split(delimiter);
- return data.slice(data.indexOf('\n')+1).split('\n').map(v => {
- const values = v.split(delimiter);
- return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {});
- });
-}
+ const titles = data.slice(0, data.indexOf('\n')).split(delimiter);
+ return data
+ .slice(data.indexOf('\n') + 1)
+ .split('\n')
+ .map(v => {
+ const values = v.split(delimiter);
+ return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {});
+ });
+};
```
```js