pinkyPromise
is an ultra-bare-bones promises library intended to provide insight into the inner workings of JavaScript promises. It is not spec-compliant or meant for production use.
The original blog post: pinkyPromise: JavaScript Promises in 45 Lines of Code.
// take an async function
function incrementAsync(n, cb) {
setTimeout(function() {
cb(n + 1);
}, 100);
}
// pinkyPromise it!
var incrementAsyncPromise = pinkyPromise(incrementAsync);
var data = 1;
incrementAsyncPromise(data)
.then(incrementAsyncPromise)
.then(incrementAsyncPromise)
.then(function(n) {
console.log(n) // => 4
});