Travis build: 1360
This commit is contained in:
27
README.md
27
README.md
@ -198,6 +198,7 @@ average(1, 2, 3);
|
||||
|
||||
* [`chainAsync`](#chainasync)
|
||||
* [`compose`](#compose)
|
||||
* [`composeRight`](#composeright)
|
||||
* [`curry`](#curry)
|
||||
* [`defer`](#defer)
|
||||
* [`functionName`](#functionname)
|
||||
@ -2845,6 +2846,32 @@ multiplyAndAdd5(5, 2); // 15
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### composeRight
|
||||
|
||||
Performs left-to-right function composition.
|
||||
|
||||
Use `Array.reduce()` to perform left-to-right function composition.
|
||||
The first (leftmost) function can accept one or more arguments; the remaining functions must be unary.
|
||||
|
||||
```js
|
||||
const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
const add = (x, y) => x + y;
|
||||
const square = x => x * x;
|
||||
const addAndSquare = composeRight(add, square);
|
||||
addAndSquare(1, 2); // 9
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### curry
|
||||
|
||||
Curries a function.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -10,7 +10,7 @@ const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))
|
||||
```
|
||||
|
||||
```js
|
||||
const add = (x,y) => x + y;
|
||||
const add = (x, y) => x + y;
|
||||
const square = x => x * x;
|
||||
const addAndSquare = composeRight(add, square);
|
||||
addAndSquare(1, 2); // 9
|
||||
|
||||
Reference in New Issue
Block a user