"Fossies" - the Fresh Open Source Software Archive

Member "node-v12.18.4-win-x64/node_modules/npm/node_modules/p-defer/readme.md" (18 Feb 2020, 1035 Bytes) of package /windows/www/node-v12.18.4-win-x64.zip:

As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

p-defer Build Status

Create a deferred promise

Don’t use this unless you know what you’re doing! Prefer the Promise constructor.


$ npm install --save p-defer


const pDefer = require('p-defer');

function delay(ms) {
    const deferred = pDefer();
    setTimeout(deferred.resolve, ms, '🦄');
    return deferred.promise;

//=> '🦄'

The above is just an example. Use delay if you need to delay a promise.



Returns an Object with a promise property and functions to resolve() and reject().


MIT © Sindre Sorhus