diff --git a/README.md b/README.md index 94613e8c3..8ce0393a2 100644 --- a/README.md +++ b/README.md @@ -503,16 +503,16 @@ const firstTwoMax = ary(Math.max, 2);
[⬆ Back to top](#table-of-contents) -### 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. - +### 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. + ```js const call = (key, ...args) => context => context[key](...args); -``` - +``` +
Examples @@ -524,23 +524,23 @@ const map = call.bind(null, 'map'); Promise.resolve([1, 2, 3]) .then(map(x => 2 * x)) .then(console.log); //[ 2, 4, 6 ] -``` +```

[⬆ Back to top](#table-of-contents) -### collectInto - -Changes a function that accepts an array into a variadic function. - -Given a function, return a closure that collects all inputs into an array-accepting function. - +### collectInto + +Changes a function that accepts an array into a variadic function. + +Given a function, return a closure that collects all inputs into an array-accepting function. + ```js const collectInto = fn => (...args) => fn(args); -``` - +``` +
Examples @@ -550,23 +550,23 @@ let p1 = Promise.resolve(1); let p2 = Promise.resolve(2); let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3)); Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds) -``` +```

[⬆ Back to top](#table-of-contents) -### flip - -Flip takes a function as an argument, then makes the first argument the last. - -Return a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest. - +### flip + +Flip takes a function as an argument, then makes the first argument the last. + +Return a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest. + ```js const flip = fn => (first, ...rest) => fn(...rest, first); -``` - +``` +
Examples @@ -578,7 +578,7 @@ let mergePerson = mergeFrom.bind(null, a); mergePerson(b); // == b b = {}; Object.assign(b, a); // == b -``` +```
@@ -754,23 +754,23 @@ rearged('b', 'c', 'a'); // ['a', 'b', 'c']
[⬆ Back to top](#table-of-contents) -### spreadOver - -Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. - -Use closures and the spread operator (`...`) to map the array of arguments to the inputs of the function. - +### spreadOver + +Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. + +Use closures and the spread operator (`...`) to map the array of arguments to the inputs of the function. + ```js const spreadOver = fn => argsArr => fn(...argsArr); -``` - +``` +
Examples ```js const arrayMax = spreadOver(Math.max); arrayMax([1, 2, 3]); // 3 -``` +```
@@ -6694,7 +6694,7 @@ const matchesWith = (obj, source, fn) => key => obj.hasOwnProperty(key) && fn ? fn(obj[key], source[key], key, obj, source) - : obj[key] === source[key] + : obj[key] == source[key] ); ``` diff --git a/docs/object.html b/docs/object.html index 801f6a078..495957bef 100644 --- a/docs/object.html +++ b/docs/object.html @@ -327,7 +327,7 @@ Foo.prototype// { '1': ['a', 'c'], '2': ['b'] }

truthCheckCollection

Checks if the predicate (second argument) is truthy on all elements of a collection (first argument).

Use Array.every() to check if each passed object has the specified property and if it returns a truthy value.

const truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]);
 
truthCheckCollection([{ user: 'Tinky-Winky', sex: 'male' }, { user: 'Dipsy', sex: 'male' }], 'sex'); // true
-

unflattenObjectadvanced

Unlatten an object with the paths for keys.

Use Object.keys(obj) combined with Array.reduce() to convert flattened path node to a leaf node. If the value of a key contains a dot delimiter (.), use Array.split('.'), string transformations and JSON.parse() to create an object, then Object.assign() to create the leaf node. Otherwise, add the appropriate key-value pair to the accumulator object.

const unflattenObject = obj =>
+

unflattenObjectadvanced

Unflatten an object with the paths for keys.

Use Object.keys(obj) combined with Array.reduce() to convert flattened path node to a leaf node. If the value of a key contains a dot delimiter (.), use Array.split('.'), string transformations and JSON.parse() to create an object, then Object.assign() to create the leaf node. Otherwise, add the appropriate key-value pair to the accumulator object.

const unflattenObject = obj =>
   Object.keys(obj).reduce((acc, k) => {
     if (k.indexOf('.') !== -1) {
       const keys = k.split('.');