Require Node.js 8

This commit is contained in:
Sindre Sorhus 2019-06-07 15:08:42 +07:00
parent 21c1db5aa0
commit 71b64de6d6
5 changed files with 21 additions and 39 deletions

View File

@ -3,4 +3,3 @@ node_js:
- '12' - '12'
- '10' - '10'
- '8' - '8'
- '6'

43
index.d.ts vendored
View File

@ -21,34 +21,25 @@ declare namespace pDefer {
} }
} }
declare const pDefer: { /**
/** Create a deferred promise.
Create a deferred promise.
@example @example
``` ```
import pDefer = require('p-defer'); import pDefer = require('p-defer');
function delay(ms) { function delay(ms) {
const deferred = pDefer(); const deferred = pDefer();
setTimeout(deferred.resolve, ms, '🦄'); setTimeout(deferred.resolve, ms, '🦄');
return deferred.promise; return deferred.promise;
} }
(async () => { (async () => {
console.log(await delay(100)); console.log(await delay(100));
//=> '🦄' //=> '🦄'
})(); })();
``` ```
*/ */
<ValueType>(): pDefer.DeferredPromise<ValueType>; declare function pDefer<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;
};
export = pDefer; export = pDefer;

View File

@ -12,5 +12,3 @@ const pDefer = () => {
}; };
module.exports = pDefer; module.exports = pDefer;
// TODO: Remove this for the next major release
module.exports.default = pDefer;

View File

@ -10,7 +10,7 @@
"url": "sindresorhus.com" "url": "sindresorhus.com"
}, },
"engines": { "engines": {
"node": ">=6" "node": ">=8"
}, },
"scripts": { "scripts": {
"test": "xo && ava && tsd" "test": "xo && ava && tsd"
@ -29,12 +29,11 @@
"later", "later",
"async", "async",
"await", "await",
"promises", "promises"
"bluebird"
], ],
"devDependencies": { "devDependencies": {
"ava": "^2.0.0", "ava": "^2.0.0",
"tsd": "^0.7.2", "tsd": "^0.7.3",
"xo": "^0.24.0" "xo": "^0.24.0"
} }
} }

View File

@ -36,15 +36,10 @@ function delay(ms) {
### pDefer() ### 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 ## Related
- [p-lazy](https://github.com/sindresorhus/p-lazy) - Create a lazy promise that defers execution until `.then()` or `.catch()` is called - [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) - [More…](https://github.com/sindresorhus/promise-fun)
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)