p-defer

WebJar for p-defer

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

p-defer
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

p-defer
WebJar for p-defer
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/sindresorhus/p-defer

Download p-defer

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/p-defer/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>p-defer</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/p-defer/
implementation 'org.webjars.npm:p-defer:1.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/p-defer/
implementation ("org.webjars.npm:p-defer:1.0.0")
'org.webjars.npm:p-defer:jar:1.0.0'
<dependency org="org.webjars.npm" name="p-defer" rev="1.0.0">
  <artifact name="p-defer" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='p-defer', version='1.0.0')
)
libraryDependencies += "org.webjars.npm" % "p-defer" % "1.0.0"
[org.webjars.npm/p-defer "1.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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

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

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

(async () => {
	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…

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Versions

Version
1.0.0