compose-promise
Function composition that works with functions that return promises.
Synopsis
'use strict'; var compose = var Promise = { return n + 1 } { return n * 2 } { return Promise } { return Promise }
Now we'll compose every combination of sync/async to create an array of functions:
var functions =
Every one of the above functions is equivalent:
- they all multiply the input by 2 and then add 1
- they all return a
Promise
... but let's verify it to be sure:
var assert = console; functions /* Output: * * ok 1 result was correct * ok 2 result was correct * ok 3 result was correct * ok 4 result was correct */
Cool! everything works.
License
MIT