Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

a-defer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-defer

Create a deferred promise

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

a-defer

Create a deferred promise

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

Install

$ npm install a-defer

Usage

import aDefer from 'a-defer';

function delay(milliseconds) {
  const deferred = aDefer();
  setTimeout(deferred.resolve, milliseconds, '🦄');
  return deferred.promise;
  // or
  // return deferred;
}

console.log(await delay(100));
//=> '🦄'

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

API

aDefer()

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

  • p-lazy - Create a lazy promise that defers execution until .then() or .catch() is called
  • More…

Keywords

FAQs

Package last updated on 30 Jun 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc