From 753ad05b879d6380a87de8844b096c6c8ed469ba Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 22 Dec 2017 18:22:00 +0000 Subject: [PATCH] Travis build: 145 --- README.md | 20 ++++++++++++++++++++ docs/index.html | 17 +++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e8db714ab..99ac7f01a 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ ## Table of Contents ### Adapter +* [`collectInto`](#collectinto) * [`promisify`](#promisify) * [`spreadOver`](#spreadover) @@ -167,6 +168,25 @@ ## Adapter +### 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) +*/ +``` + +[⬆ back to top](#table-of-contents) + ### promisify Converts an asynchronous function to return a promise. diff --git a/docs/index.html b/docs/index.html index c5dff3d07..dcfb4febc 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,8 @@

Adapter -

promisify +collectInto +promisify spreadOver

Array @@ -194,7 +195,19 @@

flip
 

Adapter

-

promisify

+

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.

+
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)
+*/
+
+

promisify

Converts an asynchronous function to return a promise.

Use currying to return a function returning a Promise that calls the original function. Use the ...rest operator to pass in all the parameters.