Meta tweaks

This commit is contained in:
Sindre Sorhus 2019-03-17 19:24:05 +07:00
parent 3510168005
commit 1eff146400
3 changed files with 8 additions and 10 deletions

4
index.d.ts vendored
View File

@ -22,6 +22,4 @@ export interface DeferredPromise<ValueType> {
/**
Create a deferred promise.
*/
export default function pDefer<ValueType = unknown>(): DeferredPromise<
ValueType
>;
export default function pDefer<ValueType = unknown>(): DeferredPromise<ValueType>;

View File

@ -1,14 +1,14 @@
'use strict';
const pDefer = () => {
const ret = {};
const deferred = {};
ret.promise = new Promise((resolve, reject) => {
ret.resolve = resolve;
ret.reject = reject;
deferred.promise = new Promise((resolve, reject) => {
deferred.resolve = resolve;
deferred.reject = reject;
});
return ret;
return deferred;
};
module.exports = pDefer;

View File

@ -2,13 +2,13 @@
> Create a deferred promise
[**Don't use this unless you know what you're doing!**](https://github.com/petkaantonov/bluebird/wiki/Promise-anti-patterns#the-deferred-anti-pattern) Prefer the `Promise` constructor.
[Don't use this unless you know what you're doing.](https://github.com/petkaantonov/bluebird/wiki/Promise-anti-patterns#the-deferred-anti-pattern) Prefer the `Promise` constructor.
## Install
```
$ npm install --save p-defer
$ npm install p-defer
```