[Feature] Add flip adapter

This commit is contained in:
Robert Mennell
2017-12-21 16:42:15 -08:00
parent 1c93c2d6b6
commit f616488615
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
*/
```