4.0.1 • Published 2 years ago

p-defer v4.0.1

Weekly downloads
7,259,698
License
MIT
Repository
github
Last release
2 years ago

p-defer

Create a deferred promise

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

Install

npm install p-defer

Usage

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.

API

pDefer()

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

Related

  • p-lazy - Create a lazy promise that defers execution until .then() or .catch() is called
  • More…
map-age-cleanerarchetype-librarykilli8n-react-native-fast-image@cashremit/cr-streamline-iconscsgo-demo-helper-tmp@l1nyanm1ng/react-picture-viewerpg-tubern-pdf-reader-offlinecogoportutilsreact-native-slider-kfunblock-block-save-variables@saaspe/components@pixiebrix/extension@everything-registry/sub-chunk-2396tana-google-cloud-pubsubtest-carosello-campustest-ipfs-examplewebchewufflewss-managerteapackage-tatespoorman297superset-plugin-chart-hello-world2techfox-icontechfox-react-feathertestnpm_lmnvue-compmentvite-live-preview@cybermega/flutter-resource-manager-rs@poscredit/plugin-chart-borisipfs-grpc-clientipfs-demoipfs-interopjs-parse-extipfsd-ctlit-handshakeit-batched-bytesit-pushableit-queueless-pushableit-rpcit-tarit-to-streamit-pairit-parallelidm-walleticfs-streamiex-sdkhip-web-speech-cognitive-serviceshexyun.helpershaywireguruwayguruway.jsinterface-ipfs-corelibp2p-websocketslibp2p-websockets-curltechlibp2p-websockets-curltechtestlibp2p-webrtc-starlibp2plibp2p-delegated-content-routinglibp2p-interfaces-compliance-testslibp2p-kad-dhtlibp2p-delegated-peer-routingmama-exportermatch-colorskuro-connector@waku-objects/adapter@wardpeet/gatsby-plugin-remote-file@wardpeet/gatsby-plugin-sharp-worker@wardpeet/gatsby-plugin-sqip-worker@wardpeet/gatsby-plugin-structured-logging-worker@web3-storage/multistream-select@web3-storage/public-bucket@web3-storage/access@web3-storage/blob-fetcher@unboundedsystems/listr@typestream/sdk@throttleup/gatsby@types/p-defer@udecode/plate-cloud@udooku/react-image-comparison-slider@turf-rs/turf@thewakingsands/xivdict@tracelabs/kad-dht@villagekit/plugin-smart-fasteners@viamedici-spc/configurator-react@viamedici-spc/configurator-ts@upacyxou/react-native-draggable-flatlist@vladmaraev/web-speech-cognitive-services-davi@yplabs-ltd/react-native-detector@zaplify/gcp-pubsub@zh0st/evm-chainsabstract-startableb2x-utilsasync-iterator-demuxerasync-iterator-muxerasync-iter-mapasync-iter-pipeasync-iter-event-readerasync-iter-fan-outasync-query-selectorarnavmq
4.0.1

2 years ago

4.0.0

5 years ago

3.0.0

6 years ago

2.1.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.0

9 years ago