Sweetly small promises/a+ implementation.
Should work fine in ES3.
var pinky =var eventual =var eventual2 = eventualeventualeventual2// => ok: 11
Just grab it from NPM:
$ npm install pinky
Tests only run on Node right now, so just:
$ npm test
The promises/a+ specification requires things to be asynchronous. To do that,
process.nextTick in Node.js, and
setImmediate in a DOM
setImmediate is a Microsoft thing, and it's unlikely to
be implemented anywhere else, and in that case we fall back to the slow
setTimeout. Thus, providing a fallback for
setImmediate might speed things
up a bit.
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.
Most promise implementations I've seen plainly do way too much. OTOH Minimal promise implementations (like PinkySwear) provide a terrible API, which really sucks.
So, I wrote Pinky to be a minimal and fast baseline for extensions to promises/a+. Some implementation ideas are taken straight out from avow, btw, but I might revisit this in the future and try to optimise things.