[Feature] Add flip adapter

This commit is contained in:
Robert Mennell
2017-12-21 16:42:15 -08:00
parent f525f2ee54
commit f19a79b863
2 changed files with 18 additions and 0 deletions

17
snippets/flip.md Normal file
View File

@ -0,0 +1,17 @@
### Flip
Flip recieves a function the make the first argument the last
Returning 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 => (...args) =>
fn( args.pop(), ...args )
/*
var a = {}
var b = {test:1}
const mergeInto = flip(Object.assign)
mergeInto(a, b) // == b
Object.assign(b,a) // == b
*/
```

View File

@ -124,3 +124,4 @@ without:array
words:string words:string
zip:array zip:array
zipObject:array zipObject:array
flip:adapter