Travis build: 392

This commit is contained in:
Travis CI
2017-12-28 08:32:00 +00:00
parent 203edf9ba2
commit 6d8e78d688
5 changed files with 52 additions and 52 deletions

View File

@ -186,17 +186,17 @@ Given a key and a set of arguments, call them when given a context. Primarily us
Use a closure to call a stored key with stored arguments. Use a closure to call a stored key with stored arguments.
```js ```js
const call = (key, ...args) => context => context[key](...args); const call = (key, ...args) => context => context[key](...args);
``` ```
```js ```js
Promise.resolve([1, 2, 3]) Promise.resolve([1, 2, 3])
.then(call('map', x => 2 * x)) .then(call('map', x => 2 * x))
.then(console.log); //[ 2, 4, 6 ] .then(console.log); //[ 2, 4, 6 ]
const map = call.bind(null, 'map'); const map = call.bind(null, 'map');
Promise.resolve([1, 2, 3]) Promise.resolve([1, 2, 3])
.then(map(x => 2 * x)) .then(map(x => 2 * x))
.then(console.log); //[ 2, 4, 6 ] .then(console.log); //[ 2, 4, 6 ]
``` ```
[⬆ back to top](#table-of-contents) [⬆ back to top](#table-of-contents)
@ -208,15 +208,15 @@ 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. Given a function, return a closure that collects all inputs into an array-accepting function.
```js ```js
const collectInto = fn => (...args) => fn(args); const collectInto = fn => (...args) => fn(args);
``` ```
```js ```js
const Pall = collectInto(Promise.all.bind(Promise)); const Pall = collectInto(Promise.all.bind(Promise));
let p1 = Promise.resolve(1); let p1 = Promise.resolve(1);
let p2 = Promise.resolve(2); let p2 = Promise.resolve(2);
let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3)); let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
Pall(p1, p2, p3).then(console.log); Pall(p1, p2, p3).then(console.log);
``` ```
[⬆ back to top](#table-of-contents) [⬆ back to top](#table-of-contents)
@ -228,17 +228,17 @@ 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. Return a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest.
```js ```js
const flip = fn => (...args) => fn(args.pop(), ...args); const flip = fn => (...args) => fn(args.pop(), ...args);
``` ```
```js ```js
let a = { name: 'John Smith' }; let a = { name: 'John Smith' };
let b = {}; let b = {};
const mergeFrom = flip(Object.assign); const mergeFrom = flip(Object.assign);
let mergePerson = mergeFrom.bind(null, a); let mergePerson = mergeFrom.bind(null, a);
mergePerson(b); // == b mergePerson(b); // == b
b = {}; b = {};
Object.assign(b, a); // == b Object.assign(b, a); // == b
``` ```
[⬆ back to top](#table-of-contents) [⬆ back to top](#table-of-contents)
@ -293,13 +293,13 @@ Takes a variadic function and returns a closure that accepts an array of argumen
Use closures and the spread operator (`...`) to map the array of arguments 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 ```js
const spreadOver = fn => argsArr => fn(...argsArr); const spreadOver = fn => argsArr => fn(...argsArr);
``` ```
```js ```js
const arrayMax = spreadOver(Math.max); const arrayMax = spreadOver(Math.max);
arrayMax([1, 2, 3]); // 3 arrayMax([1, 2, 3]); // 3
arrayMax([1, 2, 4]); // 4 arrayMax([1, 2, 4]); // 4
``` ```
[⬆ back to top](#table-of-contents) [⬆ back to top](#table-of-contents)

View File

@ -5,15 +5,15 @@ Given a key and a set of arguments, call them when given a context. Primarily us
Use a closure to call a stored key with stored arguments. Use a closure to call a stored key with stored arguments.
```js ```js
const call = (key, ...args) => context => context[key](...args); const call = (key, ...args) => context => context[key](...args);
``` ```
```js ```js
Promise.resolve([1, 2, 3]) Promise.resolve([1, 2, 3])
.then(call('map', x => 2 * x)) .then(call('map', x => 2 * x))
.then(console.log); //[ 2, 4, 6 ] .then(console.log); //[ 2, 4, 6 ]
const map = call.bind(null, 'map'); const map = call.bind(null, 'map');
Promise.resolve([1, 2, 3]) Promise.resolve([1, 2, 3])
.then(map(x => 2 * x)) .then(map(x => 2 * x))
.then(console.log); //[ 2, 4, 6 ] .then(console.log); //[ 2, 4, 6 ]
``` ```

View File

@ -5,13 +5,13 @@ 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. Given a function, return a closure that collects all inputs into an array-accepting function.
```js ```js
const collectInto = fn => (...args) => fn(args); const collectInto = fn => (...args) => fn(args);
``` ```
```js ```js
const Pall = collectInto(Promise.all.bind(Promise)); const Pall = collectInto(Promise.all.bind(Promise));
let p1 = Promise.resolve(1); let p1 = Promise.resolve(1);
let p2 = Promise.resolve(2); let p2 = Promise.resolve(2);
let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3)); let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
Pall(p1, p2, p3).then(console.log); Pall(p1, p2, p3).then(console.log);
``` ```

View File

@ -5,15 +5,15 @@ 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. Return a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest.
```js ```js
const flip = fn => (...args) => fn(args.pop(), ...args); const flip = fn => (...args) => fn(args.pop(), ...args);
``` ```
```js ```js
let a = { name: 'John Smith' }; let a = { name: 'John Smith' };
let b = {}; let b = {};
const mergeFrom = flip(Object.assign); const mergeFrom = flip(Object.assign);
let mergePerson = mergeFrom.bind(null, a); let mergePerson = mergeFrom.bind(null, a);
mergePerson(b); // == b mergePerson(b); // == b
b = {}; b = {};
Object.assign(b, a); // == b Object.assign(b, a); // == b
``` ```

View File

@ -5,11 +5,11 @@ Takes a variadic function and returns a closure that accepts an array of argumen
Use closures and the spread operator (`...`) to map the array of arguments 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 ```js
const spreadOver = fn => argsArr => fn(...argsArr); const spreadOver = fn => argsArr => fn(...argsArr);
``` ```
```js ```js
const arrayMax = spreadOver(Math.max); const arrayMax = spreadOver(Math.max);
arrayMax([1, 2, 3]); // 3 arrayMax([1, 2, 3]); // 3
arrayMax([1, 2, 4]); // 4 arrayMax([1, 2, 4]); // 4
``` ```