From 9e94070eb740bce808bff7669c3fb87b0634aae1 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sat, 2 Jan 2021 15:40:54 +0700 Subject: [PATCH] Require Node.js 10 --- bench.ts | 2 +- package.json | 20 ++++++++++---------- source/index.ts | 13 ++++++++----- source/lower-bound.ts | 2 +- source/options.ts | 4 +--- test/test.ts | 17 ++++++++--------- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/bench.ts b/bench.ts index c2d6de8..0d47ddd 100644 --- a/bench.ts +++ b/bench.ts @@ -32,7 +32,7 @@ suite for (let i = 0; i < 100; i++) { // eslint-disable-next-line @typescript-eslint/no-empty-function queue.add(async () => {}, { - priority: (Math.random() * 100) | 0 + priority: Math.trunc(Math.random() * 100) }); } diff --git a/package.json b/package.json index 735beae..2745536 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "funding": "https://github.com/sponsors/sindresorhus", "main": "dist/index.js", "engines": { - "node": ">=8" + "node": ">=10" }, "scripts": { "build": "del dist && tsc", @@ -42,25 +42,25 @@ "bluebird" ], "dependencies": { - "eventemitter3": "^4.0.4", - "p-timeout": "^3.2.0" + "eventemitter3": "^4.0.7", + "p-timeout": "^4.1.0" }, "devDependencies": { "@sindresorhus/tsconfig": "^0.7.0", - "@types/benchmark": "^1.0.33", - "@types/node": "^14.6.0", - "ava": "^2.0.0", + "@types/benchmark": "^2.1.0", + "@types/node": "^14.14.19", + "ava": "^2.4.0", "benchmark": "^2.1.4", - "codecov": "^3.7.2", + "codecov": "^3.8.1", "del-cli": "^3.0.1", "delay": "^4.4.0", "in-range": "^2.0.0", "nyc": "^15.1.0", "random-int": "^2.0.1", "time-span": "^4.0.0", - "ts-node": "^9.0.0", - "typescript": "^4.0.2", - "xo": "^0.33.0" + "ts-node": "^9.1.1", + "typescript": "^4.1.3", + "xo": "^0.37.1" }, "ava": { "babel": false, diff --git a/source/index.ts b/source/index.ts index 0273b9b..a010a09 100644 --- a/source/index.ts +++ b/source/index.ts @@ -60,9 +60,9 @@ export default class PQueue>): number { - // eslint-disable-next-line unicorn/no-fn-reference-in-iterator + // eslint-disable-next-line unicorn/no-array-callback-reference return this._queue.filter(options).length; } diff --git a/source/lower-bound.ts b/source/lower-bound.ts index 5412c2c..2100d67 100644 --- a/source/lower-bound.ts +++ b/source/lower-bound.ts @@ -5,7 +5,7 @@ export default function lowerBound(array: readonly T[], value: T, comparator: let count = array.length; while (count > 0) { - const step = (count / 2) | 0; + const step = Math.trunc(count / 2); let it = first + step; if (comparator(array[it], value) <= 0) { diff --git a/source/options.ts b/source/options.ts index e153bb5..4a134d7 100644 --- a/source/options.ts +++ b/source/options.ts @@ -1,8 +1,6 @@ import {Queue, RunFunction} from './queue'; -export interface QueueAddOptions { - readonly [key: string]: unknown; -} +export type QueueAddOptions = Readonly>; export interface Options, QueueOptions extends QueueAddOptions> { /** diff --git a/test/test.ts b/test/test.ts index 81d4bb3..eeba6a2 100644 --- a/test/test.ts +++ b/test/test.ts @@ -47,7 +47,7 @@ test('.add() - concurrency: 1', async t => { return value; }); - // eslint-disable-next-line unicorn/no-fn-reference-in-iterator + // eslint-disable-next-line unicorn/no-array-callback-reference t.deepEqual(await Promise.all(input.map(mapper)), [10, 20, 30]); t.true(inRange(end(), {start: 590, end: 650})); }); @@ -227,12 +227,11 @@ test('.onIdle()', async t => { test('.onIdle() - no pending', async t => { const queue = new PQueue(); - t.is(queue.size, 0); t.is(queue.pending, 0); - const promise = await queue.onIdle(); - t.is(promise, undefined); + // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression + t.is(await queue.onIdle(), undefined); }); test('.clear()', t => { @@ -283,7 +282,7 @@ test('enforce number in options.concurrency', t => { }); t.notThrows(() => { - new PQueue({concurrency: Infinity}); + new PQueue({concurrency: Number.POSITIVE_INFINITY}); }); }); @@ -312,7 +311,7 @@ test('enforce number in queue.concurrency', t => { }); t.notThrows(() => { - (new PQueue()).concurrency = Infinity; + (new PQueue()).concurrency = Number.POSITIVE_INFINITY; }); }); @@ -340,7 +339,7 @@ test('enforce number in options.intervalCap', t => { }); t.notThrows(() => { - new PQueue({intervalCap: Infinity}); + new PQueue({intervalCap: Number.POSITIVE_INFINITY}); }); }); @@ -360,7 +359,7 @@ test('enforce finite in options.interval', t => { ); t.throws(() => { - new PQueue({interval: Infinity}); + new PQueue({interval: Number.POSITIVE_INFINITY}); }); t.notThrows(() => { @@ -372,7 +371,7 @@ test('enforce finite in options.interval', t => { }); t.throws(() => { - new PQueue({interval: Infinity}); + new PQueue({interval: Number.POSITIVE_INFINITY}); }); });