Require Node.js 8
This commit is contained in:
parent
21c1db5aa0
commit
71b64de6d6
|
@ -3,4 +3,3 @@ node_js:
|
|||
- '12'
|
||||
- '10'
|
||||
- '8'
|
||||
- '6'
|
||||
|
|
|
@ -21,34 +21,25 @@ declare namespace pDefer {
|
|||
}
|
||||
}
|
||||
|
||||
declare const pDefer: {
|
||||
/**
|
||||
Create a deferred promise.
|
||||
/**
|
||||
Create a deferred promise.
|
||||
|
||||
@example
|
||||
```
|
||||
import pDefer = require('p-defer');
|
||||
@example
|
||||
```
|
||||
import pDefer = require('p-defer');
|
||||
|
||||
function delay(ms) {
|
||||
const deferred = pDefer();
|
||||
setTimeout(deferred.resolve, ms, '🦄');
|
||||
return deferred.promise;
|
||||
}
|
||||
function delay(ms) {
|
||||
const deferred = pDefer();
|
||||
setTimeout(deferred.resolve, ms, '🦄');
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
(async () => {
|
||||
console.log(await delay(100));
|
||||
//=> '🦄'
|
||||
})();
|
||||
```
|
||||
*/
|
||||
<ValueType>(): pDefer.DeferredPromise<ValueType>;
|
||||
|
||||
// TODO: Remove this for the next major release, refactor the whole definition to:
|
||||
// declare function pDefer<ValueType>(): pDefer.DeferredPromise<
|
||||
// ValueType
|
||||
// >;
|
||||
// export = pDefer;
|
||||
default: typeof pDefer;
|
||||
};
|
||||
(async () => {
|
||||
console.log(await delay(100));
|
||||
//=> '🦄'
|
||||
})();
|
||||
```
|
||||
*/
|
||||
declare function pDefer<ValueType>(): pDefer.DeferredPromise<ValueType>;
|
||||
|
||||
export = pDefer;
|
||||
|
|
2
index.js
2
index.js
|
@ -12,5 +12,3 @@ const pDefer = () => {
|
|||
};
|
||||
|
||||
module.exports = pDefer;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = pDefer;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
|
@ -29,12 +29,11 @@
|
|||
"later",
|
||||
"async",
|
||||
"await",
|
||||
"promises",
|
||||
"bluebird"
|
||||
"promises"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^2.0.0",
|
||||
"tsd": "^0.7.2",
|
||||
"tsd": "^0.7.3",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,15 +36,10 @@ function delay(ms) {
|
|||
|
||||
### pDefer()
|
||||
|
||||
Returns an `Object` with a `promise` property and functions to `resolve()` and `reject()`.
|
||||
Returns an `object` with a `promise` property and functions to `resolve()` and `reject()`.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [p-lazy](https://github.com/sindresorhus/p-lazy) - Create a lazy promise that defers execution until `.then()` or `.catch()` is called
|
||||
- [More…](https://github.com/sindresorhus/promise-fun)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
|
|
Loading…
Reference in New Issue