From b8a56bd21b51119971704f6d9f99cd9129679dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Wed, 22 Jan 2020 01:22:54 +0100 Subject: [PATCH] fix(async): correct 'drain' method defs. Closes #41648 (#41665) http://caolan.github.io/async/v3/docs.html#cargo http://caolan.github.io/async/v3/docs.html#QueueObject Thanks! --- types/async/index.d.ts | 7 ++++++- types/async/test/index.ts | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/types/async/index.d.ts b/types/async/index.d.ts index 54585ddc28..8d7031bff1 100644 --- a/types/async/index.d.ts +++ b/types/async/index.d.ts @@ -106,7 +106,12 @@ export interface AsyncCargo { push(task: any, callback?: Function): void; saturated(): void; empty(): void; - drain(): void; + /** + * a function that sets a callback that is called when the last item from the queue has returned from the worker. + * If the callback is omitted, q.drain() returns a promise for the next occurrence. + */ + drain(): Promise; + drain(handler: () => void): void; idle(): boolean; pause(): void; resume(): void; diff --git a/types/async/test/index.ts b/types/async/test/index.ts index 7516e49192..7e3cd35872 100644 --- a/types/async/test/index.ts +++ b/types/async/test/index.ts @@ -256,6 +256,8 @@ const cargo = async.cargo((tasks, callback) => { } callback(); }, 2); +cargo.drain(); // $ExpectType Promise +cargo.drain(() => { console.log('done processing queue'); }); // $ExpectType void // add some items cargo.push({ name: 'foo' }, (err: Error) => { console.log('finished processing foo'); });