4.0.1 • Published 1 year ago

p-defer v4.0.1

Weekly downloads
7,259,698
License
MIT
Repository
github
Last release
1 year 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@dot/log@dplusic/gamelift-nodejs-serversdk@crypto-sdk/core@ct-note/table@ct-note/warning@ct-note/image@ct-note/inline-code@ct-note/list@ct-note/marker@ct-note/paragraph@ct-note/quote@ct-note/simple-image@ct-note/code@ct-note/delimiter@ct-note/embed@ct-note/header@comapeo/core@comapeo/ipc@cybermega/flutter-resource-manager-rs@contentpass/pubsub@daiki48/keisan@canvas-js/core@poscredit/plugin-chart-boris@rbc-public/react-selectable-fastipfs-grpc-clientipfs-demoipfs-interopjs-parse-extipfsd-ctlit-handshakeit-batched-bytesit-pushableit-queueless-pushableit-rpcit-tarit-to-streamit-pairit-parallelstream-to-iteratorssb-suggest-litessb-db2ssb-db2-box2ssb-db2-norsssb-meta-feedsssb-fixturesthunk-to-async-generatorts-checker-webpack-plugintwine-libtwine-library@ascorbic/gatsby@arielapaula/components@arielapaula/test@adpt/cli@adpt/core@adpt/testutils@adpt/utils@akiyamka/web-container@alola-react/plugin-devtools@batbayar/superset-plugin-chart-hello-world@bee-icons/qwik@carhoo/widget-dealers@bringg/dashboard-sdk@chi_eee/another-test-package@clickup/distributed-locker@clickup/ent-framework@achingbrain/nat-port-mapper@7hci/gatsby-pge@_pearofducks/webpack-plugin-serve@bonsaiswapv3/deploy@dfdao/network@dfares/network@df0/network@darkforest_eth/network
4.0.1

1 year ago

4.0.0

4 years ago

3.0.0

6 years ago

2.1.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.0

9 years ago