API extentions for p0 A+ promises
Install it with NPM or add it to your package.json:
npm install pzero
Then:
var pzero = require('pzero');
<script src="pzero.js"></script>
var promise1 = pzero();
var promise2 = pzero();
pzero
.when([promise1, promise2])
.then(
function(values) {
var value1 = values[0];
var value2 = values[1];
},
function(reason) {}
);
promise1
.fail(function(reason) {});
promise1.callback(function(reason, value) {});
var cb = promise1.callback();
// reject promise -> cb(reason);
// fulfill promise -> cb(null, value);