Files
DefinitelyTyped/promise-pool/promise-pool-tests.ts
2015-08-29 00:15:35 +09:00

50 lines
1018 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/// <reference path="./promise-pool.d.ts" />
import Q = require('q');
import promisePool = require('promise-pool');
var pool = new promisePool.Pool<number>((taskDataId, index) => {
return Q.delay(Math.floor(Math.random() * 5000)).then(function () {
taskDataId == 0;
index == 0;
});
}, 20);
pool
.pause()
.delay(5000)
.then(function () {
pool.resume();
});
pool.retries == 0;
pool.retryInterval == 0;
pool.maxRetryInterval == 0;
pool.retryIntervalMultiplier == 0;
pool.add(0);
pool
.start(onProgress)
.then(result => {
result.total == 0;
return pool.reset();
})
.then(() => {
return pool.start(onProgress);
})
.then(result => {
result.total == 0;
return pool.reset();
})
.then(() => {
pool.endless == true;
});
function onProgress(progress: promisePool.IProgress) {
progress.success == true;
progress.fulfilled == 0;
progress.total == 0;
progress.index == 0;
}