Travis build: 1304
This commit is contained in:
@ -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.
|
||||
|
||||
```js
|
||||
const flip = fn => (first, ...rest) => fn(...rest, first);
|
||||
const flip = fn => (first, ...rest) => fn(...rest, first);
|
||||
```
|
||||
|
||||
```js
|
||||
let a = { name: 'John Smith' };
|
||||
let b = {};
|
||||
const mergeFrom = flip(Object.assign);
|
||||
let mergePerson = mergeFrom.bind(null, a);
|
||||
mergePerson(b); // == b
|
||||
b = {};
|
||||
Object.assign(b, a); // == b
|
||||
let a = { name: 'John Smith' };
|
||||
let b = {};
|
||||
const mergeFrom = flip(Object.assign);
|
||||
let mergePerson = mergeFrom.bind(null, a);
|
||||
mergePerson(b); // == b
|
||||
b = {};
|
||||
Object.assign(b, a); // == b
|
||||
```
|
||||
|
||||
@ -16,6 +16,6 @@ const get = (from, ...selectors) =>
|
||||
```
|
||||
|
||||
```js
|
||||
const obj = { selector: { to: { val: 'val to select' } }, target: [1, 2, {a: 'test'}] };
|
||||
const obj = { selector: { to: { val: 'val to select' } }, target: [1, 2, { a: 'test' }] };
|
||||
get(obj, 'selector.to.val', 'target[0]', 'target[2].a'); // ['val to select', 1, 'test']
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user