From 5178328002bffb97633c90d1e4daaf8e394aef6a Mon Sep 17 00:00:00 2001 From: Robert Mennell Date: Thu, 21 Dec 2017 19:08:36 -0800 Subject: [PATCH] [FEATURE] add collectInto snippet --- snippets/collectInto.md | 16 ++++++++++++++++ tag_database | 1 + 2 files changed, 17 insertions(+) create mode 100644 snippets/collectInto.md diff --git a/snippets/collectInto.md b/snippets/collectInto.md new file mode 100644 index 000000000..468e2af80 --- /dev/null +++ b/snippets/collectInto.md @@ -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) +*/ +``` \ No newline at end of file diff --git a/tag_database b/tag_database index 78da7daaf..b361fe7cd 100644 --- a/tag_database +++ b/tag_database @@ -16,6 +16,7 @@ cleanObj:object coalesce:utility coalesceFactory:utility collatz:math +collectInto:adapter compact:array compose:function countOccurrences:array