Comparing version 3.0.0 to 4.0.0
@@ -1,22 +0,20 @@ | ||
declare namespace pDefer { | ||
interface DeferredPromise<ValueType> { | ||
/** | ||
Resolves the promise with a value or the result of another promise. | ||
export interface DeferredPromise<ValueType> { | ||
/** | ||
The deferred promise. | ||
*/ | ||
promise: Promise<ValueType>; | ||
@param value - The value to resolve the promise with. | ||
*/ | ||
resolve(value?: ValueType | PromiseLike<ValueType>): void; | ||
/** | ||
Resolves the promise with a value or the result of another promise. | ||
/** | ||
Reject the promise with a provided reason or error. | ||
@param value - The value to resolve the promise with. | ||
*/ | ||
resolve(value?: ValueType | PromiseLike<ValueType>): void; | ||
@param reason - The reason or error to reject the promise with. | ||
*/ | ||
reject(reason?: unknown): void; | ||
/** | ||
Reject the promise with a provided reason or error. | ||
/** | ||
The deferred promise. | ||
*/ | ||
promise: Promise<ValueType>; | ||
} | ||
@param reason - The reason or error to reject the promise with. | ||
*/ | ||
reject(reason?: unknown): void; | ||
} | ||
@@ -29,18 +27,14 @@ | ||
``` | ||
import pDefer = require('p-defer'); | ||
import pDefer from 'p-defer'; | ||
function delay(ms) { | ||
function delay(milliseconds) { | ||
const deferred = pDefer(); | ||
setTimeout(deferred.resolve, ms, '🦄'); | ||
setTimeout(deferred.resolve, milliseconds, '🦄'); | ||
return deferred.promise; | ||
} | ||
(async () => { | ||
console.log(await delay(100)); | ||
//=> '🦄' | ||
})(); | ||
console.log(await delay(100)); | ||
//=> '🦄' | ||
``` | ||
*/ | ||
declare function pDefer<ValueType>(): pDefer.DeferredPromise<ValueType>; | ||
export = pDefer; | ||
export default function pDefer<ValueType>(): DeferredPromise<ValueType>; |
@@ -1,4 +0,2 @@ | ||
'use strict'; | ||
const pDefer = () => { | ||
export default function pDefer() { | ||
const deferred = {}; | ||
@@ -12,4 +10,2 @@ | ||
return deferred; | ||
}; | ||
module.exports = pDefer; | ||
} |
{ | ||
"name": "p-defer", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Create a deferred promise", | ||
"license": "MIT", | ||
"repository": "sindresorhus/p-defer", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=12" | ||
}, | ||
@@ -35,6 +38,6 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^2.0.0", | ||
"tsd": "^0.7.3", | ||
"xo": "^0.24.0" | ||
"ava": "^3.15.0", | ||
"tsd": "^0.14.0", | ||
"xo": "^0.38.2" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# p-defer [![Build Status](https://travis-ci.org/sindresorhus/p-defer.svg?branch=master)](https://travis-ci.org/sindresorhus/p-defer) | ||
# p-defer | ||
@@ -7,3 +7,2 @@ > Create a deferred promise | ||
## Install | ||
@@ -15,18 +14,15 @@ | ||
## Usage | ||
```js | ||
const pDefer = require('p-defer'); | ||
import pDefer from 'p-defer'; | ||
function delay(ms) { | ||
function delay(milliseconds) { | ||
const deferred = pDefer(); | ||
setTimeout(deferred.resolve, ms, '🦄'); | ||
setTimeout(deferred.resolve, milliseconds, '🦄'); | ||
return deferred.promise; | ||
} | ||
(async () => { | ||
console.log(await delay(100)); | ||
//=> '🦄' | ||
})(); | ||
console.log(await delay(100)); | ||
//=> '🦄' | ||
``` | ||
@@ -36,3 +32,2 @@ | ||
## API | ||
@@ -44,3 +39,2 @@ | ||
## Related | ||
@@ -50,1 +44,13 @@ | ||
- [More…](https://github.com/sindresorhus/promise-fun) | ||
--- | ||
<div align="center"> | ||
<b> | ||
<a href="https://tidelift.com/subscription/pkg/npm-p-defer?utm_source=npm-p-defer&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a> | ||
</b> | ||
<br> | ||
<sub> | ||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. | ||
</sub> | ||
</div> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4207
52
Yes
39