From 05b0479db60c661e482c323e86bfc678c9b0bf3d Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 1 Apr 2019 02:59:24 +0700 Subject: [PATCH] Require Node.js 8 --- .travis.yml | 1 - index.js | 12 +++++++----- package.json | 2 +- test.js | 1 + 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2ae9d62..f3fa8cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,3 @@ language: node_js node_js: - '10' - '8' - - '6' diff --git a/index.js b/index.js index d58f83b..e34c10f 100644 --- a/index.js +++ b/index.js @@ -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); }); }; } @@ -51,8 +52,8 @@ class PCancelable { Object.defineProperties(onCancel, { shouldReject: { get: () => this._rejectOnCancel, - set: bool => { - this._rejectOnCancel = bool; + set: boolean => { + this._rejectOnCancel = boolean; } } }); @@ -62,6 +63,7 @@ class PCancelable { } then(onFulfilled, onRejected) { + // eslint-disable-next-line promise/prefer-await-to-then return this._promise.then(onFulfilled, onRejected); } diff --git a/package.json b/package.json index d629bd6..eada0e3 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "url": "sindresorhus.com" }, "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "test": "xo && ava && tsd" diff --git a/test.js b/test.js index c2a47cf..d7a25d6 100644 --- a/test.js +++ b/test.js @@ -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');