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!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz)
2020-01-21 16:22:54 -08:00
committed by Ben Lichtman
parent 5062ff431f
commit b8a56bd21b
2 changed files with 8 additions and 1 deletions
+6 -1
View File
@@ -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<void>;
drain(handler: () => void): void;
idle(): boolean;
pause(): void;
resume(): void;
+2
View File
@@ -256,6 +256,8 @@ const cargo = async.cargo((tasks, callback) => {
}
callback();
}, 2);
cargo.drain(); // $ExpectType Promise<void>
cargo.drain(() => { console.log('done processing queue'); }); // $ExpectType void
// add some items
cargo.push({ name: 'foo' }, (err: Error) => { console.log('finished processing foo'); });