Sweet combinators for promises/a+
Sweet combinators for promises/a+.
Even though it uses pinky under the covers, it should be interoperable with any library implementing the promises/a+ specification.
This library assumes an ES5 environment, but can be easily supported in ES3 platforms by the use of shims. Just include es5-shim :3
var pinky = require'pinky'var p = require'pinky-combinators'// Sequencing operationsppipeline read'user.json'JSONparseget'data'JSONstringifywrite'data.json'otherwise throw e// Or function-composition style f . gpcompose splitLines read'log.txt'then// Parallel computationspall read'a.txt' read'b.txt' read'c.txt'then console.logasjoin'\n'throw err// First come, first servedpany request''request''then saveToDatabasea throw err
Just grab it from NPM:
$ npm install pinky-combinators
A quick reference of the API can be built using Calliope:
$ npm install -g calliope $ calliope build
You can run all tests using Mocha:
$ npm test
MIT/X11. ie.: do whatever you want.