
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
Create a deferred promise
Don't use this unless you know what you're doing. Prefer the Promise constructor.
npm install p-defer
import pDefer from 'p-defer';
function delay(milliseconds) {
const deferred = pDefer();
setTimeout(deferred.resolve, milliseconds, '🦄');
return deferred.promise;
}
console.log(await delay(100));
//=> '🦄'
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().
The 'deferred' package provides similar functionality to p-defer by allowing you to create deferred promises. It also exposes the resolve and reject methods, but it includes additional features like progress notifications and chaining. It is more feature-rich compared to p-defer.
The 'promise-defer' package is another alternative that provides deferred promises. It is lightweight and straightforward, similar to p-defer, but it does not include any additional features beyond basic deferred promise functionality.
The 'bluebird' package is a fully-featured promise library that includes deferred promises among many other advanced features like cancellation, progress, and concurrency control. It is more comprehensive and powerful compared to p-defer, but also more complex.
FAQs
Create a deferred promise
The npm package p-defer receives a total of 8,373,961 weekly downloads. As such, p-defer popularity was classified as popular.
We found that p-defer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.