promise-parallel-throttle
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -17,2 +17,3 @@ export interface Result<T> { | ||
nextCheck?: nextTaskCheck; | ||
ignoreIsFunctionCheck?: boolean; | ||
} | ||
@@ -19,0 +20,0 @@ export declare type Task<T> = () => Promise<T>; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var _this = this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -17,11 +53,12 @@ var DEFAULT_MAX = 5; | ||
*/ | ||
var defaultNextTaskCheck = function (status, tasks) { | ||
return new Promise(function (resolve, reject) { | ||
resolve(status.amountStarted < tasks.length); | ||
var defaultNextTaskCheck = function (status, tasks) { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, Promise.resolve(status.amountStarted < tasks.length)]; | ||
}); | ||
}; | ||
}); }; | ||
var DEFAULT_OPTIONS = { | ||
maxInProgress: DEFAULT_MAX, | ||
failFast: false, | ||
nextCheck: defaultNextTaskCheck | ||
nextCheck: defaultNextTaskCheck, | ||
ignoreIsFunctionCheck: false | ||
}; | ||
@@ -35,78 +72,88 @@ /** | ||
function raw(tasks, options) { | ||
return new Promise(function (resolve, reject) { | ||
var myOptions = Object.assign({}, DEFAULT_OPTIONS, options); | ||
var result = { | ||
amountDone: 0, | ||
amountStarted: 0, | ||
amountResolved: 0, | ||
amountRejected: 0, | ||
amountNextCheckFalsey: 0, | ||
rejectedIndexes: [], | ||
resolvedIndexes: [], | ||
nextCheckFalseyIndexes: [], | ||
taskResults: [] | ||
}; | ||
if (tasks.length === 0) { | ||
return resolve(result); | ||
} | ||
var failedFast = false; | ||
var currentTaskIndex = 0; | ||
var executeTask = function (index) { | ||
result.amountStarted++; | ||
if (typeof tasks[index] === 'function') { | ||
tasks[index]().then(function (taskResult) { | ||
result.taskResults[index] = taskResult; | ||
result.resolvedIndexes.push(index); | ||
result.amountResolved++; | ||
taskDone(); | ||
}, function (error) { | ||
result.taskResults[index] = error; | ||
result.rejectedIndexes.push(index); | ||
result.amountRejected++; | ||
if (myOptions.failFast === true) { | ||
failedFast = true; | ||
return reject(result); | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
var myOptions = Object.assign({}, DEFAULT_OPTIONS, options); | ||
var result = { | ||
amountDone: 0, | ||
amountStarted: 0, | ||
amountResolved: 0, | ||
amountRejected: 0, | ||
amountNextCheckFalsey: 0, | ||
rejectedIndexes: [], | ||
resolvedIndexes: [], | ||
nextCheckFalseyIndexes: [], | ||
taskResults: [] | ||
}; | ||
if (tasks.length === 0) { | ||
return resolve(result); | ||
} | ||
taskDone(); | ||
}); | ||
} | ||
else { | ||
failedFast = true; | ||
return reject(new Error('tasks[' + index + ']: ' + tasks[index] + ', is supposed to be of type function')); | ||
} | ||
}; | ||
var taskDone = function () { | ||
//make sure no more tasks are spawned when we failedFast | ||
if (failedFast === true) { | ||
return; | ||
} | ||
result.amountDone++; | ||
if (typeof myOptions.progressCallback === 'function') { | ||
myOptions.progressCallback(result); | ||
} | ||
if (result.amountDone === tasks.length) { | ||
return resolve(result); | ||
} | ||
if (currentTaskIndex < tasks.length) { | ||
nextTask(currentTaskIndex++); | ||
} | ||
}; | ||
var nextTask = function (index) { | ||
//check if we can execute the next task | ||
myOptions.nextCheck(result, tasks).then(function (canExecuteNextTask) { | ||
if (canExecuteNextTask === true) { | ||
//execute it | ||
executeTask(index); | ||
} | ||
else { | ||
result.amountNextCheckFalsey++; | ||
result.nextCheckFalseyIndexes.push(index); | ||
taskDone(); | ||
} | ||
}, reject); | ||
}; | ||
//spawn the first X task | ||
for (var i = 0; i < Math.min(myOptions.maxInProgress, tasks.length); i++) { | ||
nextTask(currentTaskIndex++); | ||
} | ||
var failedFast = false; | ||
var currentTaskIndex = 0; | ||
var executeTask = function (index) { | ||
result.amountStarted++; | ||
if (typeof tasks[index] === 'function') { | ||
tasks[index]().then(function (taskResult) { | ||
result.taskResults[index] = taskResult; | ||
result.resolvedIndexes.push(index); | ||
result.amountResolved++; | ||
taskDone(); | ||
}, function (error) { | ||
result.taskResults[index] = error; | ||
result.rejectedIndexes.push(index); | ||
result.amountRejected++; | ||
if (myOptions.failFast === true) { | ||
failedFast = true; | ||
return reject(result); | ||
} | ||
taskDone(); | ||
}); | ||
} | ||
else if (myOptions.ignoreIsFunctionCheck === true) { | ||
result.taskResults[index] = tasks[index]; | ||
result.resolvedIndexes.push(index); | ||
result.amountResolved++; | ||
taskDone(); | ||
} | ||
else { | ||
failedFast = true; | ||
return reject(new Error('tasks[' + index + ']: ' + tasks[index] + ', is supposed to be of type function')); | ||
} | ||
}; | ||
var taskDone = function () { | ||
//make sure no more tasks are spawned when we failedFast | ||
if (failedFast === true) { | ||
return; | ||
} | ||
result.amountDone++; | ||
if (typeof myOptions.progressCallback === 'function') { | ||
myOptions.progressCallback(result); | ||
} | ||
if (result.amountDone === tasks.length) { | ||
return resolve(result); | ||
} | ||
if (currentTaskIndex < tasks.length) { | ||
nextTask(currentTaskIndex++); | ||
} | ||
}; | ||
var nextTask = function (index) { | ||
//check if we can execute the next task | ||
myOptions.nextCheck(result, tasks).then(function (canExecuteNextTask) { | ||
if (canExecuteNextTask === true) { | ||
//execute it | ||
executeTask(index); | ||
} | ||
else { | ||
result.amountNextCheckFalsey++; | ||
result.nextCheckFalseyIndexes.push(index); | ||
taskDone(); | ||
} | ||
}, reject); | ||
}; | ||
//spawn the first X task | ||
for (var i = 0; i < Math.min(myOptions.maxInProgress, tasks.length); i++) { | ||
nextTask(currentTaskIndex++); | ||
} | ||
})]; | ||
}); | ||
}); | ||
@@ -122,12 +169,16 @@ } | ||
function executeRaw(tasks, options) { | ||
return new Promise(function (resolve, reject) { | ||
raw(tasks, options).then(function (result) { | ||
resolve(result.taskResults); | ||
}, function (error) { | ||
if (error instanceof Error) { | ||
reject(error); | ||
} | ||
else { | ||
reject(error.taskResults[error.rejectedIndexes[0]]); | ||
} | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
raw(tasks, options).then(function (result) { | ||
resolve(result.taskResults); | ||
}, function (error) { | ||
if (error instanceof Error) { | ||
reject(error); | ||
} | ||
else { | ||
reject(error.taskResults[error.rejectedIndexes[0]]); | ||
} | ||
}); | ||
})]; | ||
}); | ||
@@ -143,4 +194,9 @@ }); | ||
function sync(tasks, options) { | ||
var myOptions = Object.assign({}, { maxInProgress: 1, failFast: true }, options); | ||
return executeRaw(tasks, myOptions); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var myOptions; | ||
return __generator(this, function (_a) { | ||
myOptions = Object.assign({}, { maxInProgress: 1, failFast: true }, options); | ||
return [2 /*return*/, executeRaw(tasks, myOptions)]; | ||
}); | ||
}); | ||
} | ||
@@ -155,6 +211,11 @@ exports.sync = sync; | ||
function all(tasks, options) { | ||
var myOptions = Object.assign({}, { failFast: true }, options); | ||
return executeRaw(tasks, myOptions); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var myOptions; | ||
return __generator(this, function (_a) { | ||
myOptions = Object.assign({}, { failFast: true }, options); | ||
return [2 /*return*/, executeRaw(tasks, myOptions)]; | ||
}); | ||
}); | ||
} | ||
exports.all = all; | ||
//# sourceMappingURL=throttle.js.map |
@@ -1,2 +0,2 @@ | ||
{"/mnt/d/Projecten/Promise-parallel-throttle/src/throttle.ts": {"path":"/mnt/d/Projecten/Promise-parallel-throttle/src/throttle.ts","statementMap":{"0":{"start":{"line":1,"column":13},"end":{"line":1,"column":42}},"1":{"start":{"line":1,"column":42},"end":{"line":1,"column":55}},"2":{"start":{"line":2,"column":0},"end":{"line":2,"column":62}},"3":{"start":{"line":3,"column":18},"end":{"line":3,"column":19}},"4":{"start":{"line":17,"column":27},"end":{"line":21,"column":1}},"5":{"start":{"line":18,"column":4},"end":{"line":20,"column":7}},"6":{"start":{"line":19,"column":8},"end":{"line":19,"column":53}},"7":{"start":{"line":22,"column":22},"end":{"line":26,"column":1}},"8":{"start":{"line":34,"column":4},"end":{"line":110,"column":7}},"9":{"start":{"line":35,"column":24},"end":{"line":35,"column":67}},"10":{"start":{"line":36,"column":21},"end":{"line":46,"column":9}},"11":{"start":{"line":47,"column":8},"end":{"line":49,"column":9}},"12":{"start":{"line":48,"column":12},"end":{"line":48,"column":35}},"13":{"start":{"line":50,"column":25},"end":{"line":50,"column":30}},"14":{"start":{"line":51,"column":31},"end":{"line":51,"column":32}},"15":{"start":{"line":52,"column":26},"end":{"line":75,"column":9}},"16":{"start":{"line":53,"column":12},"end":{"line":53,"column":35}},"17":{"start":{"line":54,"column":12},"end":{"line":74,"column":13}},"18":{"start":{"line":55,"column":16},"end":{"line":69,"column":19}},"19":{"start":{"line":56,"column":20},"end":{"line":56,"column":59}},"20":{"start":{"line":57,"column":20},"end":{"line":57,"column":55}},"21":{"start":{"line":58,"column":20},"end":{"line":58,"column":44}},"22":{"start":{"line":59,"column":20},"end":{"line":59,"column":31}},"23":{"start":{"line":61,"column":20},"end":{"line":61,"column":54}},"24":{"start":{"line":62,"column":20},"end":{"line":62,"column":55}},"25":{"start":{"line":63,"column":20},"end":{"line":63,"column":44}},"26":{"start":{"line":64,"column":20},"end":{"line":67,"column":21}},"27":{"start":{"line":65,"column":24},"end":{"line":65,"column":42}},"28":{"start":{"line":66,"column":24},"end":{"line":66,"column":46}},"29":{"start":{"line":68,"column":20},"end":{"line":68,"column":31}},"30":{"start":{"line":72,"column":16},"end":{"line":72,"column":34}},"31":{"start":{"line":73,"column":16},"end":{"line":73,"column":123}},"32":{"start":{"line":76,"column":23},"end":{"line":91,"column":9}},"33":{"start":{"line":78,"column":12},"end":{"line":80,"column":13}},"34":{"start":{"line":79,"column":16},"end":{"line":79,"column":23}},"35":{"start":{"line":81,"column":12},"end":{"line":81,"column":32}},"36":{"start":{"line":82,"column":12},"end":{"line":84,"column":13}},"37":{"start":{"line":83,"column":16},"end":{"line":83,"column":51}},"38":{"start":{"line":85,"column":12},"end":{"line":87,"column":13}},"39":{"start":{"line":86,"column":16},"end":{"line":86,"column":39}},"40":{"start":{"line":88,"column":12},"end":{"line":90,"column":13}},"41":{"start":{"line":89,"column":16},"end":{"line":89,"column":45}},"42":{"start":{"line":92,"column":23},"end":{"line":105,"column":9}},"43":{"start":{"line":94,"column":12},"end":{"line":104,"column":23}},"44":{"start":{"line":95,"column":16},"end":{"line":103,"column":17}},"45":{"start":{"line":97,"column":20},"end":{"line":97,"column":39}},"46":{"start":{"line":100,"column":20},"end":{"line":100,"column":51}},"47":{"start":{"line":101,"column":20},"end":{"line":101,"column":62}},"48":{"start":{"line":102,"column":20},"end":{"line":102,"column":31}},"49":{"start":{"line":107,"column":8},"end":{"line":109,"column":9}},"50":{"start":{"line":108,"column":12},"end":{"line":108,"column":41}},"51":{"start":{"line":112,"column":0},"end":{"line":112,"column":18}},"52":{"start":{"line":120,"column":4},"end":{"line":131,"column":7}},"53":{"start":{"line":121,"column":8},"end":{"line":130,"column":11}},"54":{"start":{"line":122,"column":12},"end":{"line":122,"column":40}},"55":{"start":{"line":124,"column":12},"end":{"line":129,"column":13}},"56":{"start":{"line":125,"column":16},"end":{"line":125,"column":30}},"57":{"start":{"line":128,"column":16},"end":{"line":128,"column":68}},"58":{"start":{"line":140,"column":20},"end":{"line":140,"column":84}},"59":{"start":{"line":141,"column":4},"end":{"line":141,"column":40}},"60":{"start":{"line":143,"column":0},"end":{"line":143,"column":20}},"61":{"start":{"line":151,"column":20},"end":{"line":151,"column":66}},"62":{"start":{"line":152,"column":4},"end":{"line":152,"column":40}},"63":{"start":{"line":154,"column":0},"end":{"line":154,"column":18}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":17,"column":27},"end":{"line":17,"column":28}},"loc":{"start":{"line":17,"column":52},"end":{"line":21,"column":1}},"line":17},"1":{"name":"(anonymous_1)","decl":{"start":{"line":18,"column":23},"end":{"line":18,"column":24}},"loc":{"start":{"line":18,"column":50},"end":{"line":20,"column":5}},"line":18},"2":{"name":"raw","decl":{"start":{"line":33,"column":9},"end":{"line":33,"column":12}},"loc":{"start":{"line":33,"column":29},"end":{"line":111,"column":1}},"line":33},"3":{"name":"(anonymous_3)","decl":{"start":{"line":34,"column":23},"end":{"line":34,"column":24}},"loc":{"start":{"line":34,"column":50},"end":{"line":110,"column":5}},"line":34},"4":{"name":"(anonymous_4)","decl":{"start":{"line":52,"column":26},"end":{"line":52,"column":27}},"loc":{"start":{"line":52,"column":43},"end":{"line":75,"column":9}},"line":52},"5":{"name":"(anonymous_5)","decl":{"start":{"line":55,"column":36},"end":{"line":55,"column":37}},"loc":{"start":{"line":55,"column":58},"end":{"line":60,"column":17}},"line":55},"6":{"name":"(anonymous_6)","decl":{"start":{"line":60,"column":19},"end":{"line":60,"column":20}},"loc":{"start":{"line":60,"column":36},"end":{"line":69,"column":17}},"line":60},"7":{"name":"(anonymous_7)","decl":{"start":{"line":76,"column":23},"end":{"line":76,"column":24}},"loc":{"start":{"line":76,"column":35},"end":{"line":91,"column":9}},"line":76},"8":{"name":"(anonymous_8)","decl":{"start":{"line":92,"column":23},"end":{"line":92,"column":24}},"loc":{"start":{"line":92,"column":40},"end":{"line":105,"column":9}},"line":92},"9":{"name":"(anonymous_9)","decl":{"start":{"line":94,"column":52},"end":{"line":94,"column":53}},"loc":{"start":{"line":94,"column":82},"end":{"line":104,"column":13}},"line":94},"10":{"name":"executeRaw","decl":{"start":{"line":119,"column":9},"end":{"line":119,"column":19}},"loc":{"start":{"line":119,"column":36},"end":{"line":132,"column":1}},"line":119},"11":{"name":"(anonymous_11)","decl":{"start":{"line":120,"column":23},"end":{"line":120,"column":24}},"loc":{"start":{"line":120,"column":50},"end":{"line":131,"column":5}},"line":120},"12":{"name":"(anonymous_12)","decl":{"start":{"line":121,"column":33},"end":{"line":121,"column":34}},"loc":{"start":{"line":121,"column":51},"end":{"line":123,"column":9}},"line":121},"13":{"name":"(anonymous_13)","decl":{"start":{"line":123,"column":11},"end":{"line":123,"column":12}},"loc":{"start":{"line":123,"column":28},"end":{"line":130,"column":9}},"line":123},"14":{"name":"sync","decl":{"start":{"line":139,"column":9},"end":{"line":139,"column":13}},"loc":{"start":{"line":139,"column":30},"end":{"line":142,"column":1}},"line":139},"15":{"name":"all","decl":{"start":{"line":150,"column":9},"end":{"line":150,"column":12}},"loc":{"start":{"line":150,"column":29},"end":{"line":153,"column":1}},"line":150}},"branchMap":{"0":{"loc":{"start":{"line":47,"column":8},"end":{"line":49,"column":9}},"type":"if","locations":[{"start":{"line":47,"column":8},"end":{"line":49,"column":9}},{"start":{"line":47,"column":8},"end":{"line":49,"column":9}}],"line":47},"1":{"loc":{"start":{"line":54,"column":12},"end":{"line":74,"column":13}},"type":"if","locations":[{"start":{"line":54,"column":12},"end":{"line":74,"column":13}},{"start":{"line":54,"column":12},"end":{"line":74,"column":13}}],"line":54},"2":{"loc":{"start":{"line":64,"column":20},"end":{"line":67,"column":21}},"type":"if","locations":[{"start":{"line":64,"column":20},"end":{"line":67,"column":21}},{"start":{"line":64,"column":20},"end":{"line":67,"column":21}}],"line":64},"3":{"loc":{"start":{"line":78,"column":12},"end":{"line":80,"column":13}},"type":"if","locations":[{"start":{"line":78,"column":12},"end":{"line":80,"column":13}},{"start":{"line":78,"column":12},"end":{"line":80,"column":13}}],"line":78},"4":{"loc":{"start":{"line":82,"column":12},"end":{"line":84,"column":13}},"type":"if","locations":[{"start":{"line":82,"column":12},"end":{"line":84,"column":13}},{"start":{"line":82,"column":12},"end":{"line":84,"column":13}}],"line":82},"5":{"loc":{"start":{"line":85,"column":12},"end":{"line":87,"column":13}},"type":"if","locations":[{"start":{"line":85,"column":12},"end":{"line":87,"column":13}},{"start":{"line":85,"column":12},"end":{"line":87,"column":13}}],"line":85},"6":{"loc":{"start":{"line":88,"column":12},"end":{"line":90,"column":13}},"type":"if","locations":[{"start":{"line":88,"column":12},"end":{"line":90,"column":13}},{"start":{"line":88,"column":12},"end":{"line":90,"column":13}}],"line":88},"7":{"loc":{"start":{"line":95,"column":16},"end":{"line":103,"column":17}},"type":"if","locations":[{"start":{"line":95,"column":16},"end":{"line":103,"column":17}},{"start":{"line":95,"column":16},"end":{"line":103,"column":17}}],"line":95},"8":{"loc":{"start":{"line":124,"column":12},"end":{"line":129,"column":13}},"type":"if","locations":[{"start":{"line":124,"column":12},"end":{"line":129,"column":13}},{"start":{"line":124,"column":12},"end":{"line":129,"column":13}}],"line":124}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":71,"6":71,"7":1,"8":19,"9":19,"10":19,"11":19,"12":1,"13":18,"14":18,"15":18,"16":81,"17":81,"18":78,"19":56,"20":56,"21":56,"22":56,"23":22,"24":22,"25":22,"26":22,"27":7,"28":7,"29":15,"30":3,"31":3,"32":18,"33":75,"34":8,"35":67,"36":67,"37":5,"38":67,"39":11,"40":56,"41":26,"42":18,"43":86,"44":85,"45":81,"46":4,"47":4,"48":4,"49":18,"50":60,"51":1,"52":8,"53":8,"54":4,"55":4,"56":2,"57":2,"58":4,"59":4,"60":1,"61":4,"62":4,"63":1},"f":{"0":71,"1":71,"2":19,"3":19,"4":81,"5":56,"6":22,"7":75,"8":86,"9":85,"10":8,"11":8,"12":4,"13":4,"14":4,"15":4},"b":{"0":[1,18],"1":[78,3],"2":[7,15],"3":[8,67],"4":[5,62],"5":[11,56],"6":[26,30],"7":[81,4],"8":[2,2]},"inputSourceMap":{"version":3,"file":"throttle.js","sourceRoot":"","sources":["file:////mnt/d/Projecten/Promise-parallel-throttle/src/throttle.ts"],"names":[],"mappings":"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","sourcesContent":["const DEFAULT_MAX = 5;\r\n\r\nexport interface Result<T> {\r\n amountDone: number;\r\n amountStarted: number;\r\n amountResolved: number;\r\n amountRejected: number;\r\n amountNextCheckFalsey: number;\r\n rejectedIndexes: number[];\r\n resolvedIndexes: number[];\r\n nextCheckFalseyIndexes: number[];\r\n taskResults: T[];\r\n}\r\n\r\nexport interface Options {\r\n maxInProgress?: number;\r\n failFast?: boolean;\r\n progressCallback?: <T>(result: Result<T>) => void;\r\n nextCheck?: nextTaskCheck;\r\n}\r\n\r\n/**\r\n * Default checker which validates if a next task should begin.\r\n * This can be overwritten to write own checks for example checking the amount\r\n * of used ram and waiting till the ram is low enough for a next task.\r\n *\r\n * It should always resolve with a boolean, either `true` to start a next task\r\n * or `false` to stop executing a new task.\r\n *\r\n * If this method rejects, the error will propagate to the caller\r\n * @param status\r\n * @param tasks\r\n * @returns {Promise}\r\n */\r\nconst defaultNextTaskCheck: nextTaskCheck = <T>(status: Result<T>, tasks: Tasks<T>): Promise<boolean> => {\r\n return new Promise((resolve, reject) => {\r\n resolve(status.amountStarted < tasks.length);\r\n });\r\n};\r\n\r\nconst DEFAULT_OPTIONS = {\r\n maxInProgress: DEFAULT_MAX,\r\n failFast: false,\r\n nextCheck: defaultNextTaskCheck\r\n};\r\n\r\nexport type Task<T> = () => Promise<T>;\r\nexport type Tasks<T> = Array<Task<T>>;\r\nexport type nextTaskCheck = <T>(status: Result<T>, tasks: Tasks<T>) => Promise<boolean>;\r\n\r\n/**\r\n * Raw throttle function, which can return extra meta data.\r\n * @param tasks required array of tasks to be executed\r\n * @param options Options object\r\n * @returns {Promise}\r\n */\r\nexport function raw<T>(tasks: Tasks<T>, options?: Options): Promise<Result<T>> {\r\n return new Promise((resolve, reject) => {\r\n const myOptions = Object.assign({}, DEFAULT_OPTIONS, options);\r\n const result: Result<T> = {\r\n amountDone: 0,\r\n amountStarted: 0,\r\n amountResolved: 0,\r\n amountRejected: 0,\r\n amountNextCheckFalsey: 0,\r\n rejectedIndexes: [],\r\n resolvedIndexes: [],\r\n nextCheckFalseyIndexes: [],\r\n taskResults: []\r\n };\r\n\r\n if (tasks.length === 0) {\r\n return resolve(result);\r\n }\r\n\r\n let failedFast = false;\r\n let currentTaskIndex = 0;\r\n const executeTask = (index: number) => {\r\n result.amountStarted++;\r\n\r\n if (typeof tasks[index] === 'function') {\r\n tasks[index]().then(\r\n taskResult => {\r\n result.taskResults[index] = taskResult;\r\n result.resolvedIndexes.push(index);\r\n result.amountResolved++;\r\n taskDone();\r\n },\r\n error => {\r\n result.taskResults[index] = error;\r\n result.rejectedIndexes.push(index);\r\n result.amountRejected++;\r\n if (myOptions.failFast === true) {\r\n failedFast = true;\r\n return reject(result);\r\n }\r\n taskDone();\r\n }\r\n );\r\n } else {\r\n failedFast = true;\r\n return reject(\r\n new Error('tasks[' + index + ']: ' + tasks[index] + ', is supposed to be of type function')\r\n );\r\n }\r\n };\r\n\r\n const taskDone = () => {\r\n //make sure no more tasks are spawned when we failedFast\r\n if (failedFast === true) {\r\n return;\r\n }\r\n\r\n result.amountDone++;\r\n if (typeof (myOptions as Options).progressCallback === 'function') {\r\n (myOptions as any).progressCallback(result);\r\n }\r\n if (result.amountDone === tasks.length) {\r\n return resolve(result);\r\n }\r\n if (currentTaskIndex < tasks.length) {\r\n nextTask(currentTaskIndex++);\r\n }\r\n };\r\n\r\n const nextTask = (index: number) => {\r\n //check if we can execute the next task\r\n myOptions.nextCheck(result, tasks).then(canExecuteNextTask => {\r\n if (canExecuteNextTask === true) {\r\n //execute it\r\n executeTask(index);\r\n } else {\r\n result.amountNextCheckFalsey++;\r\n result.nextCheckFalseyIndexes.push(index);\r\n taskDone();\r\n }\r\n }, reject);\r\n };\r\n\r\n //spawn the first X task\r\n for (let i = 0; i < Math.min(myOptions.maxInProgress, tasks.length); i++) {\r\n nextTask(currentTaskIndex++);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Executes the raw function, but only return the task array\r\n * @param tasks \r\n * @param options \r\n * @returns {Promise}\r\n */\r\nfunction executeRaw<T>(tasks: Tasks<T>, options: Options): Promise<T[]> {\r\n return new Promise((resolve, reject) => {\r\n raw(tasks, options).then(\r\n (result: Result<T>) => {\r\n resolve(result.taskResults);\r\n },\r\n (error: Error | Result<T>) => {\r\n if (error instanceof Error) {\r\n reject(error);\r\n } else {\r\n reject(error.taskResults[error.rejectedIndexes[0]]);\r\n }\r\n }\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Simply run all the promises after each other, so in synchronous manner\r\n * @param tasks required array of tasks to be executed\r\n * @param options Options object\r\n * @returns {Promise}\r\n */\r\nexport function sync<T>(tasks: Tasks<T>, options?: Options): Promise<T[]> {\r\n const myOptions = Object.assign({}, { maxInProgress: 1, failFast: true }, options);\r\n return executeRaw(tasks, myOptions);\r\n}\r\n\r\n/**\r\n * Exposes the same behaviour as Promise.All(), but throttled!\r\n * @param tasks required array of tasks to be executed\r\n * @param options Options object\r\n * @returns {Promise}\r\n */\r\nexport function all<T>(tasks: Tasks<T>, options?: Options): Promise<T[]> {\r\n const myOptions = Object.assign({}, { failFast: true }, options);\r\n return executeRaw(tasks, myOptions);\r\n}\r\n"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"579921541b26caec6f98bdd740b0875053cea541"} | ||
{"/mnt/c/Users/dirk-/Projecten/Promise-parallel-throttle/src/throttle.ts": {"path":"/mnt/c/Users/dirk-/Projecten/Promise-parallel-throttle/src/throttle.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":196,"column":-1}},"1":{"start":{"line":1,"column":20},"end":{"line":1,"column":21}},"2":{"start":{"line":36,"column":44},"end":{"line":38,"column":1}},"3":{"start":{"line":37,"column":4},"end":{"line":37,"column":64}},"4":{"start":{"line":40,"column":24},"end":{"line":45,"column":1}},"5":{"start":{"line":58,"column":4},"end":{"line":149,"column":7}},"6":{"start":{"line":59,"column":26},"end":{"line":59,"column":69}},"7":{"start":{"line":60,"column":34},"end":{"line":70,"column":9}},"8":{"start":{"line":72,"column":8},"end":{"line":74,"column":9}},"9":{"start":{"line":73,"column":12},"end":{"line":73,"column":35}},"10":{"start":{"line":76,"column":25},"end":{"line":76,"column":30}},"11":{"start":{"line":77,"column":31},"end":{"line":77,"column":32}},"12":{"start":{"line":78,"column":28},"end":{"line":111,"column":9}},"13":{"start":{"line":79,"column":12},"end":{"line":79,"column":35}},"14":{"start":{"line":81,"column":12},"end":{"line":110,"column":13}},"15":{"start":{"line":82,"column":16},"end":{"line":99,"column":18}},"16":{"start":{"line":84,"column":24},"end":{"line":84,"column":63}},"17":{"start":{"line":85,"column":24},"end":{"line":85,"column":59}},"18":{"start":{"line":86,"column":24},"end":{"line":86,"column":48}},"19":{"start":{"line":87,"column":24},"end":{"line":87,"column":35}},"20":{"start":{"line":90,"column":24},"end":{"line":90,"column":58}},"21":{"start":{"line":91,"column":24},"end":{"line":91,"column":59}},"22":{"start":{"line":92,"column":24},"end":{"line":92,"column":48}},"23":{"start":{"line":93,"column":24},"end":{"line":96,"column":25}},"24":{"start":{"line":94,"column":28},"end":{"line":94,"column":46}},"25":{"start":{"line":95,"column":28},"end":{"line":95,"column":50}},"26":{"start":{"line":97,"column":24},"end":{"line":97,"column":35}},"27":{"start":{"line":100,"column":19},"end":{"line":110,"column":13}},"28":{"start":{"line":101,"column":16},"end":{"line":101,"column":71}},"29":{"start":{"line":102,"column":16},"end":{"line":102,"column":51}},"30":{"start":{"line":103,"column":16},"end":{"line":103,"column":40}},"31":{"start":{"line":104,"column":16},"end":{"line":104,"column":27}},"32":{"start":{"line":106,"column":16},"end":{"line":106,"column":34}},"33":{"start":{"line":107,"column":16},"end":{"line":109,"column":18}},"34":{"start":{"line":113,"column":25},"end":{"line":129,"column":9}},"35":{"start":{"line":115,"column":12},"end":{"line":117,"column":13}},"36":{"start":{"line":116,"column":16},"end":{"line":116,"column":23}},"37":{"start":{"line":119,"column":12},"end":{"line":119,"column":32}},"38":{"start":{"line":120,"column":12},"end":{"line":122,"column":13}},"39":{"start":{"line":121,"column":17},"end":{"line":121,"column":60}},"40":{"start":{"line":123,"column":12},"end":{"line":125,"column":13}},"41":{"start":{"line":124,"column":16},"end":{"line":124,"column":39}},"42":{"start":{"line":126,"column":12},"end":{"line":128,"column":13}},"43":{"start":{"line":127,"column":16},"end":{"line":127,"column":45}},"44":{"start":{"line":131,"column":25},"end":{"line":143,"column":9}},"45":{"start":{"line":133,"column":12},"end":{"line":142,"column":23}},"46":{"start":{"line":134,"column":16},"end":{"line":141,"column":17}},"47":{"start":{"line":136,"column":20},"end":{"line":136,"column":39}},"48":{"start":{"line":138,"column":20},"end":{"line":138,"column":51}},"49":{"start":{"line":139,"column":20},"end":{"line":139,"column":62}},"50":{"start":{"line":140,"column":20},"end":{"line":140,"column":31}},"51":{"start":{"line":146,"column":8},"end":{"line":148,"column":9}},"52":{"start":{"line":147,"column":12},"end":{"line":147,"column":41}},"53":{"start":{"line":57,"column":0},"end":{"line":150,"column":1}},"54":{"start":{"line":159,"column":4},"end":{"line":172,"column":7}},"55":{"start":{"line":160,"column":8},"end":{"line":171,"column":10}},"56":{"start":{"line":162,"column":16},"end":{"line":162,"column":44}},"57":{"start":{"line":165,"column":16},"end":{"line":169,"column":17}},"58":{"start":{"line":166,"column":20},"end":{"line":166,"column":34}},"59":{"start":{"line":168,"column":20},"end":{"line":168,"column":72}},"60":{"start":{"line":182,"column":10},"end":{"line":182,"column":85}},"61":{"start":{"line":183,"column":4},"end":{"line":183,"column":40}},"62":{"start":{"line":181,"column":0},"end":{"line":184,"column":1}},"63":{"start":{"line":193,"column":10},"end":{"line":193,"column":67}},"64":{"start":{"line":194,"column":4},"end":{"line":194,"column":40}},"65":{"start":{"line":192,"column":0},"end":{"line":195,"column":1}}},"fnMap":{"0":{"name":"(anonymous_12)","decl":{"start":{"line":36,"column":44},"end":{"line":36,"column":53}},"loc":{"start":{"line":36,"column":88},"end":{"line":38,"column":1}}},"1":{"name":"raw","decl":{"start":{"line":57,"column":22},"end":{"line":57,"column":25}},"loc":{"start":{"line":57,"column":63},"end":{"line":150,"column":1}}},"2":{"name":"(anonymous_18)","decl":{"start":{"line":58,"column":34},"end":{"line":58,"column":34}},"loc":{"start":{"line":58,"column":50},"end":{"line":149,"column":5}}},"3":{"name":"(anonymous_19)","decl":{"start":{"line":78,"column":28},"end":{"line":78,"column":28}},"loc":{"start":{"line":78,"column":42},"end":{"line":111,"column":9}}},"4":{"name":"(anonymous_20)","decl":{"start":{"line":83,"column":20},"end":{"line":83,"column":19}},"loc":{"start":{"line":83,"column":30},"end":{"line":88,"column":21}}},"5":{"name":"(anonymous_21)","decl":{"start":{"line":89,"column":20},"end":{"line":89,"column":19}},"loc":{"start":{"line":89,"column":25},"end":{"line":98,"column":21}}},"6":{"name":"(anonymous_22)","decl":{"start":{"line":113,"column":25},"end":{"line":null,"column":-1}},"loc":{"start":{"line":113,"column":25},"end":{"line":129,"column":9}}},"7":{"name":"(anonymous_23)","decl":{"start":{"line":131,"column":25},"end":{"line":131,"column":25}},"loc":{"start":{"line":131,"column":39},"end":{"line":143,"column":9}}},"8":{"name":"(anonymous_24)","decl":{"start":{"line":133,"column":52},"end":{"line":133,"column":51}},"loc":{"start":{"line":133,"column":70},"end":{"line":142,"column":13}}},"9":{"name":"executeRaw","decl":{"start":{"line":158,"column":15},"end":{"line":158,"column":25}},"loc":{"start":{"line":158,"column":62},"end":{"line":173,"column":1}}},"10":{"name":"(anonymous_28)","decl":{"start":{"line":159,"column":28},"end":{"line":159,"column":28}},"loc":{"start":{"line":159,"column":44},"end":{"line":172,"column":5}}},"11":{"name":"(anonymous_29)","decl":{"start":{"line":161,"column":12},"end":{"line":161,"column":12}},"loc":{"start":{"line":161,"column":30},"end":{"line":163,"column":13}}},"12":{"name":"(anonymous_30)","decl":{"start":{"line":164,"column":12},"end":{"line":164,"column":12}},"loc":{"start":{"line":164,"column":37},"end":{"line":170,"column":13}}},"13":{"name":"sync","decl":{"start":{"line":181,"column":22},"end":{"line":181,"column":26}},"loc":{"start":{"line":181,"column":64},"end":{"line":184,"column":1}}},"14":{"name":"all","decl":{"start":{"line":192,"column":22},"end":{"line":192,"column":25}},"loc":{"start":{"line":192,"column":63},"end":{"line":195,"column":1}}}},"branchMap":{"0":{"loc":{"start":{"line":72,"column":8},"end":{"line":74,"column":9}},"type":"if","locations":[{"start":{"line":72,"column":8},"end":{"line":74,"column":9}},{"start":{"line":72,"column":8},"end":{"line":74,"column":9}}]},"1":{"loc":{"start":{"line":81,"column":12},"end":{"line":110,"column":13}},"type":"if","locations":[{"start":{"line":81,"column":12},"end":{"line":110,"column":13}},{"start":{"line":81,"column":12},"end":{"line":110,"column":13}}]},"2":{"loc":{"start":{"line":93,"column":24},"end":{"line":96,"column":25}},"type":"if","locations":[{"start":{"line":93,"column":24},"end":{"line":96,"column":25}},{"start":{"line":93,"column":24},"end":{"line":96,"column":25}}]},"3":{"loc":{"start":{"line":100,"column":19},"end":{"line":110,"column":13}},"type":"if","locations":[{"start":{"line":100,"column":19},"end":{"line":110,"column":13}},{"start":{"line":100,"column":19},"end":{"line":110,"column":13}}]},"4":{"loc":{"start":{"line":115,"column":12},"end":{"line":117,"column":13}},"type":"if","locations":[{"start":{"line":115,"column":12},"end":{"line":117,"column":13}},{"start":{"line":115,"column":12},"end":{"line":117,"column":13}}]},"5":{"loc":{"start":{"line":120,"column":12},"end":{"line":122,"column":13}},"type":"if","locations":[{"start":{"line":120,"column":12},"end":{"line":122,"column":13}},{"start":{"line":120,"column":12},"end":{"line":122,"column":13}}]},"6":{"loc":{"start":{"line":123,"column":12},"end":{"line":125,"column":13}},"type":"if","locations":[{"start":{"line":123,"column":12},"end":{"line":125,"column":13}},{"start":{"line":123,"column":12},"end":{"line":125,"column":13}}]},"7":{"loc":{"start":{"line":126,"column":12},"end":{"line":128,"column":13}},"type":"if","locations":[{"start":{"line":126,"column":12},"end":{"line":128,"column":13}},{"start":{"line":126,"column":12},"end":{"line":128,"column":13}}]},"8":{"loc":{"start":{"line":134,"column":16},"end":{"line":141,"column":17}},"type":"if","locations":[{"start":{"line":134,"column":16},"end":{"line":141,"column":17}},{"start":{"line":134,"column":16},"end":{"line":141,"column":17}}]},"9":{"loc":{"start":{"line":165,"column":16},"end":{"line":169,"column":17}},"type":"if","locations":[{"start":{"line":165,"column":16},"end":{"line":169,"column":17}},{"start":{"line":165,"column":16},"end":{"line":169,"column":17}}]}},"s":{"0":1,"1":1,"2":1,"3":76,"4":1,"5":20,"6":20,"7":20,"8":20,"9":1,"10":19,"11":19,"12":19,"13":86,"14":86,"15":82,"16":60,"17":60,"18":60,"19":60,"20":22,"21":22,"22":22,"23":22,"24":7,"25":7,"26":15,"27":4,"28":1,"29":1,"30":1,"31":1,"32":3,"33":3,"34":19,"35":80,"36":8,"37":72,"38":72,"39":10,"40":72,"41":12,"42":60,"43":26,"44":19,"45":91,"46":90,"47":86,"48":4,"49":4,"50":4,"51":19,"52":65,"53":1,"54":8,"55":8,"56":4,"57":4,"58":2,"59":2,"60":4,"61":4,"62":1,"63":4,"64":4,"65":1},"f":{"0":76,"1":20,"2":20,"3":86,"4":60,"5":22,"6":80,"7":91,"8":90,"9":8,"10":8,"11":4,"12":4,"13":4,"14":4},"b":{"0":[1,19],"1":[82,4],"2":[7,15],"3":[1,3],"4":[8,72],"5":[10,62],"6":[12,60],"7":[26,34],"8":[86,4],"9":[2,2]}} | ||
} |
{ | ||
"/mnt/d/Projecten/Promise-parallel-throttle/src/throttle.ts":{"path":"/mnt/d/Projecten/Promise-parallel-throttle/src/throttle.ts","statementMap":{"1":{"start":{"line":1,"column":20},"end":{"line":1,"column":21}},"2":{"start":{"line":35,"column":44},"end":{"line":39,"column":1}},"3":{"start":{"line":36,"column":4},"end":{"line":38,"column":7}},"4":{"start":{"line":37,"column":8},"end":{"line":37,"column":53}},"5":{"start":{"line":41,"column":24},"end":{"line":45,"column":1}},"6":{"start":{"line":58,"column":4},"end":{"line":144,"column":7}},"7":{"start":{"line":59,"column":26},"end":{"line":59,"column":69}},"8":{"start":{"line":60,"column":34},"end":{"line":70,"column":9}},"9":{"start":{"line":72,"column":8},"end":{"line":74,"column":9}},"10":{"start":{"line":73,"column":12},"end":{"line":73,"column":35}},"11":{"start":{"line":76,"column":25},"end":{"line":76,"column":30}},"12":{"start":{"line":77,"column":31},"end":{"line":77,"column":32}},"13":{"start":{"line":78,"column":28},"end":{"line":106,"column":9}},"14":{"start":{"line":79,"column":12},"end":{"line":79,"column":35}},"15":{"start":{"line":81,"column":12},"end":{"line":105,"column":13}},"16":{"start":{"line":82,"column":16},"end":{"line":99,"column":18}},"17":{"start":{"line":84,"column":24},"end":{"line":84,"column":63}},"18":{"start":{"line":85,"column":24},"end":{"line":85,"column":59}},"19":{"start":{"line":86,"column":24},"end":{"line":86,"column":48}},"20":{"start":{"line":87,"column":24},"end":{"line":87,"column":35}},"21":{"start":{"line":90,"column":24},"end":{"line":90,"column":58}},"22":{"start":{"line":91,"column":24},"end":{"line":91,"column":59}},"23":{"start":{"line":92,"column":24},"end":{"line":92,"column":48}},"24":{"start":{"line":93,"column":24},"end":{"line":96,"column":25}},"25":{"start":{"line":94,"column":28},"end":{"line":94,"column":46}},"26":{"start":{"line":95,"column":28},"end":{"line":95,"column":50}},"27":{"start":{"line":97,"column":24},"end":{"line":97,"column":35}},"28":{"start":{"line":101,"column":16},"end":{"line":101,"column":34}},"29":{"start":{"line":102,"column":16},"end":{"line":104,"column":18}},"30":{"start":{"line":108,"column":25},"end":{"line":124,"column":9}},"31":{"start":{"line":110,"column":12},"end":{"line":112,"column":13}},"32":{"start":{"line":111,"column":16},"end":{"line":111,"column":23}},"33":{"start":{"line":114,"column":12},"end":{"line":114,"column":32}},"34":{"start":{"line":115,"column":12},"end":{"line":117,"column":13}},"35":{"start":{"line":116,"column":17},"end":{"line":116,"column":60}},"36":{"start":{"line":118,"column":12},"end":{"line":120,"column":13}},"37":{"start":{"line":119,"column":16},"end":{"line":119,"column":39}},"38":{"start":{"line":121,"column":12},"end":{"line":123,"column":13}},"39":{"start":{"line":122,"column":16},"end":{"line":122,"column":45}},"40":{"start":{"line":126,"column":25},"end":{"line":138,"column":9}},"41":{"start":{"line":128,"column":12},"end":{"line":137,"column":23}},"42":{"start":{"line":129,"column":16},"end":{"line":136,"column":17}},"43":{"start":{"line":131,"column":20},"end":{"line":131,"column":39}},"44":{"start":{"line":133,"column":20},"end":{"line":133,"column":51}},"45":{"start":{"line":134,"column":20},"end":{"line":134,"column":62}},"46":{"start":{"line":135,"column":20},"end":{"line":135,"column":31}},"47":{"start":{"line":141,"column":8},"end":{"line":143,"column":9}},"48":{"start":{"line":142,"column":12},"end":{"line":142,"column":41}},"49":{"start":{"line":57,"column":0},"end":{"line":145,"column":1}},"50":{"start":{"line":154,"column":4},"end":{"line":167,"column":7}},"51":{"start":{"line":155,"column":8},"end":{"line":166,"column":10}},"52":{"start":{"line":157,"column":16},"end":{"line":157,"column":44}},"53":{"start":{"line":160,"column":16},"end":{"line":164,"column":17}},"54":{"start":{"line":161,"column":20},"end":{"line":161,"column":34}},"55":{"start":{"line":163,"column":20},"end":{"line":163,"column":72}},"56":{"start":{"line":177,"column":22},"end":{"line":177,"column":86}},"57":{"start":{"line":178,"column":4},"end":{"line":178,"column":40}},"58":{"start":{"line":176,"column":0},"end":{"line":179,"column":1}},"59":{"start":{"line":188,"column":22},"end":{"line":188,"column":68}},"60":{"start":{"line":189,"column":4},"end":{"line":189,"column":40}},"61":{"start":{"line":187,"column":0},"end":{"line":190,"column":1}}},"fnMap":{"1":{"name":"(anonymous_0)","line":35,"loc":{"start":{"line":35,"column":82},"end":{"line":39,"column":1}}},"2":{"name":"(anonymous_1)","line":36,"loc":{"start":{"line":36,"column":39},"end":{"line":38,"column":5}}},"3":{"name":"raw","line":57,"loc":{"start":{"line":57,"column":57},"end":{"line":145,"column":1}}},"4":{"name":"(anonymous_3)","line":58,"loc":{"start":{"line":58,"column":39},"end":{"line":144,"column":5}}},"5":{"name":"(anonymous_4)","line":78,"loc":{"start":{"line":78,"column":42},"end":{"line":106,"column":9}}},"6":{"name":"(anonymous_5)","line":83,"loc":{"start":{"line":83,"column":30},"end":{"line":88,"column":21}}},"7":{"name":"(anonymous_6)","line":89,"loc":{"start":{"line":89,"column":25},"end":{"line":98,"column":21}}},"8":{"name":"(anonymous_7)","line":108,"loc":{"start":{"line":108,"column":25},"end":{"line":124,"column":9}}},"9":{"name":"(anonymous_8)","line":126,"loc":{"start":{"line":126,"column":39},"end":{"line":138,"column":9}}},"10":{"name":"(anonymous_9)","line":128,"loc":{"start":{"line":128,"column":70},"end":{"line":137,"column":13}}},"11":{"name":"executeRaw","line":153,"loc":{"start":{"line":153,"column":56},"end":{"line":168,"column":1}}},"12":{"name":"(anonymous_11)","line":154,"loc":{"start":{"line":154,"column":39},"end":{"line":167,"column":5}}},"13":{"name":"(anonymous_12)","line":156,"loc":{"start":{"line":156,"column":30},"end":{"line":158,"column":13}}},"14":{"name":"(anonymous_13)","line":159,"loc":{"start":{"line":159,"column":37},"end":{"line":165,"column":13}}},"15":{"name":"sync","line":176,"loc":{"start":{"line":176,"column":58},"end":{"line":179,"column":1}}},"16":{"name":"all","line":187,"loc":{"start":{"line":187,"column":57},"end":{"line":190,"column":1}}}},"branchMap":{"1":{"line":72,"type":"if","locations":[{"start":{"line":72,"column":8},"end":{"line":74,"column":9}},{"start":{"line":72,"column":8},"end":{"line":74,"column":9}}]},"2":{"line":81,"type":"if","locations":[{"start":{"line":81,"column":12},"end":{"line":105,"column":13}},{"start":{"line":81,"column":12},"end":{"line":105,"column":13}}]},"3":{"line":93,"type":"if","locations":[{"start":{"line":93,"column":24},"end":{"line":96,"column":25}},{"start":{"line":93,"column":24},"end":{"line":96,"column":25}}]},"4":{"line":110,"type":"if","locations":[{"start":{"line":110,"column":12},"end":{"line":112,"column":13}},{"start":{"line":110,"column":12},"end":{"line":112,"column":13}}]},"5":{"line":115,"type":"if","locations":[{"start":{"line":115,"column":12},"end":{"line":117,"column":13}},{"start":{"line":115,"column":12},"end":{"line":117,"column":13}}]},"6":{"line":118,"type":"if","locations":[{"start":{"line":118,"column":12},"end":{"line":120,"column":13}},{"start":{"line":118,"column":12},"end":{"line":120,"column":13}}]},"7":{"line":121,"type":"if","locations":[{"start":{"line":121,"column":12},"end":{"line":123,"column":13}},{"start":{"line":121,"column":12},"end":{"line":123,"column":13}}]},"8":{"line":129,"type":"if","locations":[{"start":{"line":129,"column":16},"end":{"line":136,"column":17}},{"start":{"line":129,"column":16},"end":{"line":136,"column":17}}]},"9":{"line":160,"type":"if","locations":[{"start":{"line":160,"column":16},"end":{"line":164,"column":17}},{"start":{"line":160,"column":16},"end":{"line":164,"column":17}}]}},"s":{"1":1,"2":1,"3":71,"4":71,"5":1,"6":19,"7":19,"8":19,"9":19,"10":1,"11":18,"12":18,"13":18,"14":81,"15":81,"16":78,"17":56,"18":56,"19":56,"20":56,"21":22,"22":22,"23":22,"24":22,"25":7,"26":7,"27":15,"28":3,"29":3,"30":18,"31":75,"32":8,"33":67,"34":67,"35":5,"36":67,"37":11,"38":56,"39":26,"40":18,"41":86,"42":85,"43":81,"44":4,"45":4,"46":4,"47":18,"48":60,"49":1,"50":8,"51":8,"52":4,"53":4,"54":2,"55":2,"56":4,"57":4,"58":1,"59":4,"60":4,"61":1},"b":{"1":[1,18],"2":[78,3],"3":[7,15],"4":[8,67],"5":[5,62],"6":[11,56],"7":[26,30],"8":[81,4],"9":[2,2]},"f":{"1":71,"2":71,"3":19,"4":19,"5":81,"6":56,"7":22,"8":75,"9":86,"10":85,"11":8,"12":8,"13":4,"14":4,"15":4,"16":4},"code":["const DEFAULT_MAX = 5;\r","\r","export interface Result<T> {\r"," amountDone: number;\r"," amountStarted: number;\r"," amountResolved: number;\r"," amountRejected: number;\r"," amountNextCheckFalsey: number;\r"," rejectedIndexes: number[];\r"," resolvedIndexes: number[];\r"," nextCheckFalseyIndexes: number[];\r"," taskResults: T[];\r","}\r","\r","export interface Options {\r"," maxInProgress?: number;\r"," failFast?: boolean;\r"," progressCallback?: <T>(result: Result<T>) => void;\r"," nextCheck?: nextTaskCheck;\r","}\r","\r","/**\r"," * Default checker which validates if a next task should begin.\r"," * This can be overwritten to write own checks for example checking the amount\r"," * of used ram and waiting till the ram is low enough for a next task.\r"," *\r"," * It should always resolve with a boolean, either `true` to start a next task\r"," * or `false` to stop executing a new task.\r"," *\r"," * If this method rejects, the error will propagate to the caller\r"," * @param status\r"," * @param tasks\r"," * @returns {Promise}\r"," */\r","const defaultNextTaskCheck: nextTaskCheck = <T>(status: Result<T>, tasks: Tasks<T>): Promise<boolean> => {\r"," return new Promise((resolve, reject) => {\r"," resolve(status.amountStarted < tasks.length);\r"," });\r","};\r","\r","const DEFAULT_OPTIONS = {\r"," maxInProgress: DEFAULT_MAX,\r"," failFast: false,\r"," nextCheck: defaultNextTaskCheck\r","};\r","\r","export type Task<T> = () => Promise<T>;\r","export type Tasks<T> = Array<Task<T>>;\r","export type nextTaskCheck = <T>(status: Result<T>, tasks: Tasks<T>) => Promise<boolean>;\r","\r","/**\r"," * Raw throttle function, which can return extra meta data.\r"," * @param tasks required array of tasks to be executed\r"," * @param options Options object\r"," * @returns {Promise}\r"," */\r","export function raw<T>(tasks: Tasks<T>, options?: Options): Promise<Result<T>> {\r"," return new Promise((resolve, reject) => {\r"," const myOptions = Object.assign({}, DEFAULT_OPTIONS, options);\r"," const result: Result<T> = {\r"," amountDone: 0,\r"," amountStarted: 0,\r"," amountResolved: 0,\r"," amountRejected: 0,\r"," amountNextCheckFalsey: 0,\r"," rejectedIndexes: [],\r"," resolvedIndexes: [],\r"," nextCheckFalseyIndexes: [],\r"," taskResults: []\r"," };\r","\r"," if (tasks.length === 0) {\r"," return resolve(result);\r"," }\r","\r"," let failedFast = false;\r"," let currentTaskIndex = 0;\r"," const executeTask = (index: number) => {\r"," result.amountStarted++;\r","\r"," if (typeof tasks[index] === 'function') {\r"," tasks[index]().then(\r"," taskResult => {\r"," result.taskResults[index] = taskResult;\r"," result.resolvedIndexes.push(index);\r"," result.amountResolved++;\r"," taskDone();\r"," },\r"," error => {\r"," result.taskResults[index] = error;\r"," result.rejectedIndexes.push(index);\r"," result.amountRejected++;\r"," if (myOptions.failFast === true) {\r"," failedFast = true;\r"," return reject(result);\r"," }\r"," taskDone();\r"," }\r"," );\r"," } else {\r"," failedFast = true;\r"," return reject(\r"," new Error('tasks[' + index + ']: ' + tasks[index] + ', is supposed to be of type function')\r"," );\r"," }\r"," };\r","\r"," const taskDone = () => {\r"," //make sure no more tasks are spawned when we failedFast\r"," if (failedFast === true) {\r"," return;\r"," }\r","\r"," result.amountDone++;\r"," if (typeof (myOptions as Options).progressCallback === 'function') {\r"," (myOptions as any).progressCallback(result);\r"," }\r"," if (result.amountDone === tasks.length) {\r"," return resolve(result);\r"," }\r"," if (currentTaskIndex < tasks.length) {\r"," nextTask(currentTaskIndex++);\r"," }\r"," };\r","\r"," const nextTask = (index: number) => {\r"," //check if we can execute the next task\r"," myOptions.nextCheck(result, tasks).then(canExecuteNextTask => {\r"," if (canExecuteNextTask === true) {\r"," //execute it\r"," executeTask(index);\r"," } else {\r"," result.amountNextCheckFalsey++;\r"," result.nextCheckFalseyIndexes.push(index);\r"," taskDone();\r"," }\r"," }, reject);\r"," };\r","\r"," //spawn the first X task\r"," for (let i = 0; i < Math.min(myOptions.maxInProgress, tasks.length); i++) {\r"," nextTask(currentTaskIndex++);\r"," }\r"," });\r","}\r","\r","/**\r"," * Executes the raw function, but only return the task array\r"," * @param tasks \r"," * @param options \r"," * @returns {Promise}\r"," */\r","function executeRaw<T>(tasks: Tasks<T>, options: Options): Promise<T[]> {\r"," return new Promise((resolve, reject) => {\r"," raw(tasks, options).then(\r"," (result: Result<T>) => {\r"," resolve(result.taskResults);\r"," },\r"," (error: Error | Result<T>) => {\r"," if (error instanceof Error) {\r"," reject(error);\r"," } else {\r"," reject(error.taskResults[error.rejectedIndexes[0]]);\r"," }\r"," }\r"," );\r"," });\r","}\r","\r","/**\r"," * Simply run all the promises after each other, so in synchronous manner\r"," * @param tasks required array of tasks to be executed\r"," * @param options Options object\r"," * @returns {Promise}\r"," */\r","export function sync<T>(tasks: Tasks<T>, options?: Options): Promise<T[]> {\r"," const myOptions = Object.assign({}, { maxInProgress: 1, failFast: true }, options);\r"," return executeRaw(tasks, myOptions);\r","}\r","\r","/**\r"," * Exposes the same behaviour as Promise.All(), but throttled!\r"," * @param tasks required array of tasks to be executed\r"," * @param options Options object\r"," * @returns {Promise}\r"," */\r","export function all<T>(tasks: Tasks<T>, options?: Options): Promise<T[]> {\r"," const myOptions = Object.assign({}, { failFast: true }, options);\r"," return executeRaw(tasks, myOptions);\r","}\r",""],"l":{"1":1,"35":1,"36":71,"37":71,"41":1,"57":1,"58":19,"59":19,"60":19,"72":19,"73":1,"76":18,"77":18,"78":18,"79":81,"81":81,"82":78,"84":56,"85":56,"86":56,"87":56,"90":22,"91":22,"92":22,"93":22,"94":7,"95":7,"97":15,"101":3,"102":3,"108":18,"110":75,"111":8,"114":67,"115":67,"116":5,"118":67,"119":11,"121":56,"122":26,"126":18,"128":86,"129":85,"131":81,"133":4,"134":4,"135":4,"141":18,"142":60,"154":8,"155":8,"157":4,"160":4,"161":2,"163":2,"176":1,"177":4,"178":4,"187":1,"188":4,"189":4}}} | ||
"/mnt/c/Users/dirk-/Projecten/Promise-parallel-throttle/src/throttle.ts":{"path":"/mnt/c/Users/dirk-/Projecten/Promise-parallel-throttle/src/throttle.ts","statementMap":{"1":{"start":{"line":1,"column":20},"end":{"line":1,"column":21}},"2":{"start":{"line":35,"column":44},"end":{"line":39,"column":1}},"3":{"start":{"line":36,"column":4},"end":{"line":38,"column":7}},"4":{"start":{"line":37,"column":8},"end":{"line":37,"column":53}},"5":{"start":{"line":41,"column":24},"end":{"line":45,"column":1}},"6":{"start":{"line":58,"column":4},"end":{"line":144,"column":7}},"7":{"start":{"line":59,"column":26},"end":{"line":59,"column":69}},"8":{"start":{"line":60,"column":34},"end":{"line":70,"column":9}},"9":{"start":{"line":72,"column":8},"end":{"line":74,"column":9}},"10":{"start":{"line":73,"column":12},"end":{"line":73,"column":35}},"11":{"start":{"line":76,"column":25},"end":{"line":76,"column":30}},"12":{"start":{"line":77,"column":31},"end":{"line":77,"column":32}},"13":{"start":{"line":78,"column":28},"end":{"line":106,"column":9}},"14":{"start":{"line":79,"column":12},"end":{"line":79,"column":35}},"15":{"start":{"line":81,"column":12},"end":{"line":105,"column":13}},"16":{"start":{"line":82,"column":16},"end":{"line":99,"column":18}},"17":{"start":{"line":84,"column":24},"end":{"line":84,"column":63}},"18":{"start":{"line":85,"column":24},"end":{"line":85,"column":59}},"19":{"start":{"line":86,"column":24},"end":{"line":86,"column":48}},"20":{"start":{"line":87,"column":24},"end":{"line":87,"column":35}},"21":{"start":{"line":90,"column":24},"end":{"line":90,"column":58}},"22":{"start":{"line":91,"column":24},"end":{"line":91,"column":59}},"23":{"start":{"line":92,"column":24},"end":{"line":92,"column":48}},"24":{"start":{"line":93,"column":24},"end":{"line":96,"column":25}},"25":{"start":{"line":94,"column":28},"end":{"line":94,"column":46}},"26":{"start":{"line":95,"column":28},"end":{"line":95,"column":50}},"27":{"start":{"line":97,"column":24},"end":{"line":97,"column":35}},"28":{"start":{"line":101,"column":16},"end":{"line":101,"column":34}},"29":{"start":{"line":102,"column":16},"end":{"line":104,"column":18}},"30":{"start":{"line":108,"column":25},"end":{"line":124,"column":9}},"31":{"start":{"line":110,"column":12},"end":{"line":112,"column":13}},"32":{"start":{"line":111,"column":16},"end":{"line":111,"column":23}},"33":{"start":{"line":114,"column":12},"end":{"line":114,"column":32}},"34":{"start":{"line":115,"column":12},"end":{"line":117,"column":13}},"35":{"start":{"line":116,"column":17},"end":{"line":116,"column":60}},"36":{"start":{"line":118,"column":12},"end":{"line":120,"column":13}},"37":{"start":{"line":119,"column":16},"end":{"line":119,"column":39}},"38":{"start":{"line":121,"column":12},"end":{"line":123,"column":13}},"39":{"start":{"line":122,"column":16},"end":{"line":122,"column":45}},"40":{"start":{"line":126,"column":25},"end":{"line":138,"column":9}},"41":{"start":{"line":128,"column":12},"end":{"line":137,"column":23}},"42":{"start":{"line":129,"column":16},"end":{"line":136,"column":17}},"43":{"start":{"line":131,"column":20},"end":{"line":131,"column":39}},"44":{"start":{"line":133,"column":20},"end":{"line":133,"column":51}},"45":{"start":{"line":134,"column":20},"end":{"line":134,"column":62}},"46":{"start":{"line":135,"column":20},"end":{"line":135,"column":31}},"47":{"start":{"line":141,"column":8},"end":{"line":143,"column":9}},"48":{"start":{"line":142,"column":12},"end":{"line":142,"column":41}},"49":{"start":{"line":57,"column":0},"end":{"line":145,"column":1}},"50":{"start":{"line":154,"column":4},"end":{"line":167,"column":7}},"51":{"start":{"line":155,"column":8},"end":{"line":166,"column":10}},"52":{"start":{"line":157,"column":16},"end":{"line":157,"column":44}},"53":{"start":{"line":160,"column":16},"end":{"line":164,"column":17}},"54":{"start":{"line":161,"column":20},"end":{"line":161,"column":34}},"55":{"start":{"line":163,"column":20},"end":{"line":163,"column":72}},"56":{"start":{"line":177,"column":22},"end":{"line":177,"column":86}},"57":{"start":{"line":178,"column":4},"end":{"line":178,"column":40}},"58":{"start":{"line":176,"column":0},"end":{"line":179,"column":1}},"59":{"start":{"line":188,"column":22},"end":{"line":188,"column":68}},"60":{"start":{"line":189,"column":4},"end":{"line":189,"column":40}},"61":{"start":{"line":187,"column":0},"end":{"line":190,"column":1}}},"fnMap":{"1":{"name":"(anonymous_0)","line":35,"loc":{"start":{"line":35,"column":82},"end":{"line":39,"column":1}}},"2":{"name":"(anonymous_1)","line":36,"loc":{"start":{"line":36,"column":39},"end":{"line":38,"column":5}}},"3":{"name":"raw","line":57,"loc":{"start":{"line":57,"column":57},"end":{"line":145,"column":1}}},"4":{"name":"(anonymous_3)","line":58,"loc":{"start":{"line":58,"column":39},"end":{"line":144,"column":5}}},"5":{"name":"(anonymous_4)","line":78,"loc":{"start":{"line":78,"column":42},"end":{"line":106,"column":9}}},"6":{"name":"(anonymous_5)","line":83,"loc":{"start":{"line":83,"column":30},"end":{"line":88,"column":21}}},"7":{"name":"(anonymous_6)","line":89,"loc":{"start":{"line":89,"column":25},"end":{"line":98,"column":21}}},"8":{"name":"(anonymous_7)","line":108,"loc":{"start":{"line":108,"column":25},"end":{"line":124,"column":9}}},"9":{"name":"(anonymous_8)","line":126,"loc":{"start":{"line":126,"column":39},"end":{"line":138,"column":9}}},"10":{"name":"(anonymous_9)","line":128,"loc":{"start":{"line":128,"column":70},"end":{"line":137,"column":13}}},"11":{"name":"executeRaw","line":153,"loc":{"start":{"line":153,"column":56},"end":{"line":168,"column":1}}},"12":{"name":"(anonymous_11)","line":154,"loc":{"start":{"line":154,"column":39},"end":{"line":167,"column":5}}},"13":{"name":"(anonymous_12)","line":156,"loc":{"start":{"line":156,"column":30},"end":{"line":158,"column":13}}},"14":{"name":"(anonymous_13)","line":159,"loc":{"start":{"line":159,"column":37},"end":{"line":165,"column":13}}},"15":{"name":"sync","line":176,"loc":{"start":{"line":176,"column":58},"end":{"line":179,"column":1}}},"16":{"name":"all","line":187,"loc":{"start":{"line":187,"column":57},"end":{"line":190,"column":1}}}},"branchMap":{"1":{"line":72,"type":"if","locations":[{"start":{"line":72,"column":8},"end":{"line":74,"column":9}},{"start":{"line":72,"column":8},"end":{"line":74,"column":9}}]},"2":{"line":81,"type":"if","locations":[{"start":{"line":81,"column":12},"end":{"line":105,"column":13}},{"start":{"line":81,"column":12},"end":{"line":105,"column":13}}]},"3":{"line":93,"type":"if","locations":[{"start":{"line":93,"column":24},"end":{"line":96,"column":25}},{"start":{"line":93,"column":24},"end":{"line":96,"column":25}}]},"4":{"line":110,"type":"if","locations":[{"start":{"line":110,"column":12},"end":{"line":112,"column":13}},{"start":{"line":110,"column":12},"end":{"line":112,"column":13}}]},"5":{"line":115,"type":"if","locations":[{"start":{"line":115,"column":12},"end":{"line":117,"column":13}},{"start":{"line":115,"column":12},"end":{"line":117,"column":13}}]},"6":{"line":118,"type":"if","locations":[{"start":{"line":118,"column":12},"end":{"line":120,"column":13}},{"start":{"line":118,"column":12},"end":{"line":120,"column":13}}]},"7":{"line":121,"type":"if","locations":[{"start":{"line":121,"column":12},"end":{"line":123,"column":13}},{"start":{"line":121,"column":12},"end":{"line":123,"column":13}}]},"8":{"line":129,"type":"if","locations":[{"start":{"line":129,"column":16},"end":{"line":136,"column":17}},{"start":{"line":129,"column":16},"end":{"line":136,"column":17}}]},"9":{"line":160,"type":"if","locations":[{"start":{"line":160,"column":16},"end":{"line":164,"column":17}},{"start":{"line":160,"column":16},"end":{"line":164,"column":17}}]}},"s":{"1":1,"2":1,"3":71,"4":71,"5":1,"6":19,"7":19,"8":19,"9":19,"10":1,"11":18,"12":18,"13":18,"14":81,"15":81,"16":78,"17":56,"18":56,"19":56,"20":56,"21":22,"22":22,"23":22,"24":22,"25":7,"26":7,"27":15,"28":3,"29":3,"30":18,"31":75,"32":8,"33":67,"34":67,"35":5,"36":67,"37":11,"38":56,"39":26,"40":18,"41":86,"42":85,"43":81,"44":4,"45":4,"46":4,"47":18,"48":60,"49":1,"50":8,"51":8,"52":4,"53":4,"54":2,"55":2,"56":4,"57":4,"58":1,"59":4,"60":4,"61":1},"b":{"1":[1,18],"2":[78,3],"3":[7,15],"4":[8,67],"5":[5,62],"6":[11,56],"7":[26,30],"8":[81,4],"9":[2,2]},"f":{"1":71,"2":71,"3":19,"4":19,"5":81,"6":56,"7":22,"8":75,"9":86,"10":85,"11":8,"12":8,"13":4,"14":4,"15":4,"16":4},"code":["const DEFAULT_MAX = 5;\r","\r","export interface Result<T> {\r"," amountDone: number;\r"," amountStarted: number;\r"," amountResolved: number;\r"," amountRejected: number;\r"," amountNextCheckFalsey: number;\r"," rejectedIndexes: number[];\r"," resolvedIndexes: number[];\r"," nextCheckFalseyIndexes: number[];\r"," taskResults: T[];\r","}\r","\r","export interface Options {\r"," maxInProgress?: number;\r"," failFast?: boolean;\r"," progressCallback?: <T>(result: Result<T>) => void;\r"," nextCheck?: nextTaskCheck;\r","}\r","\r","/**\r"," * Default checker which validates if a next task should begin.\r"," * This can be overwritten to write own checks for example checking the amount\r"," * of used ram and waiting till the ram is low enough for a next task.\r"," *\r"," * It should always resolve with a boolean, either `true` to start a next task\r"," * or `false` to stop executing a new task.\r"," *\r"," * If this method rejects, the error will propagate to the caller\r"," * @param status\r"," * @param tasks\r"," * @returns {Promise}\r"," */\r","const defaultNextTaskCheck: nextTaskCheck = <T>(status: Result<T>, tasks: Tasks<T>): Promise<boolean> => {\r"," return new Promise((resolve, reject) => {\r"," resolve(status.amountStarted < tasks.length);\r"," });\r","};\r","\r","const DEFAULT_OPTIONS = {\r"," maxInProgress: DEFAULT_MAX,\r"," failFast: false,\r"," nextCheck: defaultNextTaskCheck\r","};\r","\r","export type Task<T> = () => Promise<T>;\r","export type Tasks<T> = Array<Task<T>>;\r","export type nextTaskCheck = <T>(status: Result<T>, tasks: Tasks<T>) => Promise<boolean>;\r","\r","/**\r"," * Raw throttle function, which can return extra meta data.\r"," * @param tasks required array of tasks to be executed\r"," * @param options Options object\r"," * @returns {Promise}\r"," */\r","export function raw<T>(tasks: Tasks<T>, options?: Options): Promise<Result<T>> {\r"," return new Promise((resolve, reject) => {\r"," const myOptions = Object.assign({}, DEFAULT_OPTIONS, options);\r"," const result: Result<T> = {\r"," amountDone: 0,\r"," amountStarted: 0,\r"," amountResolved: 0,\r"," amountRejected: 0,\r"," amountNextCheckFalsey: 0,\r"," rejectedIndexes: [],\r"," resolvedIndexes: [],\r"," nextCheckFalseyIndexes: [],\r"," taskResults: []\r"," };\r","\r"," if (tasks.length === 0) {\r"," return resolve(result);\r"," }\r","\r"," let failedFast = false;\r"," let currentTaskIndex = 0;\r"," const executeTask = (index: number) => {\r"," result.amountStarted++;\r","\r"," if (typeof tasks[index] === 'function') {\r"," tasks[index]().then(\r"," taskResult => {\r"," result.taskResults[index] = taskResult;\r"," result.resolvedIndexes.push(index);\r"," result.amountResolved++;\r"," taskDone();\r"," },\r"," error => {\r"," result.taskResults[index] = error;\r"," result.rejectedIndexes.push(index);\r"," result.amountRejected++;\r"," if (myOptions.failFast === true) {\r"," failedFast = true;\r"," return reject(result);\r"," }\r"," taskDone();\r"," }\r"," );\r"," } else {\r"," failedFast = true;\r"," return reject(\r"," new Error('tasks[' + index + ']: ' + tasks[index] + ', is supposed to be of type function')\r"," );\r"," }\r"," };\r","\r"," const taskDone = () => {\r"," //make sure no more tasks are spawned when we failedFast\r"," if (failedFast === true) {\r"," return;\r"," }\r","\r"," result.amountDone++;\r"," if (typeof (myOptions as Options).progressCallback === 'function') {\r"," (myOptions as any).progressCallback(result);\r"," }\r"," if (result.amountDone === tasks.length) {\r"," return resolve(result);\r"," }\r"," if (currentTaskIndex < tasks.length) {\r"," nextTask(currentTaskIndex++);\r"," }\r"," };\r","\r"," const nextTask = (index: number) => {\r"," //check if we can execute the next task\r"," myOptions.nextCheck(result, tasks).then(canExecuteNextTask => {\r"," if (canExecuteNextTask === true) {\r"," //execute it\r"," executeTask(index);\r"," } else {\r"," result.amountNextCheckFalsey++;\r"," result.nextCheckFalseyIndexes.push(index);\r"," taskDone();\r"," }\r"," }, reject);\r"," };\r","\r"," //spawn the first X task\r"," for (let i = 0; i < Math.min(myOptions.maxInProgress, tasks.length); i++) {\r"," nextTask(currentTaskIndex++);\r"," }\r"," });\r","}\r","\r","/**\r"," * Executes the raw function, but only return the task array\r"," * @param tasks \r"," * @param options \r"," * @returns {Promise}\r"," */\r","function executeRaw<T>(tasks: Tasks<T>, options: Options): Promise<T[]> {\r"," return new Promise((resolve, reject) => {\r"," raw(tasks, options).then(\r"," (result: Result<T>) => {\r"," resolve(result.taskResults);\r"," },\r"," (error: Error | Result<T>) => {\r"," if (error instanceof Error) {\r"," reject(error);\r"," } else {\r"," reject(error.taskResults[error.rejectedIndexes[0]]);\r"," }\r"," }\r"," );\r"," });\r","}\r","\r","/**\r"," * Simply run all the promises after each other, so in synchronous manner\r"," * @param tasks required array of tasks to be executed\r"," * @param options Options object\r"," * @returns {Promise}\r"," */\r","export function sync<T>(tasks: Tasks<T>, options?: Options): Promise<T[]> {\r"," const myOptions = Object.assign({}, { maxInProgress: 1, failFast: true }, options);\r"," return executeRaw(tasks, myOptions);\r","}\r","\r","/**\r"," * Exposes the same behaviour as Promise.All(), but throttled!\r"," * @param tasks required array of tasks to be executed\r"," * @param options Options object\r"," * @returns {Promise}\r"," */\r","export function all<T>(tasks: Tasks<T>, options?: Options): Promise<T[]> {\r"," const myOptions = Object.assign({}, { failFast: true }, options);\r"," return executeRaw(tasks, myOptions);\r","}\r",""],"l":{"1":1,"35":1,"36":71,"37":71,"41":1,"57":1,"58":19,"59":19,"60":19,"72":19,"73":1,"76":18,"77":18,"78":18,"79":81,"81":81,"82":78,"84":56,"85":56,"86":56,"87":56,"90":22,"91":22,"92":22,"93":22,"94":7,"95":7,"97":15,"101":3,"102":3,"108":18,"110":75,"111":8,"114":67,"115":67,"116":5,"118":67,"119":11,"121":56,"122":26,"126":18,"128":86,"129":85,"131":81,"133":4,"134":4,"135":4,"141":18,"142":60,"154":8,"155":8,"157":4,"160":4,"161":2,"163":2,"176":1,"177":4,"178":4,"187":1,"188":4,"189":4}}} |
{ | ||
"name": "promise-parallel-throttle", | ||
"version": "3.1.0", | ||
"keywords": ["promise", "async", "parallel", "throttle", "promise.all()", "sync", "synchronously"], | ||
"version": "3.2.0", | ||
"keywords": [ | ||
"promise", | ||
"async", | ||
"parallel", | ||
"throttle", | ||
"promise.all()", | ||
"sync", | ||
"synchronously" | ||
], | ||
"description": "Run promises in parallel, but throttled", | ||
@@ -16,3 +24,3 @@ "main": "build/throttle.js", | ||
"lint:fix": "tslint -p ./tsconfig.json --fix", | ||
"prettier": "prettier --write \"src/**/*.ts*\"" | ||
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,css,scss,md,graphl}\" --ignore-path .gitignore" | ||
}, | ||
@@ -32,31 +40,38 @@ "repository": { | ||
"transform": { | ||
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js" | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
"testResultsProcessor": "<rootDir>/node_modules/ts-jest/coverageprocessor.js", | ||
"testRegex": "(/tests/.*|\\.(test|spec))\\.(ts|tsx|js)$", | ||
"moduleFileExtensions": ["ts", "tsx", "js"] | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"jsx", | ||
"json", | ||
"node" | ||
] | ||
}, | ||
"lint-staged": { | ||
"*.{ts,js}": ["prettier --write", "tslint -c ./tslint.json", "git add"] | ||
"*.{ts,tsx}": [ | ||
"prettier --write", | ||
"tslint -c ./tslint.json --fix", | ||
"git add" | ||
], | ||
"*.{json,css,scss,md,graphl,js,jsx}": [ | ||
"prettier --write", | ||
"git add" | ||
] | ||
}, | ||
"prettier": { | ||
"printWidth": 120, | ||
"tabWidth": 4, | ||
"singleQuote": true, | ||
"jsxBracketSameLine": true, | ||
"bracketSpacing": true | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^19.2.2", | ||
"@types/node": "^6.0.46", | ||
"@types/jest": "^23.3.1", | ||
"@types/node": "^10.7.1", | ||
"husky": "^0.14.3", | ||
"jest": "^19.0.2", | ||
"lint-staged": "^4.2.3", | ||
"prettier": "^1.7.2", | ||
"ts-jest": "^19.0.14", | ||
"tslint": "^5.1.0", | ||
"tslint-config-prettier": "^1.5.0", | ||
"tslint-eslint-rules": "^4.1.1", | ||
"typescript": "^2.6.1" | ||
"jest": "^23.5.0", | ||
"lint-staged": "^7.2.2", | ||
"prettier": "^1.14.2", | ||
"ts-jest": "^23.1.3", | ||
"tslint": "^5.11.0", | ||
"tslint-config-prettier": "^1.15.0", | ||
"tslint-eslint-rules": "^5.4.0", | ||
"typescript": "^3.0.1" | ||
} | ||
} |
# Promise-parallel-throttle | ||
[![Build Status](https://travis-ci.org/DJWassink/Promise-parallel-throttle.svg?branch=master)](https://travis-ci.org/DJWassink/Promise-parallel-throttle) | ||
[![npm version](https://badge.fury.io/js/promise-parallel-throttle.svg)](https://badge.fury.io/js/promise-parallel-throttle) | ||
[![npm downloads](https://img.shields.io/npm/dm/promise-parallel-throttle.svg)](https://www.npmjs.com/package/promise-parallel-throttle) | ||
[![Bundlephobia](https://img.shields.io/badge/dynamic/json.svg?label=minified%20size&url=https%3A%2F%2Fbundlephobia.com%2Fapi%2Fsize%3Fpackage%3Dpromise-parallel-throttle%26record%3Dtrue&query=size&suffix=%20bytes&colorB=%230a7bbc)](https://bundlephobia.com/result?p=promise-parallel-throttle) | ||
[![Bundlephobia](https://img.shields.io/badge/dynamic/json.svg?label=minzipped%20size&url=https%3A%2F%2Fbundlephobia.com%2Fapi%2Fsize%3Fpackage%3Dpromise-parallel-throttle%26record%3Dtrue&query=gzip&suffix=%20bytes&colorB=%230a7bbc)](https://bundlephobia.com/result?p=promise-parallel-throttle) | ||
Run a array of Promises in parallel. Kinda like Promise.all(), but throttled! | ||
## Install | ||
## Install | ||
### NPM | ||
```bash | ||
@@ -14,2 +20,3 @@ npm i promise-parallel-throttle -S | ||
### Yarn | ||
```bash | ||
@@ -22,3 +29,3 @@ yarn add promise-parallel-throttle | ||
```js | ||
import Throttle from 'promise-parallel-throttle'; | ||
import * as Throttle from 'promise-parallel-throttle'; | ||
@@ -28,9 +35,6 @@ //Function which should return a Promise | ||
//Do something async. | ||
return firstName + " " + lastName; | ||
} | ||
return firstName + ' ' + lastName; | ||
}; | ||
const users = [ | ||
{firstName: "Irene", lastName: "Pullman"}, | ||
{firstName: "Sean", lastName: "Parr"} | ||
]; | ||
const users = [{firstName: 'Irene', lastName: 'Pullman'}, {firstName: 'Sean', lastName: 'Parr'}]; | ||
@@ -46,4 +50,8 @@ //Queue with functions to be run | ||
[![Edit Promise-parallel-throttle example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/4x1943m2v7) | ||
## API | ||
### Throttle.all | ||
`Throttle.all(tasks, options)` | ||
@@ -55,41 +63,48 @@ | ||
### Throttle.sync | ||
`Throttle.sync(tasks, options)` | ||
Throttle.sync runs all the tasks synchronously. | ||
Once again the tasks array is required, the [options](#options-object) are optional. | ||
Throttle.sync runs all the tasks synchronously. | ||
Once again the tasks array is required, the [options](#options-object) are optional. | ||
Be aware that this method is simply a wrapper to pass `maxInProgress` with 1. So overwriting this option in the options object would run the tasks again in parallel. | ||
### Throttle.raw | ||
`Throttle.raw(tasks, options)` | ||
The raw method instead of returning the tasks their results, will return a [result](#result-object--progress-callback) object. | ||
Useful if you wan't more statistics about the execution of your tasks. Once again the tasks are required while the [options](#options-object) are optional. | ||
The raw method instead of returning the tasks their results, will return a [result](#result-object--progress-callback) object. | ||
Useful if you wan't more statistics about the execution of your tasks. Once again the tasks are required while the [options](#options-object) are optional. | ||
#### Option's Object | ||
|Parameter|Type|Default|Definition| | ||
|:---|:---|:---|:---| | ||
|maxInProgress |Integer|5| max amount of parallel threads| | ||
|failFast |Boolean|true (false for the [raw](#throttleraw) method)| reject after a single error, or keep running| | ||
|progressCallback |Function|Optional| callback with progress reports| | ||
|nextCheck |Function|Optional| function which should return a promise, if the promise resolved true the next task is spawn, errors will propagate and should be handled in the calling code| | ||
| Parameter | Type | Default | Definition | | ||
| :-------------------- | :------- | :---------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| maxInProgress | Integer | 5 | max amount of parallel threads | | ||
| failFast | Boolean | true (false for the [raw](#throttleraw) method) | reject after a single error, or keep running | | ||
| progressCallback | Function | Optional | callback with progress reports | | ||
| nextCheck | Function | Optional | function which should return a promise, if the promise resolved true the next task is spawn, errors will propagate and should be handled in the calling code | | ||
| ignoreIsFunctionCheck | Boolean | false | If one of the tasks is not a function an error is thrown, if this boolean is set to true we simply return the task itself | | ||
#### Result object / Progress callback | ||
The `progressCallback` and the `Raw` will return a `Result` object with the following properties: | ||
|Property|Type|Start value|Definition| | ||
|:---|:---|:---|:---| | ||
|amountDone|Integer|0|amount of tasks which are finished| | ||
|amountStarted|Integer|0|amount of tasks which started| | ||
|amountResolved|Integer|0|amount of tasks which successfully resolved| | ||
|amountRejected|Integer|0|amount of tasks which returned in an error and are aborted| | ||
|amountNextCheckFalsey|Integer|0|amount of tasks which got a falsey value in the [nextCheck](#nextcheck)| | ||
|rejectedIndexes|Array|[]|all the indexes in the tasks array where the promise rejected| | ||
|resolvedIndexes|Array|[]|all the indexes in the tasks array where the promise resolved| | ||
|nextCheckFalseyIndexes|Array|[]|all the indexes in the tasks array where the [nextCheck](#nextcheck) returned a falsey value| | ||
|taskResults|Array|[]|array containing the result of every task| | ||
| Property | Type | Start value | Definition | | ||
| :--------------------- | :------ | :---------- | :------------------------------------------------------------------------------------------- | | ||
| amountDone | Integer | 0 | amount of tasks which are finished | | ||
| amountStarted | Integer | 0 | amount of tasks which started | | ||
| amountResolved | Integer | 0 | amount of tasks which successfully resolved | | ||
| amountRejected | Integer | 0 | amount of tasks which returned in an error and are aborted | | ||
| amountNextCheckFalsey | Integer | 0 | amount of tasks which got a falsey value in the [nextCheck](#nextcheck) | | ||
| rejectedIndexes | Array | [] | all the indexes in the tasks array where the promise rejected | | ||
| resolvedIndexes | Array | [] | all the indexes in the tasks array where the promise resolved | | ||
| nextCheckFalseyIndexes | Array | [] | all the indexes in the tasks array where the [nextCheck](#nextcheck) returned a falsey value | | ||
| taskResults | Array | [] | array containing the result of every task | | ||
#### nextCheck | ||
All the `Throttle` methods have a `nextCheck` method which will be used to verify if a next task is allowed to start. | ||
All the `Throttle` methods have a `nextCheck` method which will be used to verify if a next task is allowed to start. | ||
The default `nextCheck` is defined like this; | ||
```js | ||
@@ -100,3 +115,3 @@ const defaultNextTaskCheck = (status, tasks) => { | ||
}); | ||
} | ||
}; | ||
``` | ||
@@ -114,2 +129,3 @@ | ||
## Example | ||
Check out the example's directory, it's heavily documented so it should be easy to follow. | ||
@@ -120,2 +136,3 @@ | ||
Simply run the example with npm: | ||
``` | ||
@@ -126,4 +143,5 @@ npm run-script names | ||
Or with Yarn: | ||
``` | ||
yarn names | ||
``` |
{ | ||
"compilerOptions": { | ||
"outDir": "./build", | ||
"sourceMap": true, | ||
"moduleResolution": "node", | ||
"module": "commonjs", | ||
"target": "es5", | ||
"lib": ["es6"], | ||
"strict": true | ||
}, | ||
"files": [ | ||
"./src/throttle.ts" | ||
] | ||
} | ||
"compilerOptions": { | ||
"outDir": "./build", | ||
"sourceMap": true, | ||
"moduleResolution": "node", | ||
"module": "commonjs", | ||
"target": "es5", | ||
"lib": ["es6"], | ||
"strict": true | ||
}, | ||
"files": ["./src/throttle.ts"] | ||
} |
@@ -6,3 +6,2 @@ { | ||
"object-literal-sort-keys": false, | ||
"ordered-imports": false, | ||
"member-ordering": false, | ||
@@ -19,4 +18,19 @@ "variable-name": [true, "allow-leading-underscore", "allow-pascal-case"], | ||
"object-literal-shorthand": false, | ||
"no-console": [true, "log"] | ||
"no-var-requires": false, | ||
"no-misused-new": false, | ||
"prefer-for-of": true, | ||
"promise-function-async": true, | ||
"await-promise": true, | ||
"no-floating-promises": true, | ||
"no-console": [true, "log", "error"], | ||
"ordered-imports": [ | ||
true, | ||
{ | ||
"import-sources-order": "case-insensitive", | ||
"grouped-imports": true, | ||
"named-imports-order": "case-insensitive", | ||
"module-source-path": "basename" | ||
} | ||
] | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
307621
32
1297
139