Travis build: 1360

This commit is contained in:
30secondsofcode
2018-01-23 20:14:21 +00:00
parent 920841ae16
commit c4a78512b2
3 changed files with 34 additions and 2 deletions

View File

@ -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

View File

@ -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