Export either the native Promise or Bluebird (using native-or-bluebird) as deferred object.
Install
$ npm install native-or-another
$ npm test
Usage
For more use-cases see the tests
var assert = require('assert');
var Deferred = require('native-or-another');
var defer = new Deferred();
defer.resolve(1);
defer.promise.then(function fulfilled(val) {
assert.strictEqual(val, 1);
done();
});
defer.reject(new Error('custom error'));
defer.promise.catch(function rejected(err) {
assert.ok(err instanceof Error);
assert.strictEqual(err.message, 'custom error');
done();
});
Author
Charlike Mike Reagent
License
Copyright (c) 2014 Charlike Mike Reagent, contributors.
Released under the MIT
license.
Powered and automated by readdirp + hogan.js, December 21, 2014