[FEATURE] add collectInto snippet

This commit is contained in:
Robert Mennell
2017-12-21 19:08:36 -08:00
parent 1c93c2d6b6
commit 5178328002
2 changed files with 17 additions and 0 deletions

16
snippets/collectInto.md Normal file
View File

@ -0,0 +1,16 @@
### Colect Into
Changes a function that accepts an array into a variadic function
Given a funciton, return a closure that collects all inputs into an array accepting function
```js
const collectInto = fn => ( ...args ) => fn( args )
/*
const Pall = collectInto( Promise.all.bind(Promise) )
var p1 = Promise.resolve(1)
var p2 = Promise.resolve(2)
var p3 = new Promise((resolve) => setTimeout(resolve,2000,3))
Pall(p1, p2, p3).then(console.log)
*/
```

View File

@ -16,6 +16,7 @@ cleanObj:object
coalesce:utility
coalesceFactory:utility
collatz:math
collectInto:adapter
compact:array
compose:function
countOccurrences:array