Skip to content

Commit

Permalink
Require Node.js 8
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Mar 31, 2019
1 parent 72aae92 commit 05b0479
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -2,4 +2,3 @@ language: node_js
node_js:
- '10'
- '8'
- '6'
12 changes: 7 additions & 5 deletions index.js
Expand Up @@ -13,10 +13,11 @@ class CancelError extends Error {

class PCancelable {
static fn(userFn) {
return (...args) => {
return (...arguments_) => {
return new PCancelable((resolve, reject, onCancel) => {
args.push(onCancel);
userFn(...args).then(resolve, reject);
arguments_.push(onCancel);
// eslint-disable-next-line promise/prefer-await-to-then
userFn(...arguments_).then(resolve, reject);
});
};
}
Expand Down Expand Up @@ -51,8 +52,8 @@ class PCancelable {
Object.defineProperties(onCancel, {
shouldReject: {
get: () => this._rejectOnCancel,
set: bool => {
this._rejectOnCancel = bool;
set: boolean => {
this._rejectOnCancel = boolean;
}
}
});
Expand All @@ -62,6 +63,7 @@ class PCancelable {
}

then(onFulfilled, onRejected) {
// eslint-disable-next-line promise/prefer-await-to-then
return this._promise.then(onFulfilled, onRejected);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -10,7 +10,7 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd"
Expand Down
1 change: 1 addition & 0 deletions test.js
Expand Up @@ -3,6 +3,7 @@ import delay from 'delay';
import promiseFinally from 'promise.prototype.finally';
import PCancelable from '.';

// TODO: Remove this when targeting Node.js 10
promiseFinally.shim();

const fixture = Symbol('fixture');
Expand Down

0 comments on commit 05b0479

Please sign in to comment.