pinkie-defer
v1.0.0
Published
Defer an ES2015 Promise implementation
Downloads
69,461
Maintainers
Readme
pinkie-defer
Defer an ES2015 Promise implementation
Install
$ npm install --save pinkie-defer
Usage
const defer = require('pinkie-defer');
const delay = ms => {
var deferred = defer();
setTimeout(() => {
deferred.resolve();
}, ms);
return new Promise(deferred);
};
delay(2000).then(() => {
//=> 2 seconds later...
});
API
defer()
Returns an object with resolved
and reject
methods that can be injected in the Promise
constructor.
License
MIT © Sam Verschueren