Travis build: 1584
This commit is contained in:
28
README.md
28
README.md
@ -231,6 +231,7 @@ average(1, 2, 3);
|
||||
* [`chainAsync`](#chainasync)
|
||||
* [`compose`](#compose)
|
||||
* [`composeRight`](#composeright)
|
||||
* [`converge`](#converge)
|
||||
* [`curry`](#curry)
|
||||
* [`debounce`](#debounce)
|
||||
* [`defer`](#defer)
|
||||
@ -3766,6 +3767,33 @@ addAndSquare(1, 2); // 9
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### converge
|
||||
|
||||
Accepts a converging function and a list of branching functions and returns a function that applies each branching function to the arguments and the results of the branching functions are passed as arguments to the converging function.
|
||||
|
||||
Use `Array.map()` and `Function.apply()` to apply each function to the given arguments.
|
||||
Use the spread operator (`...`) to call `coverger` with the results of all other functions.
|
||||
|
||||
```js
|
||||
const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn.apply(null, args)));
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
const average = converge((a, b) => a / b, [
|
||||
arr => arr.reduce((a, v) => a + v, 0),
|
||||
arr => arr.length
|
||||
]);
|
||||
average([1, 2, 3, 4, 5, 6, 7]); // 4
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### curry
|
||||
|
||||
Curries a function.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -6,14 +6,13 @@ Use `Array.map()` and `Function.apply()` to apply each function to the given arg
|
||||
Use the spread operator (`...`) to call `coverger` with the results of all other functions.
|
||||
|
||||
```js
|
||||
const converge = (converger, fns) => (...args) =>
|
||||
converger(...fns.map(fn => fn.apply(null, args)));
|
||||
const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn.apply(null, args)));
|
||||
```
|
||||
|
||||
```js
|
||||
const average = converge((a, b) => a / b, [
|
||||
arr => arr.reduce((a, v) => a + v, 0),
|
||||
arr => arr.length,
|
||||
arr => arr.length
|
||||
]);
|
||||
average([1, 2, 3, 4, 5, 6, 7]); // 4
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user