mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
Updated async.queue definitions to v0.9.0
This commit is contained in:
@@ -145,9 +145,8 @@ q.drain = function () {
|
||||
console.log('all items have been processed');
|
||||
}
|
||||
|
||||
q.push({ name: 'foo' }, function (err) {
|
||||
console.log('finished processing foo');
|
||||
});
|
||||
q.push({ name: 'foo' });
|
||||
|
||||
q.push({ name: 'bar' }, function (err) {
|
||||
console.log('finished processing bar');
|
||||
});
|
||||
@@ -156,6 +155,38 @@ q.push([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (err) {
|
||||
console.log('finished processing bar');
|
||||
});
|
||||
|
||||
q.unshift({ name: 'foo' });
|
||||
|
||||
q.unshift({ name: 'bar' }, function (err) {
|
||||
console.log('finished processing bar');
|
||||
});
|
||||
|
||||
q.unshift([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (err) {
|
||||
console.log('finished processing bar');
|
||||
});
|
||||
|
||||
var qLength : number = q.length();
|
||||
var qStarted : boolean = q.started;
|
||||
var qPaused : boolean = q.paused;
|
||||
var qProcessingCount : number = q.running();
|
||||
var qIsIdle : boolean = q.idle();
|
||||
|
||||
q.saturated = function() {
|
||||
console.log('queue is saturated.');
|
||||
}
|
||||
|
||||
q.empty = function() {
|
||||
console.log('queue is empty.');
|
||||
}
|
||||
|
||||
q.drain = function() {
|
||||
console.log('queue was drained.');
|
||||
}
|
||||
|
||||
q.pause();
|
||||
q.resume();
|
||||
q.kill();
|
||||
|
||||
// tests for strongly typed tasks
|
||||
var q2 = async.queue(function (task: string, callback) {
|
||||
console.log('Task: ' + task);
|
||||
@@ -172,6 +203,16 @@ q2.push(['task3', 'task4', 'task5'], function (error, results: string[]) {
|
||||
console.log('Finished tasks: ' + results.join(', '));
|
||||
});
|
||||
|
||||
q2.unshift('task1');
|
||||
|
||||
q2.unshift('task2', function (error, results: string[]) {
|
||||
console.log('Finished tasks: ' + results.join(', '));
|
||||
});
|
||||
|
||||
q2.unshift(['task3', 'task4', 'task5'], function (error, results: string[]) {
|
||||
console.log('Finished tasks: ' + results.join(', '));
|
||||
});
|
||||
|
||||
var filename = '';
|
||||
async.auto({
|
||||
get_data: function (callback) { },
|
||||
|
||||
15
async/async.d.ts
vendored
15
async/async.d.ts
vendored
@@ -15,11 +15,20 @@ interface AsyncWorker<T> { (task: T, callback: Function): void; }
|
||||
interface AsyncQueue<T> {
|
||||
length(): number;
|
||||
concurrency: number;
|
||||
started: boolean;
|
||||
paused: boolean;
|
||||
push(task: T, callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
push(task: T[], callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
saturated: AsyncMultipleResultsCallback<T>;
|
||||
empty: AsyncMultipleResultsCallback<T>;
|
||||
drain: AsyncMultipleResultsCallback<T>;
|
||||
unshift(task: T, callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
unshift(task: T[], callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
saturated: () => any;
|
||||
empty: () => any;
|
||||
drain: () => any;
|
||||
running(): number;
|
||||
idle(): boolean;
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
kill(): void;
|
||||
}
|
||||
|
||||
interface Async {
|
||||
|
||||
Reference in New Issue
Block a user