I hereby claim:
- I am sktt on github.
- I am jwknr (https://keybase.io/jwknr) on keybase.
- I have a public key whose fingerprint is 978C 6F9A 69CB CE2F 915D AD0A 5846 66DF 8F0E AAF4
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| /** | |
| * Promisify a node style async func. | |
| * | |
| * @param {function} f Function to with a node callback as its last argument. | |
| * @param [{object}] scope Scope to run `f` in, if necessary. | |
| * @return {Promise} | |
| * | |
| * @example ``` | |
| * const read = promisify(fs.readFile, fs); | |
| * read('./file') |
| module.exports = run | |
| // Run tasks in sequence or async can be done in a very expressive way using | |
| // Promise and a reducer | |
| function run(tasks) { | |
| return tasks.reduce( | |
| (acc, task) => acc.then(lastResult => { | |
| if (typeof task === 'function') { | |
| // A task is a function that takes a result from a previous task and returns | |
| // a promise executor function |