diff --git a/notNeededPackages.json b/notNeededPackages.json index 4289393363..82c50ddaab 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -1158,6 +1158,12 @@ "sourceRepoURL": "https://github.com/sindresorhus/p-pipe", "asOfVersion": "2.0.1" }, + { + "libraryName": "p-queue", + "typingsPackageName": "p-queue", + "sourceRepoURL": "https://github.com/sindresorhus/p-queue", + "asOfVersion": "3.2.0" + }, { "libraryName": "p-throttle", "typingsPackageName": "p-throttle", diff --git a/types/p-queue/index.d.ts b/types/p-queue/index.d.ts deleted file mode 100644 index 96fda8426a..0000000000 --- a/types/p-queue/index.d.ts +++ /dev/null @@ -1,160 +0,0 @@ -// Type definitions for p-queue 3.1 -// Project: https://github.com/sindresorhus/p-queue#readme -// Definitions by: BendingBender -// Evan Shortiss -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 - -/// - -import { EventEmitter } from 'events'; - -export = PQueue; - -/** - * Promise queue with concurrency control. - */ -declare class PQueue< - TEnqueueOptions extends PQueue.QueueAddOptions = PQueue.DefaultAddOptions -> extends EventEmitter { - /** - * Size of the queue. - */ - readonly size: number; - - /** - * Number of pending promises. - */ - readonly pending: number; - - /** - * Whether the queue is currently paused. - */ - readonly isPaused: boolean; - - constructor(opts?: PQueue.Options); - - /** - * Adds a sync or async task to the queue. Always returns a promise. - * @param fn Promise-returning/async function. - * @param opts - */ - add(fn: PQueue.Task, opts?: TEnqueueOptions): Promise; - - /** - * Same as `.add()`, but accepts an array of sync or async functions - * and returns a promise that resolves when all functions are resolved. - * @param fn Array of Promise-returning/async functions. - */ - addAll(fns: Array>, opts?: TEnqueueOptions): Promise; - - /** - * Returns a promise that settles when the queue becomes empty. - * - * Can be called multiple times. Useful if you for example add - * additional items at a later time. - */ - onEmpty(): Promise; - - /** - * Returns a promise that settles when the queue becomes empty, and all - * promises have completed; `queue.size === 0 && queue.pending === 0`. - * - * The difference with `.onEmpty` is that `.onIdle` guarantees that all work - * from the queue has finished. `.onEmpty` merely signals that the queue is - * empty, but it could mean that some promises haven't completed yet. - */ - onIdle(): Promise; - - /** - * Start (or resume) executing enqueued tasks within concurrency limit. - * No need to call this if queue is not paused - * (via `options.autoStart = false` or by `.pause()` method.) - */ - start(): void; - - /** - * Clear the queue. - */ - clear(): void; - - /** - * Put queue execution on hold. - */ - pause(): void; - - addListener(event: 'active', listener: () => void): this; - on(event: 'active', listener: () => void): this; - once(event: 'active', listener: () => void): this; - prependListener(event: 'active', listener: () => void): this; - prependOnceListener(event: 'active', listener: () => void): this; - removeListener(event: 'active', listener: () => void): this; - off(event: 'active', listener: () => void): this; - removeAllListeners(event?: 'active'): this; - listeners(event: 'active'): Array<() => void>; - rawListeners(event: 'active'): Array<() => void>; - emit(event: 'active'): boolean; - eventNames(): Array<'active'>; - listenerCount(type: 'active'): number; -} - -declare namespace PQueue { - interface QueueAddOptions { - [key: string]: any; - } - - interface QueueClassConstructor { - new (): QueueClass; - } - - interface QueueClass { - size: number; - - enqueue(run: () => void, options?: TEnqueueOptions): void; - - dequeue(): (() => void) | undefined; - } - - interface Options { - /** - * Concurrency limit. Minimum: `1`. - * @default Infinity - */ - concurrency?: number; - /** - * Whether queue tasks within concurrency limit, are auto-executed as soon as they're added. - * @default true - */ - autoStart?: boolean; - /** - * Class with a `enqueue` and `dequeue` method, and a `size` getter. See the - * [Custom QueueClass](https://github.com/sindresorhus/p-queue#custom-queueclass) section. - */ - queueClass?: QueueClassConstructor; - /** - * The max number of runs in the given interval of time. Minimum: `1`. - * @default Infinity - */ - intervalCap?: number; - /** - * The length of time in milliseconds before the interval count resets. Must be finite. Minimum: `0`. - * @default 0 - */ - interval?: number; - /** - * Whether the task must finish in the given interval or will be carried over into the next interval count. - * @default false - */ - carryoverConcurrencyCount?: boolean; - } - - interface DefaultAddOptions { - /** - * Priority of operation. Operations with greater priority will be scheduled first. - * @default 0 - */ - priority?: number; - } - - type Task = (() => PromiseLike) | (() => T); -} diff --git a/types/p-queue/p-queue-tests.ts b/types/p-queue/p-queue-tests.ts deleted file mode 100644 index 4ce6fbb13e..0000000000 --- a/types/p-queue/p-queue-tests.ts +++ /dev/null @@ -1,49 +0,0 @@ -import PQueue = require('p-queue'); - -const queue = new PQueue({ concurrency: 1 }); -new PQueue({ autoStart: false }); -new PQueue({ intervalCap: 1 }); -new PQueue({ interval: 0 }); -new PQueue({ carryoverConcurrencyCount: true }); - -queue.add(() => Promise.resolve('sindresorhus.com')); // $ExpectType Promise -queue.add(() => 'sindresorhus.com'); // $ExpectType Promise -queue.add(() => 'sindresorhus.com', { priority: 1 }); // $ExpectType Promise - -queue.addAll([() => Promise.resolve('oh'), () => 'hi']); // $ExpectType Promise -queue.addAll([() => Promise.resolve('oh'), () => 1]); // $ExpectType Promise<(string | number)[]> -queue.addAll([() => Promise.resolve('oh'), () => 'hi'], { priority: 1 }); // $ExpectType Promise - -queue.onEmpty(); // $ExpectType Promise -queue.onIdle(); // $ExpectType Promise -queue.start(); -queue.pause(); -queue.clear(); - -queue.size; // $ExpectType number -queue.size = 1; // $ExpectError -queue.pending; // $ExpectType number -queue.pending = 5; // $ExpectError -queue.isPaused; // $ExpectType boolean -queue.isPaused = true; // $ExpectError - -class QueueClass implements PQueue.QueueClass<{ any: string }> { - private readonly queue: Array<() => void>; - - size = 0; - - constructor() { - this.queue = []; - } - - enqueue(run: () => void, options: { any: string }) { - this.queue.push(run); - } - - dequeue() { - return this.queue.shift(); - } -} - -const queue2 = new PQueue({ queueClass: QueueClass }); -queue2.add(() => Promise.resolve(), { any: 'hi' }); diff --git a/types/p-queue/tsconfig.json b/types/p-queue/tsconfig.json deleted file mode 100644 index b3dd5e5314..0000000000 --- a/types/p-queue/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "p-queue-tests.ts" - ] -} \ No newline at end of file diff --git a/types/p-queue/tslint.json b/types/p-queue/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/p-queue/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } diff --git a/types/p-queue/v2/index.d.ts b/types/p-queue/v2/index.d.ts deleted file mode 100644 index 568de0ca1d..0000000000 --- a/types/p-queue/v2/index.d.ts +++ /dev/null @@ -1,103 +0,0 @@ -// Type definitions for p-queue 2.3 -// Project: https://github.com/sindresorhus/p-queue#readme -// Definitions by: BendingBender -// Evan Shortiss -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -export = PQueue; - -declare class PQueue { - /** - * Size of the queue. - */ - size: number; - - /** - * Number of pending promises. - */ - pending: number; - - /** - * Whether the queue is currently paused. - */ - isPaused: boolean; - - constructor(opts?: PQueue.Options); - - /** - * Returns the promise returned by calling fn. - * @param fn Promise-returning/async function. - */ - add(fn: PQueue.Task, opts?: O): Promise; - - /** - * Same as .add(), but accepts an array of async functions and - * returns a promise that resolves when all async functions are resolved. - * @param fn Array of Promise-returning/async functions. - */ - addAll(fns: Array>, opts?: O): Promise; - - /** - * Returns a promise that settles when the queue becomes empty. - * Can be called multiple times. Useful if you for example add - * additional items at a later time. - */ - onEmpty(): Promise; - - /** - * Returns a promise that settles when the queue becomes empty, and all - * promises have completed; queue.size === 0 && queue.pending === 0. - * The difference with .onEmpty is that .onIdle guarantees that all work - * from the queue has finished. .onEmpty merely signals that the queue is - * empty, but it could mean that some promises haven't completed yet. - */ - onIdle(): Promise; - - /** - * Start (or resume) executing enqueued tasks within concurrency limit. - * No need to call this if queue is not paused (via options.autoStart = false - * or by .pause() method.) - */ - start(): void; - - /** - * Clear the queue. - */ - clear(): void; - - /** - * Put queue execution on hold. - */ - pause(): void; -} - -declare namespace PQueue { - interface QueueAddOptions { - [key: string]: any; - } - - interface QueueClassConstructor { - new(): QueueClass; - } - - interface QueueClass { - size: number; - - enqueue(run: () => void, options?: O): void; - - dequeue(): (() => void) | undefined; - } - - interface Options { - concurrency?: number; - autoStart?: boolean; - queueClass?: QueueClassConstructor; - } - - interface DefaultAddOptions { - priority?: number; - } - - type Task = () => Promise; -} diff --git a/types/p-queue/v2/p-queue-tests.ts b/types/p-queue/v2/p-queue-tests.ts deleted file mode 100644 index fcd48c852d..0000000000 --- a/types/p-queue/v2/p-queue-tests.ts +++ /dev/null @@ -1,51 +0,0 @@ -import PQueue = require("p-queue"); - -const queue = new PQueue({ concurrency: 1 }); - -queue - .add(() => Promise.resolve("sindresorhus.com")) - .then(sindre => { - const str: string = sindre; - }); - -queue.addAll([() => Promise.resolve("oh"), () => Promise.resolve("hi")]).then(r => { - r.indexOf("h"); -}); - -Promise.resolve((): Promise => Promise.resolve("unicorn")) - .then(task => queue.add(task, { priority: 5 })) - .then(unicorn => { - const str: string = unicorn; - }); - -queue.onEmpty().then(() => {}); -queue.onIdle().then(() => {}); -queue.start(); -queue.pause(); -queue.clear(); - -let num: number; -num = queue.size; -num = queue.pending; -const paused = queue.isPaused; - -class QueueClass implements PQueue.QueueClass<{ any: string }> { - private readonly queue: Array<() => void>; - - size = 0; - - constructor() { - this.queue = []; - } - - enqueue(run: () => void, options: { any: string }) { - this.queue.push(run); - } - - dequeue() { - return this.queue.shift(); - } -} - -const queue2 = new PQueue({ queueClass: QueueClass }); -queue2.add(() => Promise.resolve(), { any: "hi" }); diff --git a/types/p-queue/v2/tsconfig.json b/types/p-queue/v2/tsconfig.json deleted file mode 100644 index 49d979aa06..0000000000 --- a/types/p-queue/v2/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../../", - "typeRoots": [ - "../../" - ], - "paths": { - "p-queue": [ "p-queue/v2" ] - }, - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "p-queue-tests.ts" - ] -} diff --git a/types/p-queue/v2/tslint.json b/types/p-queue/v2/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/p-queue/v2/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" }