Travis build: 126
This commit is contained in:
46
README.md
46
README.md
@ -14,6 +14,7 @@
|
||||
## Table of Contents
|
||||
|
||||
### Adapter
|
||||
* [`promisify`](#promisify)
|
||||
* [`spreadOver`](#spreadover)
|
||||
|
||||
### Array
|
||||
@ -83,7 +84,6 @@
|
||||
* [`curry`](#curry)
|
||||
* [`functionName`](#functionname)
|
||||
* [`pipe`](#pipe)
|
||||
* [`promisify`](#promisify)
|
||||
* [`runPromisesInSeries`](#runpromisesinseries)
|
||||
* [`sleep`](#sleep)
|
||||
|
||||
@ -167,6 +167,28 @@
|
||||
|
||||
## Adapter
|
||||
|
||||
### 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.
|
||||
|
||||
*In Node 8+, you can use [`util.promisify`](https://nodejs.org/api/util.html#util_util_promisify_original)*
|
||||
|
||||
```js
|
||||
const promisify = func =>
|
||||
(...args) =>
|
||||
new Promise((resolve, reject) =>
|
||||
func(...args, (err, result) =>
|
||||
err ? reject(err) : resolve(result))
|
||||
);
|
||||
// const delay = promisify((d, cb) => setTimeout(cb, d))
|
||||
// delay(2000).then(() => console.log('Hi!')) -> Promise resolves after 2s
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
|
||||
### spreadOver
|
||||
|
||||
Takes a veriadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.
|
||||
@ -1135,28 +1157,6 @@ multiplyAndAdd5(5, 2) -> 15
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
|
||||
### 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.
|
||||
|
||||
*In Node 8+, you can use [`util.promisify`](https://nodejs.org/api/util.html#util_util_promisify_original)*
|
||||
|
||||
```js
|
||||
const promisify = func =>
|
||||
(...args) =>
|
||||
new Promise((resolve, reject) =>
|
||||
func(...args, (err, result) =>
|
||||
err ? reject(err) : resolve(result))
|
||||
);
|
||||
// const delay = promisify((d, cb) => setTimeout(cb, d))
|
||||
// delay(2000).then(() => console.log('Hi!')) -> Promise resolves after 2s
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
|
||||
### runPromisesInSeries
|
||||
|
||||
Runs an array of promises in series.
|
||||
|
||||
Reference in New Issue
Block a user