diff --git a/README.md b/README.md
index 95a5000fd..a64842de8 100644
--- a/README.md
+++ b/README.md
@@ -248,7 +248,7 @@ const promisify = func =>
### spreadOver
-Takes a veriadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.
+Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.
Use closures and the spread operator (`...`) to map the array of arguments to the inputs of the function.
@@ -283,9 +283,9 @@ const arrayGcd = arr =>{
### arrayLcm
-Calculates the lowest common multiple (lcm) of an array of numbers.
+Calculates the lowest common multiple (lcm) of an array of numbers.
-Use `Array.reduce()` and the `lcm` formula (uses recursion) to calculate the lowest common multiple of an array of numbers.
+Use `Array.reduce()` and the `lcm` formula (uses recursion) to calculate the lowest common multiple of an array of numbers.
```js
const arrayLcm = arr =>{
@@ -512,7 +512,7 @@ const flattenDepth = (arr, depth = 1) =>
### groupBy
-Groups the element of an array based on the given function.
+Groups the elements of an array based on the given function.
Use `Array.map()` to map the values of an array to a function or property name.
Use `Array.reduce()` to create an object, where the keys are produced from the mapped results.
@@ -544,7 +544,7 @@ const head = arr => arr[0];
Returns all the elements of an array except the last one.
-Use `arr.slice(0,-1)`to return all but the last element of the array.
+Use `arr.slice(0,-1)` to return all but the last element of the array.
```js
const initial = arr => arr.slice(0, -1);
@@ -555,9 +555,9 @@ const initial = arr => arr.slice(0, -1);
### initialize2DArray
-Initializes an 2D array of given width and height and value.
+Initializes a 2D array of given width and height and value.
-Use `Array.map()` to generate h rows where each is a new array of size w initialize with value. If value is not provided, default to `null`.
+Use `Array.map()` to generate h rows where each is a new array of size w initialize with value. If the value is not provided, default to `null`.
```js
const initialize2DArray = (w, h, val = null) => Array(h).fill().map(() => Array(w).fill(val));
@@ -613,7 +613,7 @@ const intersection = (a, b) => { const s = new Set(b); return a.filter(x => s.ha
Returns the last element in an array.
-Use `arr.length - 1` to compute index of the last element of the given array and returning it.
+Use `arr.length - 1` to compute the index of the last element of the given array and returning it.
```js
const last = arr => arr[arr.length - 1];
@@ -626,7 +626,7 @@ const last = arr => arr[arr.length - 1];
Maps the values of an array to an object using a function, where the key-value pairs consist of the original value as the key and the mapped value.
-Use an anonymous inner function scope to declare an undefined memory space, using closures to store a return value. Use a new `Array` to stor the array with a map of the function over its data set and a comma operator to return a second step, without needing to move from one context to another (due to closures and order of operations).
+Use an anonymous inner function scope to declare an undefined memory space, using closures to store a return value. Use a new `Array` to store the array with a map of the function over its data set and a comma operator to return a second step, without needing to move from one context to another (due to closures and order of operations).
```js
const mapObject = (arr, fn) =>
@@ -659,7 +659,7 @@ const nthElement = (arr, n=0) => (n>0? arr.slice(n,n+1) : arr.slice(n))[0];
Picks the key-value pairs corresponding to the given keys from an object.
-Use `Array.reduce()` to convert the filtered/picked keys back to a object with the corresponding key-value pair if the key exist in the obj.
+Use `Array.reduce()` to convert the filtered/picked keys back to an object with the corresponding key-value pair if the key exists in the obj.
```js
const pick = (obj, arr) =>
@@ -674,7 +674,7 @@ const pick = (obj, arr) =>
Mutates the original array to filter out the values specified.
Use `Array.filter()` and `Array.includes()` to pull out the values that are not needed.
-Use `Array.length = 0` to mutate the passed in array by resetting it's length to zero and `Array.push()` to re-populate it with only the pulled values.
+Use `Array.length = 0` to mutate the passed in an array by resetting it's length to zero and `Array.push()` to re-populate it with only the pulled values.
_(For a snippet that does not mutate the original array see [`without`](#without))_
@@ -702,7 +702,7 @@ const pull = (arr, ...args) => {
Mutates the original array to filter out the values at the specified indexes.
Use `Array.filter()` and `Array.includes()` to pull out the values that are not needed.
-Use `Array.length = 0` to mutate the passed in array by resetting it's length to zero and `Array.push()` to re-populate it with only the pulled values.
+Use `Array.length = 0` to mutate the passed in an array by resetting it's length to zero and `Array.push()` to re-populate it with only the pulled values.
Use `Array.push()` to keep track of pulled values
```js
@@ -729,7 +729,7 @@ const pullAtIndex = (arr, pullArr) => {
Mutates the original array to filter out the values specified. Returns the removed elements.
Use `Array.filter()` and `Array.includes()` to pull out the values that are not needed.
-Use `Array.length = 0` to mutate the passed in array by resetting it's length to zero and `Array.push()` to re-populate it with only the pulled values.
+Use `Array.length = 0` to mutate the passed in an array by resetting it's length to zero and `Array.push()` to re-populate it with only the pulled values.
Use `Array.push()` to keep track of pulled values
```js
@@ -773,7 +773,7 @@ const remove = (arr, func) =>
Returns a random element from an array.
-Use `Math.random()` to generate a random number, multiply it with `length` and round it of to the nearest whole number using `Math.floor()`.
+Use `Math.random()` to generate a random number, multiply it by `length` and round it of to the nearest whole number using `Math.floor()`.
This method also works with strings.
```js
@@ -829,7 +829,7 @@ const symmetricDifference = (a, b) => {
Returns all elements in an array except for the first one.
-Return `arr.slice(1)` if the array's `length` is more than `1`, otherwise return the whole array.
+Return `arr.slice(1)` if the array's `length` is more than `1`, otherwise, return the whole array.
```js
const tail = arr => arr.length > 1 ? arr.slice(1) : arr;
@@ -1063,7 +1063,7 @@ const redirect = (url, asLink = true) =>
Smooth-scrolls to the top of the page.
Get distance from top using `document.documentElement.scrollTop` or `document.body.scrollTop`.
-Scroll by a fraction of the distance from top. Use `window.requestAnimationFrame()` to animate the scrolling.
+Scroll by a fraction of the distance from the top. Use `window.requestAnimationFrame()` to animate the scrolling.
```js
const scrollToTop = () => {
@@ -1083,7 +1083,7 @@ const scrollToTop = () => {
Returns the difference (in days) between two dates.
-Calculate the difference (in days) between to `Date` objects.
+Calculate the difference (in days) between two `Date` objects.
```js
const getDaysDiffBetweenDates = (dateInitial, dateFinal) => (dateFinal - dateInitial) / (1000 * 3600 * 24);
@@ -1112,7 +1112,7 @@ const JSONToDate = arr => {
Converts a date from American format to English format.
-Use `Date.toISOString()`, `split('T')` and `replace()` to convert a date from American format to English format.
+Use `Date.toISOString()`, `split('T')` and `replace()` to convert a date from American format to the English format.
Throws an error if the passed time cannot be converted to a date.
```js
@@ -1168,7 +1168,7 @@ Curries a function.
Use recursion.
If the number of provided arguments (`args`) is sufficient, call the passed function `f`.
-Otherwise return a curried function `f` that expects the rest of the arguments.
+Otherwise, return a curried function `f` that expects the rest of the arguments.
If you want to curry a function that accepts a variable number of arguments (a variadic function, e.g. `Math.min()`), you can optionally pass the number of arguments to the second parameter `arity`.
```js
@@ -1280,7 +1280,7 @@ Clamps `num` within the inclusive `lower` and `upper` bounds.
If `lower` is greater than `upper`, swap them.
If `num` falls within the range, return `num`.
-Otherwise return the nearest number in the range.
+Otherwise, return the nearest number in the range.
```js
const clampNumber = (num, lower, upper) => {
@@ -1298,7 +1298,7 @@ const clampNumber = (num, lower, upper) => {
Applies the Collatz algorithm.
-If `n` is even, return `n/2`. Otherwise return `3n+1`.
+If `n` is even, return `n/2`. Otherwise, return `3n+1`.
```js
const collatz = n => (n % 2 == 0) ? (n / 2) : (3 * n + 1);
@@ -1387,7 +1387,7 @@ const gcd = (x, y) => !y ? x : gcd(y, x % y);
Calculates the Hamming distance between two values.
-Use XOR operator (`^`) to find the bit difference between the two numbers, convert to binary string using `toString(2)`.
+Use XOR operator (`^`) to find the bit difference between the two numbers, convert to a binary string using `toString(2)`.
Count and return the number of `1`s in the string, using `match(/1/g)`.
```js
@@ -1400,10 +1400,10 @@ const hammingDistance = (num1, num2) =>
### inRange
-Checks if the given number falls in the given range.
+Checks if the given number falls within the given range.
Use arithmetic comparison to check if the given number is in the specified range.
-If the second parameter, `end`, is not specified, the reange is considered to be from `0` to `start`.
+If the second parameter, `end`, is not specified, the range is considered to be from `0` to `start`.
```js
const inRange = (n, start, end=null) => {
@@ -1420,9 +1420,9 @@ const inRange = (n, start, end=null) => {
### isArmstrongNumber
-Checks if the given number is an armstrong number or not.
+Checks if the given number is an Armstrong number or not.
-Convert the given number into array of digits. Use `Math.pow()` to get the appropriate power for each digit and sum them up. If the sum is equal to the number itself, return `true` otherwise `false`.
+Convert the given number into an array of digits. Use `Math.pow()` to get the appropriate power for each digit and sum them up. If the sum is equal to the number itself, return `true` otherwise `false`.
```js
const isArmstrongNumber = digits =>
@@ -1706,7 +1706,7 @@ const readFileLines = filename => fs.readFileSync(filename).toString('UTF8').spl
Removes any properties except the ones specified from a JSON object.
-Use `Object.keys()` method to loop over given json object and deleting keys that are not `include`d in given array.
+Use `Object.keys()` method to loop over given JSON object and deleting keys that are not `include`d in given array.
Also if you give it a special key (`childIndicator`) it will search deeply inside it to apply function to inner objects too.
```js
@@ -1784,9 +1784,9 @@ orderby(users, ['name', 'age']) -> [{name: 'barney', age: 34}, {name: 'barney',
### select
-Retrieve a property that indicated by the selector from object.
+Retrieve a property that indicated by the selector from an object.
-If property not exists returns `undefined`.
+If the property does not exists returns `undefined`.
```js
const select = (from, selector) =>
@@ -1882,7 +1882,7 @@ const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperC
Retuns `number` of vowels in provided string.
-Use a regular expression to count number of vowels `(A, E, I, O, U)` in a `string`.
+Use a regular expression to count the number of vowels `(A, E, I, O, U)` in a `string`.
```js
const countVowels = str => (str.match(/[aeiou]/ig) || []).length;
@@ -1909,7 +1909,7 @@ const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
Converts a string from camelcase.
-Use `replace()` to remove underscores, hyphens and spaces and convert words to camelcase.
+Use `replace()` to remove underscores, hyphens, and spaces and convert words to camelcase.
Omit the second argument to use a default separator of `_`.
```js
@@ -1955,7 +1955,7 @@ const sortCharactersInString = str =>
Converts a string to camelcase.
-Use `replace()` to remove underscores, hyphens and spaces and convert words to camelcase.
+Use `replace()` to remove underscores, hyphens, and spaces and convert words to camelcase.
```js
const toCamelCase = str =>
@@ -1987,7 +1987,7 @@ const truncateString = (str, num) =>
Converts a given string into an array of words.
-Use `String.split()` with a supplied pattern (defaults to non alpha as a regex) to convert to an array of strings. Use `Array.filter()` to remove any empty strings.
+Use `String.split()` with a supplied pattern (defaults to non-alpha as a regex) to convert to an array of strings. Use `Array.filter()` to remove any empty strings.
Omit the second argument to use the default regex.
```js
@@ -2059,7 +2059,7 @@ const getType = v =>
Converts a color code to a `rgb()` or `rgba()` string if alpha value is provided.
-Use bitwise right-shift operator and mask bits with `&` (and) operator to convert a hexadecimal color code (with or without prefixed with `#`) to a string with the RGB values. If it's 3-digit color code, first convert to 6-digit version. If any alpha value is provided alongside 6-digit hex, give `rgba()` string in return.
+Use bitwise right-shift operator and mask bits with `&` (and) operator to convert a hexadecimal color code (with or without prefixed with `#`) to a string with the RGB values. If it's 3-digit color code, first convert to 6-digit version. If an alpha value is provided alongside 6-digit hex, give `rgba()` string in return.
```js
const hexToRGB = hex => {
@@ -2167,7 +2167,7 @@ const isSymbol = val => typeof val === 'symbol';
### RGBToHex
-Converts the values of RGB components to a colorcode.
+Converts the values of RGB components to a color code.
Convert given RGB parameters to hexadecimal string using bitwise left-shift operator (`<<`) and `toString(16)`, then `padStart(6,'0')` to get a 6-digit hexadecimal value.
diff --git a/docs/index.html b/docs/index.html
index 53d9a58c8..dc8296a8e 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -245,7 +245,7 @@ Use the ...rest operator to pass in all the parameters.
Takes a veriadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.
+Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.
Use closures and the spread operator (...) to map the array of arguments to the inputs of the function.
const spreadOver = fn => argsArr => fn(...argsArr);
/*
@@ -266,8 +266,8 @@ arrayMax([1,2,4]) // -> 4
// arrayGcd([4,8,12]) -> 4
Calculates the lowest common multiple (lcm) of an array of numbers.
-Use Array.reduce() and the lcm formula (uses recursion) to calculate the lowest common multiple of an array of numbers.
Calculates the lowest common multiple (lcm) of an array of numbers.
+Use Array.reduce() and the lcm formula (uses recursion) to calculate the lowest common multiple of an array of numbers.
const arrayLcm = arr =>{
const gcd = (x, y) => !y ? x : gcd(y, x % y);
const lcm = (x, y) => (x*y)/gcd(x, y)
@@ -383,7 +383,7 @@ Omit the second element, depth to flatten only to a depth of
// flattenDepth([1,[2],[[[3],4],5]], 2) -> [1,2,[3],4,5]
Groups the element of an array based on the given function.
+Groups the elements of an array based on the given function.
Use Array.map() to map the values of an array to a function or property name.
Use Array.reduce() to create an object, where the keys are produced from the mapped results.
const groupBy = (arr, func) =>
@@ -400,13 +400,13 @@ Use Array.reduce() to create an object, where the keys are produced
Returns all the elements of an array except the last one.
-Use arr.slice(0,-1)to return all but the last element of the array.
Use arr.slice(0,-1) to return all but the last element of the array.
const initial = arr => arr.slice(0, -1);
// initial([1,2,3]) -> [1,2]
Initializes an 2D array of given width and height and value.
-Use Array.map() to generate h rows where each is a new array of size w initialize with value. If value is not provided, default to null.
Initializes a 2D array of given width and height and value.
+Use Array.map() to generate h rows where each is a new array of size w initialize with value. If the value is not provided, default to null.
const initialize2DArray = (w, h, val = null) => Array(h).fill().map(() => Array(w).fill(val));
// initializeArrayWithRange(2, 2, 0) -> [[0,0], [0,0]]
@@ -434,13 +434,13 @@ You can omit value to use a default value of 0.
Returns the last element in an array.
-Use arr.length - 1 to compute index of the last element of the given array and returning it.
Use arr.length - 1 to compute the index of the last element of the given array and returning it.
const last = arr => arr[arr.length - 1];
// last([1,2,3]) -> 3
Maps the values of an array to an object using a function, where the key-value pairs consist of the original value as the key and the mapped value.
-Use an anonymous inner function scope to declare an undefined memory space, using closures to store a return value. Use a new Array to stor the array with a map of the function over its data set and a comma operator to return a second step, without needing to move from one context to another (due to closures and order of operations).
Use an anonymous inner function scope to declare an undefined memory space, using closures to store a return value. Use a new Array to store the array with a map of the function over its data set and a comma operator to return a second step, without needing to move from one context to another (due to closures and order of operations).
const mapObject = (arr, fn) =>
(a => (a = [arr, arr.map(fn)], a[0].reduce( (acc,val,ind) => (acc[val] = a[1][ind], acc), {}) )) ( );
/*
@@ -459,7 +459,7 @@ Omit the second argument, n, to get the first element of the array.
Picks the key-value pairs corresponding to the given keys from an object.
-Use Array.reduce() to convert the filtered/picked keys back to a object with the corresponding key-value pair if the key exist in the obj.
Use Array.reduce() to convert the filtered/picked keys back to an object with the corresponding key-value pair if the key exists in the obj.
const pick = (obj, arr) =>
arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {});
// pick({ 'a': 1, 'b': '2', 'c': 3 }, ['a', 'c']) -> { 'a': 1, 'c': 3 }
@@ -467,7 +467,7 @@ Omit the second argument, n, to get the first element of the array.
Mutates the original array to filter out the values specified.
Use Array.filter() and Array.includes() to pull out the values that are not needed.
-Use Array.length = 0 to mutate the passed in array by resetting it's length to zero and Array.push() to re-populate it with only the pulled values.
Array.length = 0 to mutate the passed in an array by resetting it's length to zero and Array.push() to re-populate it with only the pulled values.
(For a snippet that does not mutate the original array see without)
const pull = (arr, ...args) => {
let argState = Array.isArray(args[0]) ? args[0] : args;
@@ -487,7 +487,7 @@ Use Array.length = 0 to mutate the passed in array by resetting it'
Mutates the original array to filter out the values at the specified indexes.
Use Array.filter() and Array.includes() to pull out the values that are not needed.
-Use Array.length = 0 to mutate the passed in array by resetting it's length to zero and Array.push() to re-populate it with only the pulled values.
+Use Array.length = 0 to mutate the passed in an array by resetting it's length to zero and Array.push() to re-populate it with only the pulled values.
Use Array.push() to keep track of pulled values
const pullAtIndex = (arr, pullArr) => {
let removed = [];
@@ -507,7 +507,7 @@ Use Array.push() to keep track of pulled values
Mutates the original array to filter out the values specified. Returns the removed elements.
Use Array.filter() and Array.includes() to pull out the values that are not needed.
-Use Array.length = 0 to mutate the passed in array by resetting it's length to zero and Array.push() to re-populate it with only the pulled values.
+Use Array.length = 0 to mutate the passed in an array by resetting it's length to zero and Array.push() to re-populate it with only the pulled values.
Use Array.push() to keep track of pulled values
const pullAtValue = (arr, pullArr) => {
let removed = [],
@@ -537,7 +537,7 @@ The func is invoked with three arguments (value, index, array
Returns a random element from an array.
-Use Math.random() to generate a random number, multiply it with length and round it of to the nearest whole number using Math.floor().
+
Use Math.random() to generate a random number, multiply it by length and round it of to the nearest whole number using Math.floor().
This method also works with strings.
const sample = arr => arr[Math.floor(Math.random() * arr.length)];
// sample([3, 7, 9, 11]) -> 9
@@ -565,7 +565,7 @@ This method also works with strings.
Returns all elements in an array except for the first one.
-Return arr.slice(1) if the array's length is more than 1, otherwise return the whole array.
Return arr.slice(1) if the array's length is more than 1, otherwise, return the whole array.
const tail = arr => arr.length > 1 ? arr.slice(1) : arr;
// tail([1,2,3]) -> [2,3]
// tail([1]) -> [1]
@@ -693,7 +693,7 @@ Pass a second argument to simulate a link click (true - default) or
Smooth-scrolls to the top of the page.
Get distance from top using document.documentElement.scrollTop or document.body.scrollTop.
-Scroll by a fraction of the distance from top. Use window.requestAnimationFrame() to animate the scrolling.
window.requestAnimationFrame() to animate the scrolling.
const scrollToTop = () => {
const c = document.documentElement.scrollTop || document.body.scrollTop;
if (c > 0) {
@@ -706,7 +706,7 @@ Scroll by a fraction of the distance from top. Use window.requestAnimation
Returns the difference (in days) between two dates.
-Calculate the difference (in days) between to Date objects.
Calculate the difference (in days) between two Date objects.
const getDaysDiffBetweenDates = (dateInitial, dateFinal) => (dateFinal - dateInitial) / (1000 * 3600 * 24);
// getDaysDiffBetweenDates(new Date("2017-12-13"), new Date("2017-12-22")) -> 9
@@ -721,7 +721,7 @@ Scroll by a fraction of the distance from top. Use window.requestAnimation
Converts a date from American format to English format.
-Use Date.toISOString(), split('T') and replace() to convert a date from American format to English format.
+
Use Date.toISOString(), split('T') and replace() to convert a date from American format to the English format.
Throws an error if the passed time cannot be converted to a date.
const toEnglishDate = (time) =>
{try{return new Date(time).toISOString().split('T')[0].replace(/-/g, '/')}catch(e){return}};
@@ -756,7 +756,7 @@ multiplyAndAdd5(5, 2) -> 15
Curries a function.
Use recursion.
If the number of provided arguments (args) is sufficient, call the passed function f.
-Otherwise return a curried function f that expects the rest of the arguments.
+Otherwise, return a curried function f that expects the rest of the arguments.
If you want to curry a function that accepts a variable number of arguments (a variadic function, e.g. Math.min()), you can optionally pass the number of arguments to the second parameter arity.
const curry = (fn, arity = fn.length, ...args) =>
arity <= args.length
@@ -819,7 +819,7 @@ async function sleepyWork() {
Clamps num within the inclusive lower and upper bounds.
If lower is greater than upper, swap them.
If num falls within the range, return num.
-Otherwise return the nearest number in the range.
+Otherwise, return the nearest number in the range.
const clampNumber = (num, lower, upper) => {
if(lower > upper) upper = [lower, lower = upper][0];
return (num>=lower && num<=upper) ? num : ((num < lower) ? lower : upper)
@@ -830,7 +830,7 @@ Otherwise return the nearest number in the range.
Applies the Collatz algorithm.
-If n is even, return n/2. Otherwise return 3n+1.
If n is even, return n/2. Otherwise, return 3n+1.
const collatz = n => (n % 2 == 0) ? (n / 2) : (3 * n + 1);
// collatz(8) --> 4
// collatz(5) --> 16
@@ -877,16 +877,16 @@ Otherwise, return the GCD of y and the remainder of the division
Calculates the Hamming distance between two values.
-Use XOR operator (^) to find the bit difference between the two numbers, convert to binary string using toString(2).
+
Use XOR operator (^) to find the bit difference between the two numbers, convert to a binary string using toString(2).
Count and return the number of 1s in the string, using match(/1/g).
const hammingDistance = (num1, num2) =>
((num1 ^ num2).toString(2).match(/1/g) || '').length;
// hammingDistance(2,3) -> 1
Checks if the given number falls in the given range.
+Checks if the given number falls within the given range.
Use arithmetic comparison to check if the given number is in the specified range.
-If the second parameter, end, is not specified, the reange is considered to be from 0 to start.
end, is not specified, the range is considered to be from 0 to start.
const inRange = (n, start, end=null) => {
if(end && start > end) end = [start, start=end][0];
return (end == null) ? (n>=0 && n<start) : (n>=start && n<end);
@@ -897,8 +897,8 @@ If the second parameter, end, is not specified, the reange is consi
// inrange(3, 2) -> false
Checks if the given number is an armstrong number or not.
-Convert the given number into array of digits. Use Math.pow() to get the appropriate power for each digit and sum them up. If the sum is equal to the number itself, return true otherwise false.
Checks if the given number is an Armstrong number or not.
+Convert the given number into an array of digits. Use Math.pow() to get the appropriate power for each digit and sum them up. If the sum is equal to the number itself, return true otherwise false.
const isArmstrongNumber = digits =>
( arr => arr.reduce( ( a, d ) => a + Math.pow( parseInt( d ), arr.length ), 0 ) == digits ? true : false )( ( digits+'' ).split( '' ) );
// isArmstrongNumber(1634) -> true
@@ -1062,7 +1062,7 @@ console.log(arr) // -> ['line1', 'line2', 'line3']
Removes any properties except the ones specified from a JSON object.
-Use Object.keys() method to loop over given json object and deleting keys that are not included in given array.
+
Use Object.keys() method to loop over given JSON object and deleting keys that are not included in given array.
Also if you give it a special key (childIndicator) it will search deeply inside it to apply function to inner objects too.
const cleanObj = (obj, keysToKeep = [], childIndicator) => {
Object.keys(obj).forEach(key => {
@@ -1113,8 +1113,8 @@ orderby(users, ['name', 'age']) -> [{name: 'barney', age: 34}, {name: 'barney
*/
Retrieve a property that indicated by the selector from object.
-If property not exists returns undefined.
Retrieve a property that indicated by the selector from an object.
+If the property does not exists returns undefined.
const select = (from, selector) =>
selector.split('.').reduce((prev, cur) => prev && prev[cur], from);
@@ -1168,7 +1168,7 @@ Omit the lowerRest parameter to keep the rest of the string intact,
Retuns number of vowels in provided string.
Use a regular expression to count number of vowels (A, E, I, O, U) in a string.
Use a regular expression to count the number of vowels (A, E, I, O, U) in a string.
const countVowels = str => (str.match(/[aeiou]/ig) || []).length;
// countVowels('foobar') -> 3
// countVowels('gym') -> 0
@@ -1181,7 +1181,7 @@ Omit the lowerRest parameter to keep the rest of the string intact,
Converts a string from camelcase.
-Use replace() to remove underscores, hyphens and spaces and convert words to camelcase.
+
Use replace() to remove underscores, hyphens, and spaces and convert words to camelcase.
Omit the second argument to use a default separator of _.
const fromCamelCase = (str, separator = '_') =>
str.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2')
@@ -1206,7 +1206,7 @@ Combine characters to get a string using join('').
Converts a string to camelcase.
-Use replace() to remove underscores, hyphens and spaces and convert words to camelcase.
Use replace() to remove underscores, hyphens, and spaces and convert words to camelcase.
const toCamelCase = str =>
str.replace(/^([A-Z])|[\s-_]+(\w)/g, (match, p1, p2, offset) => p2 ? p2.toUpperCase() : p1.toLowerCase());
// toCamelCase("some_database_field_name") -> 'someDatabaseFieldName'
@@ -1224,7 +1224,7 @@ Return the string truncated to the desired length, with ... appende
Converts a given string into an array of words.
-Use String.split() with a supplied pattern (defaults to non alpha as a regex) to convert to an array of strings. Use Array.filter() to remove any empty strings.
+
Use String.split() with a supplied pattern (defaults to non-alpha as a regex) to convert to an array of strings. Use Array.filter() to remove any empty strings.
Omit the second argument to use the default regex.
const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean);
// words("I love javaScript!!") -> ["I", "love", "javaScript"]
@@ -1262,7 +1262,7 @@ Omit the second argument to use the default regex.
Converts a color code to a rgb() or rgba() string if alpha value is provided.
Use bitwise right-shift operator and mask bits with & (and) operator to convert a hexadecimal color code (with or without prefixed with #) to a string with the RGB values. If it's 3-digit color code, first convert to 6-digit version. If any alpha value is provided alongside 6-digit hex, give rgba() string in return.
Use bitwise right-shift operator and mask bits with & (and) operator to convert a hexadecimal color code (with or without prefixed with #) to a string with the RGB values. If it's 3-digit color code, first convert to 6-digit version. If an alpha value is provided alongside 6-digit hex, give rgba() string in return.
const hexToRGB = hex => {
let alpha = false, h = hex.slice(hex.startsWith('#') ? 1 : 0);
if (h.length === 3) h = [...h].map(x => x + x).join('');
@@ -1322,7 +1322,7 @@ Omit the second argument to use the default regex.
// isSymbol(Symbol('x')) -> true
Converts the values of RGB components to a colorcode.
+Converts the values of RGB components to a color code.
Convert given RGB parameters to hexadecimal string using bitwise left-shift operator (<<) and toString(16), then padStart(6,'0') to get a 6-digit hexadecimal value.
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
// RGBToHex(255, 165, 1) -> 'ffa501'