From 8c59d59a9e585b501fe5706abc6e26e0bf4151ef Mon Sep 17 00:00:00 2001 From: Robert Mennell Date: Thu, 21 Dec 2017 19:08:36 -0800 Subject: [PATCH 1/3] [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 From a5b4e3a752d1a36fabb971129a44ce653bcdd9dd Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Fri, 22 Dec 2017 09:44:59 +0200 Subject: [PATCH 2/3] Minor formatting --- snippets/collectInto.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/snippets/collectInto.md b/snippets/collectInto.md index 468e2af80..8f9b34cd4 100644 --- a/snippets/collectInto.md +++ b/snippets/collectInto.md @@ -1,11 +1,11 @@ -### Colect Into +### collectInto -Changes a function that accepts an array into a variadic function +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 +Given a function, return a closure that collects all inputs into an array-accepting function. ```js -const collectInto = fn => ( ...args ) => fn( args ) +const collectInto = fn => ( ...args ) => fn( args ); /* const Pall = collectInto( Promise.all.bind(Promise) ) var p1 = Promise.resolve(1) @@ -13,4 +13,4 @@ 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 +``` From aac191c3c2e8ab17a0c2fac912a26ae70c82986e Mon Sep 17 00:00:00 2001 From: Robert Mennell Date: Fri, 22 Dec 2017 10:00:02 -0800 Subject: [PATCH 3/3] Update collectInto.md --- snippets/collectInto.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/collectInto.md b/snippets/collectInto.md index 8f9b34cd4..eb0e4df6c 100644 --- a/snippets/collectInto.md +++ b/snippets/collectInto.md @@ -8,9 +8,9 @@ Given a function, return a closure that collects all inputs into an array-accept 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)) +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) */ ```