Merge pull request #308 from skatcat31/feature/adapters/collectInto
[FEATURE] add collectInto snippet
This commit is contained in:
16
snippets/collectInto.md
Normal file
16
snippets/collectInto.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
### collectInto
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const collectInto = fn => ( ...args ) => fn( args );
|
||||||
|
/*
|
||||||
|
const Pall = collectInto( Promise.all.bind(Promise) )
|
||||||
|
let p1 = Promise.resolve(1)
|
||||||
|
let p2 = Promise.resolve(2)
|
||||||
|
let p3 = new Promise((resolve) => setTimeout(resolve,2000,3))
|
||||||
|
Pall(p1, p2, p3).then(console.log)
|
||||||
|
*/
|
||||||
|
```
|
||||||
@ -16,6 +16,7 @@ cleanObj:object
|
|||||||
coalesce:utility
|
coalesce:utility
|
||||||
coalesceFactory:utility
|
coalesceFactory:utility
|
||||||
collatz:math
|
collatz:math
|
||||||
|
collectInto:adapter
|
||||||
compact:array
|
compact:array
|
||||||
compose:function
|
compose:function
|
||||||
countOccurrences:array
|
countOccurrences:array
|
||||||
|
|||||||
Reference in New Issue
Block a user