本文整理匯總了TypeScript中vs/base/common/async.Queue類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Queue類的具體用法?TypeScript Queue怎麽用?TypeScript Queue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Queue類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('Queue - order is kept', function () {
let queue = new async.Queue();
let res: number[] = [];
let f1 = () => Promise.resolve(true).then(() => res.push(1));
let f2 = () => async.timeout(10).then(() => res.push(2));
let f3 = () => Promise.resolve(true).then(() => res.push(3));
let f4 = () => async.timeout(20).then(() => res.push(4));
let f5 = () => async.timeout(0).then(() => res.push(5));
queue.queue(f1);
queue.queue(f2);
queue.queue(f3);
queue.queue(f4);
return queue.queue(f5).then(() => {
assert.equal(res[0], 1);
assert.equal(res[1], 2);
assert.equal(res[2], 3);
assert.equal(res[3], 4);
assert.equal(res[4], 5);
});
});
示例2:
return queue.queue(f1).then(() => {
return queue.queue(f2).then(() => {
return queue.queue(f3).then(() => {
return queue.queue(f4).then(() => {
return queue.queue(f5).then(() => {
assert.equal(res[0], 1);
assert.equal(res[1], 2);
assert.equal(res[2], 3);
assert.equal(res[3], 4);
assert.equal(res[4], 5);
});
});
});
});
});