npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

pinkie-defer

1.0.0 • Public • Published

pinkie-defer Build Status

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

install

npm i pinkie-defer

Downloadsweekly downloads

3,322

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability