promise-parallel-throttle
Advanced tools
Comparing version 2.4.0 to 2.5.0
@@ -106,6 +106,3 @@ "use strict"; | ||
return new Promise(function (resolve, reject) { | ||
if (status.amountStarted < tasks.length) { | ||
return resolve(true); | ||
} | ||
resolve(false); | ||
resolve(status.amountStarted < tasks.length); | ||
}); | ||
@@ -127,3 +124,10 @@ }; | ||
resolve(result.taskResults); | ||
}, reject); | ||
}, function (error) { | ||
if (error instanceof Error) { | ||
reject(error); | ||
} | ||
else { | ||
reject(error.taskResults[error.rejectedIndexes[0]]); | ||
} | ||
}); | ||
}); | ||
@@ -148,3 +152,10 @@ } | ||
resolve(result.taskResults); | ||
}, reject); | ||
}, function (error) { | ||
if (error instanceof Error) { | ||
reject(error); | ||
} | ||
else { | ||
reject(error.taskResults[error.rejectedIndexes[0]]); | ||
} | ||
}); | ||
}); | ||
@@ -151,0 +162,0 @@ } |
@@ -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":14,"column":4},"end":{"line":14,"column":66}},"5":{"start":{"line":14,"column":36},"end":{"line":14,"column":64}},"6":{"start":{"line":15,"column":4},"end":{"line":15,"column":50}},"7":{"start":{"line":15,"column":31},"end":{"line":15,"column":48}},"8":{"start":{"line":16,"column":4},"end":{"line":16,"column":67}},"9":{"start":{"line":16,"column":32},"end":{"line":16,"column":65}},"10":{"start":{"line":17,"column":4},"end":{"line":85,"column":7}},"11":{"start":{"line":18,"column":21},"end":{"line":26,"column":9}},"12":{"start":{"line":27,"column":8},"end":{"line":29,"column":9}},"13":{"start":{"line":28,"column":12},"end":{"line":28,"column":35}},"14":{"start":{"line":30,"column":25},"end":{"line":30,"column":30}},"15":{"start":{"line":31,"column":26},"end":{"line":54,"column":9}},"16":{"start":{"line":32,"column":12},"end":{"line":53,"column":13}},"17":{"start":{"line":33,"column":16},"end":{"line":48,"column":19}},"18":{"start":{"line":35,"column":20},"end":{"line":35,"column":59}},"19":{"start":{"line":36,"column":20},"end":{"line":36,"column":55}},"20":{"start":{"line":37,"column":20},"end":{"line":37,"column":44}},"21":{"start":{"line":38,"column":20},"end":{"line":38,"column":31}},"22":{"start":{"line":40,"column":20},"end":{"line":40,"column":54}},"23":{"start":{"line":41,"column":20},"end":{"line":41,"column":55}},"24":{"start":{"line":42,"column":20},"end":{"line":42,"column":44}},"25":{"start":{"line":43,"column":20},"end":{"line":46,"column":21}},"26":{"start":{"line":44,"column":24},"end":{"line":44,"column":42}},"27":{"start":{"line":45,"column":24},"end":{"line":45,"column":46}},"28":{"start":{"line":47,"column":20},"end":{"line":47,"column":31}},"29":{"start":{"line":51,"column":16},"end":{"line":51,"column":34}},"30":{"start":{"line":52,"column":16},"end":{"line":52,"column":123}},"31":{"start":{"line":55,"column":23},"end":{"line":70,"column":9}},"32":{"start":{"line":57,"column":12},"end":{"line":59,"column":13}},"33":{"start":{"line":58,"column":16},"end":{"line":58,"column":23}},"34":{"start":{"line":60,"column":12},"end":{"line":60,"column":32}},"35":{"start":{"line":61,"column":12},"end":{"line":63,"column":13}},"36":{"start":{"line":62,"column":16},"end":{"line":62,"column":41}},"37":{"start":{"line":64,"column":12},"end":{"line":66,"column":13}},"38":{"start":{"line":65,"column":16},"end":{"line":65,"column":39}},"39":{"start":{"line":67,"column":12},"end":{"line":69,"column":13}},"40":{"start":{"line":68,"column":16},"end":{"line":68,"column":27}},"41":{"start":{"line":71,"column":23},"end":{"line":80,"column":9}},"42":{"start":{"line":73,"column":12},"end":{"line":79,"column":23}},"43":{"start":{"line":75,"column":16},"end":{"line":78,"column":17}},"44":{"start":{"line":77,"column":20},"end":{"line":77,"column":56}},"45":{"start":{"line":82,"column":8},"end":{"line":84,"column":9}},"46":{"start":{"line":83,"column":12},"end":{"line":83,"column":23}},"47":{"start":{"line":87,"column":0},"end":{"line":87,"column":18}},"48":{"start":{"line":101,"column":27},"end":{"line":110,"column":1}},"49":{"start":{"line":102,"column":4},"end":{"line":109,"column":7}},"50":{"start":{"line":103,"column":8},"end":{"line":106,"column":9}},"51":{"start":{"line":104,"column":12},"end":{"line":104,"column":33}},"52":{"start":{"line":105,"column":12},"end":{"line":105,"column":33}},"53":{"start":{"line":107,"column":8},"end":{"line":107,"column":30}},"54":{"start":{"line":108,"column":8},"end":{"line":108,"column":23}},"55":{"start":{"line":119,"column":4},"end":{"line":119,"column":49}},"56":{"start":{"line":119,"column":31},"end":{"line":119,"column":47}},"57":{"start":{"line":120,"column":4},"end":{"line":120,"column":67}},"58":{"start":{"line":120,"column":32},"end":{"line":120,"column":65}},"59":{"start":{"line":121,"column":4},"end":{"line":126,"column":7}},"60":{"start":{"line":122,"column":8},"end":{"line":125,"column":19}},"61":{"start":{"line":124,"column":12},"end":{"line":124,"column":40}},"62":{"start":{"line":128,"column":0},"end":{"line":128,"column":20}},"63":{"start":{"line":138,"column":4},"end":{"line":138,"column":66}},"64":{"start":{"line":138,"column":36},"end":{"line":138,"column":64}},"65":{"start":{"line":139,"column":4},"end":{"line":139,"column":49}},"66":{"start":{"line":139,"column":31},"end":{"line":139,"column":47}},"67":{"start":{"line":140,"column":4},"end":{"line":140,"column":67}},"68":{"start":{"line":140,"column":32},"end":{"line":140,"column":65}},"69":{"start":{"line":141,"column":4},"end":{"line":146,"column":7}},"70":{"start":{"line":142,"column":8},"end":{"line":145,"column":19}},"71":{"start":{"line":144,"column":12},"end":{"line":144,"column":40}},"72":{"start":{"line":148,"column":0},"end":{"line":148,"column":18}}},"fnMap":{"0":{"name":"raw","decl":{"start":{"line":13,"column":9},"end":{"line":13,"column":12}},"loc":{"start":{"line":13,"column":74},"end":{"line":86,"column":1}},"line":13},"1":{"name":"(anonymous_1)","decl":{"start":{"line":17,"column":23},"end":{"line":17,"column":24}},"loc":{"start":{"line":17,"column":50},"end":{"line":85,"column":5}},"line":17},"2":{"name":"(anonymous_2)","decl":{"start":{"line":31,"column":26},"end":{"line":31,"column":27}},"loc":{"start":{"line":31,"column":43},"end":{"line":54,"column":9}},"line":31},"3":{"name":"(anonymous_3)","decl":{"start":{"line":34,"column":26},"end":{"line":34,"column":27}},"loc":{"start":{"line":34,"column":48},"end":{"line":39,"column":17}},"line":34},"4":{"name":"(anonymous_4)","decl":{"start":{"line":39,"column":19},"end":{"line":39,"column":20}},"loc":{"start":{"line":39,"column":36},"end":{"line":48,"column":17}},"line":39},"5":{"name":"(anonymous_5)","decl":{"start":{"line":55,"column":23},"end":{"line":55,"column":24}},"loc":{"start":{"line":55,"column":35},"end":{"line":70,"column":9}},"line":55},"6":{"name":"(anonymous_6)","decl":{"start":{"line":71,"column":23},"end":{"line":71,"column":24}},"loc":{"start":{"line":71,"column":35},"end":{"line":80,"column":9}},"line":71},"7":{"name":"(anonymous_7)","decl":{"start":{"line":74,"column":22},"end":{"line":74,"column":23}},"loc":{"start":{"line":74,"column":52},"end":{"line":79,"column":13}},"line":74},"8":{"name":"(anonymous_8)","decl":{"start":{"line":101,"column":27},"end":{"line":101,"column":28}},"loc":{"start":{"line":101,"column":52},"end":{"line":110,"column":1}},"line":101},"9":{"name":"(anonymous_9)","decl":{"start":{"line":102,"column":23},"end":{"line":102,"column":24}},"loc":{"start":{"line":102,"column":50},"end":{"line":109,"column":5}},"line":102},"10":{"name":"sync","decl":{"start":{"line":118,"column":9},"end":{"line":118,"column":13}},"loc":{"start":{"line":118,"column":60},"end":{"line":127,"column":1}},"line":118},"11":{"name":"(anonymous_11)","decl":{"start":{"line":121,"column":23},"end":{"line":121,"column":24}},"loc":{"start":{"line":121,"column":50},"end":{"line":126,"column":5}},"line":121},"12":{"name":"(anonymous_12)","decl":{"start":{"line":123,"column":18},"end":{"line":123,"column":19}},"loc":{"start":{"line":123,"column":36},"end":{"line":125,"column":9}},"line":123},"13":{"name":"all","decl":{"start":{"line":137,"column":9},"end":{"line":137,"column":12}},"loc":{"start":{"line":137,"column":74},"end":{"line":147,"column":1}},"line":137},"14":{"name":"(anonymous_14)","decl":{"start":{"line":141,"column":23},"end":{"line":141,"column":24}},"loc":{"start":{"line":141,"column":50},"end":{"line":146,"column":5}},"line":141},"15":{"name":"(anonymous_15)","decl":{"start":{"line":143,"column":18},"end":{"line":143,"column":19}},"loc":{"start":{"line":143,"column":36},"end":{"line":145,"column":9}},"line":143}},"branchMap":{"0":{"loc":{"start":{"line":14,"column":4},"end":{"line":14,"column":66}},"type":"if","locations":[{"start":{"line":14,"column":4},"end":{"line":14,"column":66}},{"start":{"line":14,"column":4},"end":{"line":14,"column":66}}],"line":14},"1":{"loc":{"start":{"line":15,"column":4},"end":{"line":15,"column":50}},"type":"if","locations":[{"start":{"line":15,"column":4},"end":{"line":15,"column":50}},{"start":{"line":15,"column":4},"end":{"line":15,"column":50}}],"line":15},"2":{"loc":{"start":{"line":16,"column":4},"end":{"line":16,"column":67}},"type":"if","locations":[{"start":{"line":16,"column":4},"end":{"line":16,"column":67}},{"start":{"line":16,"column":4},"end":{"line":16,"column":67}}],"line":16},"3":{"loc":{"start":{"line":27,"column":8},"end":{"line":29,"column":9}},"type":"if","locations":[{"start":{"line":27,"column":8},"end":{"line":29,"column":9}},{"start":{"line":27,"column":8},"end":{"line":29,"column":9}}],"line":27},"4":{"loc":{"start":{"line":32,"column":12},"end":{"line":53,"column":13}},"type":"if","locations":[{"start":{"line":32,"column":12},"end":{"line":53,"column":13}},{"start":{"line":32,"column":12},"end":{"line":53,"column":13}}],"line":32},"5":{"loc":{"start":{"line":43,"column":20},"end":{"line":46,"column":21}},"type":"if","locations":[{"start":{"line":43,"column":20},"end":{"line":46,"column":21}},{"start":{"line":43,"column":20},"end":{"line":46,"column":21}}],"line":43},"6":{"loc":{"start":{"line":57,"column":12},"end":{"line":59,"column":13}},"type":"if","locations":[{"start":{"line":57,"column":12},"end":{"line":59,"column":13}},{"start":{"line":57,"column":12},"end":{"line":59,"column":13}}],"line":57},"7":{"loc":{"start":{"line":61,"column":12},"end":{"line":63,"column":13}},"type":"if","locations":[{"start":{"line":61,"column":12},"end":{"line":63,"column":13}},{"start":{"line":61,"column":12},"end":{"line":63,"column":13}}],"line":61},"8":{"loc":{"start":{"line":64,"column":12},"end":{"line":66,"column":13}},"type":"if","locations":[{"start":{"line":64,"column":12},"end":{"line":66,"column":13}},{"start":{"line":64,"column":12},"end":{"line":66,"column":13}}],"line":64},"9":{"loc":{"start":{"line":67,"column":12},"end":{"line":69,"column":13}},"type":"if","locations":[{"start":{"line":67,"column":12},"end":{"line":69,"column":13}},{"start":{"line":67,"column":12},"end":{"line":69,"column":13}}],"line":67},"10":{"loc":{"start":{"line":75,"column":16},"end":{"line":78,"column":17}},"type":"if","locations":[{"start":{"line":75,"column":16},"end":{"line":78,"column":17}},{"start":{"line":75,"column":16},"end":{"line":78,"column":17}}],"line":75},"11":{"loc":{"start":{"line":103,"column":8},"end":{"line":106,"column":9}},"type":"if","locations":[{"start":{"line":103,"column":8},"end":{"line":106,"column":9}},{"start":{"line":103,"column":8},"end":{"line":106,"column":9}}],"line":103},"12":{"loc":{"start":{"line":119,"column":4},"end":{"line":119,"column":49}},"type":"if","locations":[{"start":{"line":119,"column":4},"end":{"line":119,"column":49}},{"start":{"line":119,"column":4},"end":{"line":119,"column":49}}],"line":119},"13":{"loc":{"start":{"line":120,"column":4},"end":{"line":120,"column":67}},"type":"if","locations":[{"start":{"line":120,"column":4},"end":{"line":120,"column":67}},{"start":{"line":120,"column":4},"end":{"line":120,"column":67}}],"line":120},"14":{"loc":{"start":{"line":138,"column":4},"end":{"line":138,"column":66}},"type":"if","locations":[{"start":{"line":138,"column":4},"end":{"line":138,"column":66}},{"start":{"line":138,"column":4},"end":{"line":138,"column":66}}],"line":138},"15":{"loc":{"start":{"line":139,"column":4},"end":{"line":139,"column":49}},"type":"if","locations":[{"start":{"line":139,"column":4},"end":{"line":139,"column":49}},{"start":{"line":139,"column":4},"end":{"line":139,"column":49}}],"line":139},"16":{"loc":{"start":{"line":140,"column":4},"end":{"line":140,"column":67}},"type":"if","locations":[{"start":{"line":140,"column":4},"end":{"line":140,"column":67}},{"start":{"line":140,"column":4},"end":{"line":140,"column":67}}],"line":140}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":0,"14":1,"15":1,"16":10,"17":9,"18":9,"19":9,"20":9,"21":9,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":1,"30":1,"31":1,"32":9,"33":4,"34":5,"35":5,"36":0,"37":5,"38":0,"39":5,"40":5,"41":1,"42":10,"43":10,"44":10,"45":1,"46":5,"47":1,"48":1,"49":10,"50":10,"51":10,"52":10,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":1,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":1},"f":{"0":1,"1":1,"2":10,"3":9,"4":0,"5":9,"6":10,"7":10,"8":10,"9":10,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0},"b":{"0":[1,0],"1":[1,0],"2":[1,0],"3":[0,1],"4":[9,1],"5":[0,0],"6":[4,5],"7":[0,5],"8":[0,5],"9":[5,0],"10":[10,0],"11":[10,0],"12":[0,0],"13":[0,0],"14":[0,0],"15":[0,0],"16":[0,0]},"inputSourceMap":{"version":3,"file":"throttle.js","sourceRoot":"","sources":["file:////mnt/d/Projecten/Promise-parallel-throttle/src/throttle.ts"],"names":[],"mappings":";;AAAA,IAAM,WAAW,GAAG,CAAC,CAAC;AAgBtB;;;;;;;;GAQG;AACH,aAAuB,KAAe,EACf,aAA2B,EAC3B,QAAgB,EAChB,gBAA8C,EAC9C,SAAgC;IAHhC,8BAAA,EAAA,2BAA2B;IAC3B,yBAAA,EAAA,gBAAgB;IAEhB,0BA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AAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,CAAC;aAC3D,IAAI,CAAC,UAAC,MAAiB;YACpB,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAChC,CAAC,EAAE,MAAM,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACP,CAAC;AAXD,kBAWC","sourcesContent":["const DEFAULT_MAX = 5;\n\nexport interface Result<T> {\n amountDone: number;\n amountStarted: number;\n amountResolved: number;\n amountRejected: number;\n rejectedIndexes: number[];\n resolvedIndexes: number[];\n taskResults: T[];\n}\n\nexport type Task<T> = () => Promise<T>;\nexport type Tasks<T> = Array<Task<T>>;\nexport type nextTaskCheck = <T>(status: Result<T>, tasks: Tasks<T>) => Promise<boolean>;\n\n/**\n * Raw throttle function, which can return extra meta data.\n * @param tasks array[] of functions\n * @param maxInProgress integer with the max amount of tasks to be run in parallel\n * @param failFast boolean if true, do fail-fast behaviour (see Promise.all() documentation)\n * @param progressCallback function which can be used to see the progress\n * @param nextCheck\n * @returns {Promise}\n */\nexport function raw<T>(tasks: Tasks<T>,\n maxInProgress = DEFAULT_MAX,\n failFast = false,\n progressCallback?: (result: Result<T>) => void,\n nextCheck = defaultNextTaskCheck): Promise<Result<T>> {\n return new Promise((resolve, reject) => {\n const result: Result<T> = {\n amountDone: 0,\n amountStarted: 0,\n amountResolved: 0,\n amountRejected: 0,\n rejectedIndexes: [],\n resolvedIndexes: [],\n taskResults: []\n };\n\n if (tasks.length === 0) {\n return resolve(result);\n }\n\n let failedFast = false;\n const executeTask = (index: number) => {\n if (typeof tasks[index] === 'function') {\n tasks[index]()\n .then((taskResult: T) => {\n result.taskResults[index] = taskResult;\n result.resolvedIndexes.push(index);\n result.amountResolved++;\n taskDone();\n }, error => {\n result.taskResults[index] = error;\n result.rejectedIndexes.push(index);\n result.amountRejected++;\n if (failFast) {\n failedFast = true;\n return reject(result);\n }\n taskDone();\n });\n } else {\n failedFast = true;\n return reject(new Error('tasks[' + index + ']: ' + tasks[index] + ', is supposed to be of type function'));\n }\n };\n\n const taskDone = () => {\n //make sure no more tasks are spawned when we failedFast\n if (failedFast) {\n return;\n }\n\n result.amountDone++;\n if (progressCallback) {\n progressCallback(result);\n }\n if (result.amountDone === tasks.length) {\n return resolve(result);\n }\n if (result.amountStarted !== tasks.length) {\n nextTask();\n }\n };\n\n const nextTask = () => {\n //check if we can execute the next task\n nextCheck(result, tasks)\n .then(canExecuteNextTask => {\n if (canExecuteNextTask === true) {\n //execute it\n executeTask(result.amountStarted++);\n }\n }, reject);\n };\n\n //spawn the first X task\n for (let i = 0; i < Math.min(maxInProgress, tasks.length); i++) {\n nextTask();\n }\n });\n}\n\n/**\n * Default checker which validates if a next task should begin.\n * This can be overwritten to write own checks for example checking the amount\n * of used ram and waiting till the ram is low enough for a next task.\n *\n * It should always resolve with a boolean, either `true` to start a next task\n * or `false` to stop executing a new task.\n *\n * If this method rejects, the error will propagate to the caller\n * @param status\n * @param tasks\n * @returns {Promise}\n */\nconst defaultNextTaskCheck: nextTaskCheck = <T>(status: Result<T>, tasks: Tasks<T>): Promise<boolean> => {\n return new Promise((resolve, reject) => {\n if (status.amountStarted < tasks.length) {\n console.warn('true');\n return resolve(true);\n }\n console.warn('false');\n resolve(false);\n });\n};\n\n/**\n * Simply run all the promises after each other, so in synchronous manner\n * @param tasks required array of tasks to be executed\n * @param failFast optional boolean if we directly reject on a single error defaults to true\n * @param progressCallback optional function to be run to get status updates\n * @param nextCheck function which should return a promise, when resolved the next task will spawn\n */\nexport function sync<T>(tasks: Tasks<T>,\n failFast = true,\n progressCallback?: () => void,\n nextCheck = defaultNextTaskCheck): Promise<T[]> {\n return new Promise((resolve, reject) => {\n raw(tasks, 1, failFast, progressCallback, nextCheck)\n .then((result: Result<T>) => {\n resolve(result.taskResults);\n }, reject);\n });\n}\n\n/**\n * Exposes the same behaviour as Promise.All(), but throttled!\n * @param tasks required array of tasks to be executed\n * @param maxInProgress optional integer max amount of parallel tasks to be run defaults to 5\n * @param failFast optional boolean if we directly reject on a single error defaults to true\n * @param progressCallback optional function to be run to get status updates\n * @param nextCheck function which should return a promise, when resolved the next task will spawn\n */\nexport function all<T>(tasks: Tasks<T>,\n maxInProgress = DEFAULT_MAX,\n failFast = true,\n progressCallback?: () => void,\n nextCheck = defaultNextTaskCheck): Promise<T[]> {\n return new Promise((resolve, reject) => {\n raw(tasks, maxInProgress, failFast, progressCallback, nextCheck)\n .then((result: Result<T>) => {\n resolve(result.taskResults);\n }, reject);\n });\n}\n"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"7273c069ecc9d1dc7ebc4c8653a82a49d119a402"} | ||
{"/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":14,"column":4},"end":{"line":14,"column":66}},"5":{"start":{"line":14,"column":36},"end":{"line":14,"column":64}},"6":{"start":{"line":15,"column":4},"end":{"line":15,"column":50}},"7":{"start":{"line":15,"column":31},"end":{"line":15,"column":48}},"8":{"start":{"line":16,"column":4},"end":{"line":16,"column":67}},"9":{"start":{"line":16,"column":32},"end":{"line":16,"column":65}},"10":{"start":{"line":17,"column":4},"end":{"line":88,"column":7}},"11":{"start":{"line":18,"column":21},"end":{"line":26,"column":9}},"12":{"start":{"line":27,"column":8},"end":{"line":29,"column":9}},"13":{"start":{"line":28,"column":12},"end":{"line":28,"column":35}},"14":{"start":{"line":30,"column":25},"end":{"line":30,"column":30}},"15":{"start":{"line":31,"column":27},"end":{"line":31,"column":28}},"16":{"start":{"line":32,"column":26},"end":{"line":55,"column":9}},"17":{"start":{"line":33,"column":12},"end":{"line":54,"column":13}},"18":{"start":{"line":34,"column":16},"end":{"line":49,"column":19}},"19":{"start":{"line":36,"column":20},"end":{"line":36,"column":59}},"20":{"start":{"line":37,"column":20},"end":{"line":37,"column":55}},"21":{"start":{"line":38,"column":20},"end":{"line":38,"column":44}},"22":{"start":{"line":39,"column":20},"end":{"line":39,"column":31}},"23":{"start":{"line":41,"column":20},"end":{"line":41,"column":54}},"24":{"start":{"line":42,"column":20},"end":{"line":42,"column":55}},"25":{"start":{"line":43,"column":20},"end":{"line":43,"column":44}},"26":{"start":{"line":44,"column":20},"end":{"line":47,"column":21}},"27":{"start":{"line":45,"column":24},"end":{"line":45,"column":42}},"28":{"start":{"line":46,"column":24},"end":{"line":46,"column":46}},"29":{"start":{"line":48,"column":20},"end":{"line":48,"column":31}},"30":{"start":{"line":52,"column":16},"end":{"line":52,"column":34}},"31":{"start":{"line":53,"column":16},"end":{"line":53,"column":123}},"32":{"start":{"line":56,"column":23},"end":{"line":72,"column":9}},"33":{"start":{"line":58,"column":12},"end":{"line":60,"column":13}},"34":{"start":{"line":59,"column":16},"end":{"line":59,"column":23}},"35":{"start":{"line":61,"column":12},"end":{"line":61,"column":32}},"36":{"start":{"line":62,"column":12},"end":{"line":64,"column":13}},"37":{"start":{"line":63,"column":16},"end":{"line":63,"column":41}},"38":{"start":{"line":65,"column":12},"end":{"line":67,"column":13}},"39":{"start":{"line":66,"column":16},"end":{"line":66,"column":39}},"40":{"start":{"line":68,"column":12},"end":{"line":71,"column":13}},"41":{"start":{"line":69,"column":16},"end":{"line":69,"column":31}},"42":{"start":{"line":70,"column":16},"end":{"line":70,"column":27}},"43":{"start":{"line":73,"column":23},"end":{"line":82,"column":9}},"44":{"start":{"line":75,"column":12},"end":{"line":81,"column":23}},"45":{"start":{"line":77,"column":16},"end":{"line":80,"column":17}},"46":{"start":{"line":79,"column":20},"end":{"line":79,"column":56}},"47":{"start":{"line":84,"column":8},"end":{"line":87,"column":9}},"48":{"start":{"line":85,"column":12},"end":{"line":85,"column":27}},"49":{"start":{"line":86,"column":12},"end":{"line":86,"column":23}},"50":{"start":{"line":90,"column":0},"end":{"line":90,"column":18}},"51":{"start":{"line":104,"column":27},"end":{"line":108,"column":1}},"52":{"start":{"line":105,"column":4},"end":{"line":107,"column":7}},"53":{"start":{"line":106,"column":8},"end":{"line":106,"column":53}},"54":{"start":{"line":117,"column":4},"end":{"line":117,"column":49}},"55":{"start":{"line":117,"column":31},"end":{"line":117,"column":47}},"56":{"start":{"line":118,"column":4},"end":{"line":118,"column":67}},"57":{"start":{"line":118,"column":32},"end":{"line":118,"column":65}},"58":{"start":{"line":119,"column":4},"end":{"line":131,"column":7}},"59":{"start":{"line":120,"column":8},"end":{"line":130,"column":11}},"60":{"start":{"line":122,"column":12},"end":{"line":122,"column":40}},"61":{"start":{"line":124,"column":12},"end":{"line":129,"column":13}},"62":{"start":{"line":125,"column":16},"end":{"line":125,"column":30}},"63":{"start":{"line":128,"column":16},"end":{"line":128,"column":68}},"64":{"start":{"line":133,"column":0},"end":{"line":133,"column":20}},"65":{"start":{"line":143,"column":4},"end":{"line":143,"column":66}},"66":{"start":{"line":143,"column":36},"end":{"line":143,"column":64}},"67":{"start":{"line":144,"column":4},"end":{"line":144,"column":49}},"68":{"start":{"line":144,"column":31},"end":{"line":144,"column":47}},"69":{"start":{"line":145,"column":4},"end":{"line":145,"column":67}},"70":{"start":{"line":145,"column":32},"end":{"line":145,"column":65}},"71":{"start":{"line":146,"column":4},"end":{"line":158,"column":7}},"72":{"start":{"line":147,"column":8},"end":{"line":157,"column":11}},"73":{"start":{"line":149,"column":12},"end":{"line":149,"column":40}},"74":{"start":{"line":151,"column":12},"end":{"line":156,"column":13}},"75":{"start":{"line":152,"column":16},"end":{"line":152,"column":30}},"76":{"start":{"line":155,"column":16},"end":{"line":155,"column":68}},"77":{"start":{"line":160,"column":0},"end":{"line":160,"column":18}}},"fnMap":{"0":{"name":"raw","decl":{"start":{"line":13,"column":9},"end":{"line":13,"column":12}},"loc":{"start":{"line":13,"column":74},"end":{"line":89,"column":1}},"line":13},"1":{"name":"(anonymous_1)","decl":{"start":{"line":17,"column":23},"end":{"line":17,"column":24}},"loc":{"start":{"line":17,"column":50},"end":{"line":88,"column":5}},"line":17},"2":{"name":"(anonymous_2)","decl":{"start":{"line":32,"column":26},"end":{"line":32,"column":27}},"loc":{"start":{"line":32,"column":43},"end":{"line":55,"column":9}},"line":32},"3":{"name":"(anonymous_3)","decl":{"start":{"line":35,"column":26},"end":{"line":35,"column":27}},"loc":{"start":{"line":35,"column":48},"end":{"line":40,"column":17}},"line":35},"4":{"name":"(anonymous_4)","decl":{"start":{"line":40,"column":19},"end":{"line":40,"column":20}},"loc":{"start":{"line":40,"column":36},"end":{"line":49,"column":17}},"line":40},"5":{"name":"(anonymous_5)","decl":{"start":{"line":56,"column":23},"end":{"line":56,"column":24}},"loc":{"start":{"line":56,"column":35},"end":{"line":72,"column":9}},"line":56},"6":{"name":"(anonymous_6)","decl":{"start":{"line":73,"column":23},"end":{"line":73,"column":24}},"loc":{"start":{"line":73,"column":35},"end":{"line":82,"column":9}},"line":73},"7":{"name":"(anonymous_7)","decl":{"start":{"line":76,"column":22},"end":{"line":76,"column":23}},"loc":{"start":{"line":76,"column":52},"end":{"line":81,"column":13}},"line":76},"8":{"name":"(anonymous_8)","decl":{"start":{"line":104,"column":27},"end":{"line":104,"column":28}},"loc":{"start":{"line":104,"column":52},"end":{"line":108,"column":1}},"line":104},"9":{"name":"(anonymous_9)","decl":{"start":{"line":105,"column":23},"end":{"line":105,"column":24}},"loc":{"start":{"line":105,"column":50},"end":{"line":107,"column":5}},"line":105},"10":{"name":"sync","decl":{"start":{"line":116,"column":9},"end":{"line":116,"column":13}},"loc":{"start":{"line":116,"column":60},"end":{"line":132,"column":1}},"line":116},"11":{"name":"(anonymous_11)","decl":{"start":{"line":119,"column":23},"end":{"line":119,"column":24}},"loc":{"start":{"line":119,"column":50},"end":{"line":131,"column":5}},"line":119},"12":{"name":"(anonymous_12)","decl":{"start":{"line":121,"column":18},"end":{"line":121,"column":19}},"loc":{"start":{"line":121,"column":36},"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":"all","decl":{"start":{"line":142,"column":9},"end":{"line":142,"column":12}},"loc":{"start":{"line":142,"column":74},"end":{"line":159,"column":1}},"line":142},"15":{"name":"(anonymous_15)","decl":{"start":{"line":146,"column":23},"end":{"line":146,"column":24}},"loc":{"start":{"line":146,"column":50},"end":{"line":158,"column":5}},"line":146},"16":{"name":"(anonymous_16)","decl":{"start":{"line":148,"column":18},"end":{"line":148,"column":19}},"loc":{"start":{"line":148,"column":36},"end":{"line":150,"column":9}},"line":148},"17":{"name":"(anonymous_17)","decl":{"start":{"line":150,"column":11},"end":{"line":150,"column":12}},"loc":{"start":{"line":150,"column":28},"end":{"line":157,"column":9}},"line":150}},"branchMap":{"0":{"loc":{"start":{"line":14,"column":4},"end":{"line":14,"column":66}},"type":"if","locations":[{"start":{"line":14,"column":4},"end":{"line":14,"column":66}},{"start":{"line":14,"column":4},"end":{"line":14,"column":66}}],"line":14},"1":{"loc":{"start":{"line":15,"column":4},"end":{"line":15,"column":50}},"type":"if","locations":[{"start":{"line":15,"column":4},"end":{"line":15,"column":50}},{"start":{"line":15,"column":4},"end":{"line":15,"column":50}}],"line":15},"2":{"loc":{"start":{"line":16,"column":4},"end":{"line":16,"column":67}},"type":"if","locations":[{"start":{"line":16,"column":4},"end":{"line":16,"column":67}},{"start":{"line":16,"column":4},"end":{"line":16,"column":67}}],"line":16},"3":{"loc":{"start":{"line":27,"column":8},"end":{"line":29,"column":9}},"type":"if","locations":[{"start":{"line":27,"column":8},"end":{"line":29,"column":9}},{"start":{"line":27,"column":8},"end":{"line":29,"column":9}}],"line":27},"4":{"loc":{"start":{"line":33,"column":12},"end":{"line":54,"column":13}},"type":"if","locations":[{"start":{"line":33,"column":12},"end":{"line":54,"column":13}},{"start":{"line":33,"column":12},"end":{"line":54,"column":13}}],"line":33},"5":{"loc":{"start":{"line":44,"column":20},"end":{"line":47,"column":21}},"type":"if","locations":[{"start":{"line":44,"column":20},"end":{"line":47,"column":21}},{"start":{"line":44,"column":20},"end":{"line":47,"column":21}}],"line":44},"6":{"loc":{"start":{"line":58,"column":12},"end":{"line":60,"column":13}},"type":"if","locations":[{"start":{"line":58,"column":12},"end":{"line":60,"column":13}},{"start":{"line":58,"column":12},"end":{"line":60,"column":13}}],"line":58},"7":{"loc":{"start":{"line":62,"column":12},"end":{"line":64,"column":13}},"type":"if","locations":[{"start":{"line":62,"column":12},"end":{"line":64,"column":13}},{"start":{"line":62,"column":12},"end":{"line":64,"column":13}}],"line":62},"8":{"loc":{"start":{"line":65,"column":12},"end":{"line":67,"column":13}},"type":"if","locations":[{"start":{"line":65,"column":12},"end":{"line":67,"column":13}},{"start":{"line":65,"column":12},"end":{"line":67,"column":13}}],"line":65},"9":{"loc":{"start":{"line":68,"column":12},"end":{"line":71,"column":13}},"type":"if","locations":[{"start":{"line":68,"column":12},"end":{"line":71,"column":13}},{"start":{"line":68,"column":12},"end":{"line":71,"column":13}}],"line":68},"10":{"loc":{"start":{"line":77,"column":16},"end":{"line":80,"column":17}},"type":"if","locations":[{"start":{"line":77,"column":16},"end":{"line":80,"column":17}},{"start":{"line":77,"column":16},"end":{"line":80,"column":17}}],"line":77},"11":{"loc":{"start":{"line":117,"column":4},"end":{"line":117,"column":49}},"type":"if","locations":[{"start":{"line":117,"column":4},"end":{"line":117,"column":49}},{"start":{"line":117,"column":4},"end":{"line":117,"column":49}}],"line":117},"12":{"loc":{"start":{"line":118,"column":4},"end":{"line":118,"column":67}},"type":"if","locations":[{"start":{"line":118,"column":4},"end":{"line":118,"column":67}},{"start":{"line":118,"column":4},"end":{"line":118,"column":67}}],"line":118},"13":{"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},"14":{"loc":{"start":{"line":143,"column":4},"end":{"line":143,"column":66}},"type":"if","locations":[{"start":{"line":143,"column":4},"end":{"line":143,"column":66}},{"start":{"line":143,"column":4},"end":{"line":143,"column":66}}],"line":143},"15":{"loc":{"start":{"line":144,"column":4},"end":{"line":144,"column":49}},"type":"if","locations":[{"start":{"line":144,"column":4},"end":{"line":144,"column":49}},{"start":{"line":144,"column":4},"end":{"line":144,"column":49}}],"line":144},"16":{"loc":{"start":{"line":145,"column":4},"end":{"line":145,"column":67}},"type":"if","locations":[{"start":{"line":145,"column":4},"end":{"line":145,"column":67}},{"start":{"line":145,"column":4},"end":{"line":145,"column":67}}],"line":145},"17":{"loc":{"start":{"line":151,"column":12},"end":{"line":156,"column":13}},"type":"if","locations":[{"start":{"line":151,"column":12},"end":{"line":156,"column":13}},{"start":{"line":151,"column":12},"end":{"line":156,"column":13}}],"line":151}},"s":{"0":1,"1":1,"2":1,"3":1,"4":15,"5":7,"6":15,"7":7,"8":15,"9":8,"10":15,"11":15,"12":15,"13":1,"14":14,"15":14,"16":14,"17":60,"18":57,"19":45,"20":45,"21":45,"22":45,"23":12,"24":12,"25":12,"26":12,"27":7,"28":7,"29":5,"30":3,"31":3,"32":14,"33":50,"34":8,"35":42,"36":42,"37":4,"38":42,"39":7,"40":35,"41":14,"42":14,"43":14,"44":61,"45":60,"46":60,"47":14,"48":47,"49":47,"50":1,"51":1,"52":56,"53":56,"54":3,"55":3,"56":3,"57":3,"58":3,"59":3,"60":1,"61":2,"62":1,"63":1,"64":1,"65":3,"66":3,"67":3,"68":3,"69":3,"70":3,"71":3,"72":3,"73":1,"74":2,"75":1,"76":1,"77":1},"f":{"0":15,"1":15,"2":60,"3":45,"4":12,"5":50,"6":61,"7":60,"8":56,"9":56,"10":3,"11":3,"12":1,"13":2,"14":3,"15":3,"16":1,"17":2},"b":{"0":[7,8],"1":[7,8],"2":[8,7],"3":[1,14],"4":[57,3],"5":[7,5],"6":[8,42],"7":[4,38],"8":[7,35],"9":[14,21],"10":[60,0],"11":[3,0],"12":[3,0],"13":[1,1],"14":[3,0],"15":[3,0],"16":[3,0],"17":[1,1]},"inputSourceMap":{"version":3,"file":"throttle.js","sourceRoot":"","sources":["file:////mnt/d/Projecten/Promise-parallel-throttle/src/throttle.ts"],"names":[],"mappings":";;AAAA,IAAM,WAAW,GAAG,CAAC,CAAC;AAgBtB;;;;;;;;GAQG;AACH,aAAuB,KAAe,EACf,aAA2B,EAC3B,QAAgB,EAChB,gBAA8C,EAC9C,SAAgC;IAHhC,8BAAA,EAAA,2BAA2B;IAC3B,yBAAA,EAAA,gBAAgB;IAEhB,0BAAA,EAAA,gCAAgC;IACnD,MAAM,CAAC,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QAC/B,IAAM,MAAM,GAAc;YACtB,UAAU,EAAE,CAAC;YACb,aAAa,EAAE,CAAC;YAChB,cAAc,EAAE,CAAC;YACjB,cAAc,EAAE,CAAC;YACjB,eAAe,EAAE,EAAE;YACnB,eAAe,EAAE,EAAE;YACnB,WAAW,EAAE,EAAE;SAClB,CAAC;QAEF,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;QAED,IAAI,UAAU,GAAG,KAAK,CAAC;QACvB,IAAI,YAAY,GAAG,CAAC,CAAC;QACrB,IAAM,WAAW,GAAG,UAAC,KAAa;YAC9B,EAAE,CAAC,CAAC,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC;gBACrC,KAAK,CAAC,KAAK,CAAC,EAAE;qBACT,IAAI,CAAC,UAAC,UAAa;oBAChB,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC;oBACvC,MAAM,CAAC,eAAe,CAAC,I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QAChC,CAAC,EAAE,UAAC,KAAsB;YACtB,EAAE,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC;gBACzB,MAAM,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxD,CAAC;QACL,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC;AAhBD,oBAgBC;AAED;;;;;;;GAOG;AACH,aAAuB,KAAe,EACf,aAA2B,EAC3B,QAAe,EACf,gBAA6B,EAC7B,SAAgC;IAHhC,8BAAA,EAAA,2BAA2B;IAC3B,yBAAA,EAAA,eAAe;IAEf,0BAAA,EAAA,gCAAgC;IACnD,MAAM,CAAC,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QAC/B,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,CAAC;aAC3D,IAAI,CAAC,UAAC,MAAiB;YACpB,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAChC,CAAC,EAAE,UAAC,KAAsB;YACtB,EAAE,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC;gBACzB,MAAM,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxD,CAAC;QACL,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC;AAjBD,kBAiBC","sourcesContent":["const DEFAULT_MAX = 5;\n\nexport interface Result<T> {\n amountDone: number;\n amountStarted: number;\n amountResolved: number;\n amountRejected: number;\n rejectedIndexes: number[];\n resolvedIndexes: number[];\n taskResults: T[];\n}\n\nexport type Task<T> = () => Promise<T>;\nexport type Tasks<T> = Array<Task<T>>;\nexport type nextTaskCheck = <T>(status: Result<T>, tasks: Tasks<T>) => Promise<boolean>;\n\n/**\n * Raw throttle function, which can return extra meta data.\n * @param tasks array[] of functions\n * @param maxInProgress integer with the max amount of tasks to be run in parallel\n * @param failFast boolean if true, do fail-fast behaviour (see Promise.all() documentation)\n * @param progressCallback function which can be used to see the progress\n * @param nextCheck\n * @returns {Promise}\n */\nexport function raw<T>(tasks: Tasks<T>,\n maxInProgress = DEFAULT_MAX,\n failFast = false,\n progressCallback?: (result: Result<T>) => void,\n nextCheck = defaultNextTaskCheck): Promise<Result<T>> {\n return new Promise((resolve, reject) => {\n const result: Result<T> = {\n amountDone: 0,\n amountStarted: 0,\n amountResolved: 0,\n amountRejected: 0,\n rejectedIndexes: [],\n resolvedIndexes: [],\n taskResults: []\n };\n\n if (tasks.length === 0) {\n return resolve(result);\n }\n\n let failedFast = false;\n let amountQueued = 0;\n const executeTask = (index: number) => {\n if (typeof tasks[index] === 'function') {\n tasks[index]()\n .then((taskResult: T) => {\n result.taskResults[index] = taskResult;\n result.resolvedIndexes.push(index);\n result.amountResolved++;\n taskDone();\n }, error => {\n result.taskResults[index] = error;\n result.rejectedIndexes.push(index);\n result.amountRejected++;\n if (failFast) {\n failedFast = true;\n return reject(result);\n }\n taskDone();\n });\n } else {\n failedFast = true;\n return reject(new Error('tasks[' + index + ']: ' + tasks[index] + ', is supposed to be of type function'));\n }\n };\n\n const taskDone = () => {\n //make sure no more tasks are spawned when we failedFast\n if (failedFast) {\n return;\n }\n\n result.amountDone++;\n if (progressCallback) {\n progressCallback(result);\n }\n if (result.amountDone === tasks.length) {\n return resolve(result);\n }\n if (amountQueued < tasks.length) {\n amountQueued++;\n nextTask();\n }\n };\n\n const nextTask = () => {\n //check if we can execute the next task\n nextCheck(result, tasks)\n .then(canExecuteNextTask => {\n if (canExecuteNextTask === true) {\n //execute it\n executeTask(result.amountStarted++);\n }\n }, reject);\n };\n\n //spawn the first X task\n for (let i = 0; i < Math.min(maxInProgress, tasks.length); i++) {\n amountQueued++;\n nextTask();\n }\n });\n}\n\n/**\n * Default checker which validates if a next task should begin.\n * This can be overwritten to write own checks for example checking the amount\n * of used ram and waiting till the ram is low enough for a next task.\n *\n * It should always resolve with a boolean, either `true` to start a next task\n * or `false` to stop executing a new task.\n *\n * If this method rejects, the error will propagate to the caller\n * @param status\n * @param tasks\n * @returns {Promise}\n */\nconst defaultNextTaskCheck: nextTaskCheck = <T>(status: Result<T>, tasks: Tasks<T>): Promise<boolean> => {\n return new Promise((resolve, reject) => {\n resolve(status.amountStarted < tasks.length);\n });\n};\n\n/**\n * Simply run all the promises after each other, so in synchronous manner\n * @param tasks required array of tasks to be executed\n * @param failFast optional boolean if we directly reject on a single error defaults to true\n * @param progressCallback optional function to be run to get status updates\n * @param nextCheck function which should return a promise, when resolved the next task will spawn\n */\nexport function sync<T>(tasks: Tasks<T>,\n failFast = true,\n progressCallback?: () => void,\n nextCheck = defaultNextTaskCheck): Promise<T[]> {\n return new Promise((resolve, reject) => {\n raw(tasks, 1, failFast, progressCallback, nextCheck)\n .then((result: Result<T>) => {\n resolve(result.taskResults);\n }, (error: Error|Result<T>) => {\n if (error instanceof Error) {\n reject(error);\n } else {\n reject(error.taskResults[error.rejectedIndexes[0]]);\n }\n });\n });\n}\n\n/**\n * Exposes the same behaviour as Promise.All(), but throttled!\n * @param tasks required array of tasks to be executed\n * @param maxInProgress optional integer max amount of parallel tasks to be run defaults to 5\n * @param failFast optional boolean if we directly reject on a single error defaults to true\n * @param progressCallback optional function to be run to get status updates\n * @param nextCheck function which should return a promise, when resolved the next task will spawn\n */\nexport function all<T>(tasks: Tasks<T>,\n maxInProgress = DEFAULT_MAX,\n failFast = true,\n progressCallback?: () => void,\n nextCheck = defaultNextTaskCheck): Promise<T[]> {\n return new Promise((resolve, reject) => {\n raw(tasks, maxInProgress, failFast, progressCallback, nextCheck)\n .then((result: Result<T>) => {\n resolve(result.taskResults);\n }, (error: Error|Result<T>) => {\n if (error instanceof Error) {\n reject(error);\n } else {\n reject(error.taskResults[error.rejectedIndexes[0]]);\n }\n });\n });\n}\n"]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"2bd824f876f3a4cdd536f3600f65f942615d500c"} | ||
} |
{ | ||
"/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":27,"column":23},"end":{"line":27,"column":50}},"3":{"start":{"line":28,"column":23},"end":{"line":28,"column":39}},"4":{"start":{"line":30,"column":23},"end":{"line":30,"column":55}},"5":{"start":{"line":31,"column":4},"end":{"line":104,"column":7}},"6":{"start":{"line":32,"column":34},"end":{"line":40,"column":9}},"7":{"start":{"line":42,"column":8},"end":{"line":44,"column":9}},"8":{"start":{"line":43,"column":12},"end":{"line":43,"column":35}},"9":{"start":{"line":46,"column":25},"end":{"line":46,"column":30}},"10":{"start":{"line":47,"column":28},"end":{"line":69,"column":9}},"11":{"start":{"line":48,"column":12},"end":{"line":68,"column":13}},"12":{"start":{"line":49,"column":16},"end":{"line":64,"column":23}},"13":{"start":{"line":51,"column":24},"end":{"line":51,"column":63}},"14":{"start":{"line":52,"column":24},"end":{"line":52,"column":59}},"15":{"start":{"line":53,"column":24},"end":{"line":53,"column":48}},"16":{"start":{"line":54,"column":24},"end":{"line":54,"column":35}},"17":{"start":{"line":56,"column":24},"end":{"line":56,"column":58}},"18":{"start":{"line":57,"column":24},"end":{"line":57,"column":59}},"19":{"start":{"line":58,"column":24},"end":{"line":58,"column":48}},"20":{"start":{"line":59,"column":24},"end":{"line":62,"column":25}},"21":{"start":{"line":60,"column":28},"end":{"line":60,"column":46}},"22":{"start":{"line":61,"column":28},"end":{"line":61,"column":50}},"23":{"start":{"line":63,"column":24},"end":{"line":63,"column":35}},"24":{"start":{"line":66,"column":16},"end":{"line":66,"column":34}},"25":{"start":{"line":67,"column":16},"end":{"line":67,"column":123}},"26":{"start":{"line":71,"column":25},"end":{"line":87,"column":9}},"27":{"start":{"line":73,"column":12},"end":{"line":75,"column":13}},"28":{"start":{"line":74,"column":16},"end":{"line":74,"column":23}},"29":{"start":{"line":77,"column":12},"end":{"line":77,"column":32}},"30":{"start":{"line":78,"column":12},"end":{"line":80,"column":13}},"31":{"start":{"line":79,"column":16},"end":{"line":79,"column":41}},"32":{"start":{"line":81,"column":12},"end":{"line":83,"column":13}},"33":{"start":{"line":82,"column":16},"end":{"line":82,"column":39}},"34":{"start":{"line":84,"column":12},"end":{"line":86,"column":13}},"35":{"start":{"line":85,"column":16},"end":{"line":85,"column":27}},"36":{"start":{"line":89,"column":25},"end":{"line":98,"column":9}},"37":{"start":{"line":91,"column":12},"end":{"line":97,"column":27}},"38":{"start":{"line":93,"column":20},"end":{"line":96,"column":21}},"39":{"start":{"line":95,"column":24},"end":{"line":95,"column":60}},"40":{"start":{"line":101,"column":8},"end":{"line":103,"column":9}},"41":{"start":{"line":102,"column":12},"end":{"line":102,"column":23}},"42":{"start":{"line":26,"column":0},"end":{"line":105,"column":1}},"43":{"start":{"line":120,"column":44},"end":{"line":129,"column":1}},"44":{"start":{"line":121,"column":4},"end":{"line":128,"column":7}},"45":{"start":{"line":122,"column":8},"end":{"line":125,"column":9}},"46":{"start":{"line":123,"column":12},"end":{"line":123,"column":33}},"47":{"start":{"line":124,"column":12},"end":{"line":124,"column":33}},"48":{"start":{"line":126,"column":8},"end":{"line":126,"column":30}},"49":{"start":{"line":127,"column":8},"end":{"line":127,"column":23}},"50":{"start":{"line":139,"column":24},"end":{"line":139,"column":39}},"51":{"start":{"line":141,"column":24},"end":{"line":141,"column":56}},"52":{"start":{"line":142,"column":4},"end":{"line":147,"column":7}},"53":{"start":{"line":143,"column":8},"end":{"line":146,"column":23}},"54":{"start":{"line":145,"column":16},"end":{"line":145,"column":44}},"55":{"start":{"line":138,"column":0},"end":{"line":148,"column":1}},"56":{"start":{"line":159,"column":23},"end":{"line":159,"column":50}},"57":{"start":{"line":160,"column":23},"end":{"line":160,"column":38}},"58":{"start":{"line":162,"column":23},"end":{"line":162,"column":55}},"59":{"start":{"line":163,"column":4},"end":{"line":168,"column":7}},"60":{"start":{"line":164,"column":8},"end":{"line":167,"column":23}},"61":{"start":{"line":166,"column":16},"end":{"line":166,"column":44}},"62":{"start":{"line":158,"column":0},"end":{"line":169,"column":1}}},"fnMap":{"1":{"name":"raw","line":30,"loc":{"start":{"line":30,"column":55},"end":{"line":105,"column":1}}},"2":{"name":"(anonymous_1)","line":31,"loc":{"start":{"line":31,"column":39},"end":{"line":104,"column":5}}},"3":{"name":"(anonymous_2)","line":47,"loc":{"start":{"line":47,"column":42},"end":{"line":69,"column":9}}},"4":{"name":"(anonymous_3)","line":50,"loc":{"start":{"line":50,"column":40},"end":{"line":55,"column":21}}},"5":{"name":"(anonymous_4)","line":55,"loc":{"start":{"line":55,"column":28},"end":{"line":64,"column":21}}},"6":{"name":"(anonymous_5)","line":71,"loc":{"start":{"line":71,"column":25},"end":{"line":87,"column":9}}},"7":{"name":"(anonymous_6)","line":89,"loc":{"start":{"line":89,"column":25},"end":{"line":98,"column":9}}},"8":{"name":"(anonymous_7)","line":92,"loc":{"start":{"line":92,"column":40},"end":{"line":97,"column":17}}},"9":{"name":"(anonymous_8)","line":120,"loc":{"start":{"line":120,"column":82},"end":{"line":129,"column":1}}},"10":{"name":"(anonymous_9)","line":121,"loc":{"start":{"line":121,"column":39},"end":{"line":128,"column":5}}},"11":{"name":"sync","line":141,"loc":{"start":{"line":141,"column":56},"end":{"line":148,"column":1}}},"12":{"name":"(anonymous_11)","line":142,"loc":{"start":{"line":142,"column":39},"end":{"line":147,"column":5}}},"13":{"name":"(anonymous_12)","line":144,"loc":{"start":{"line":144,"column":36},"end":{"line":146,"column":13}}},"14":{"name":"all","line":162,"loc":{"start":{"line":162,"column":55},"end":{"line":169,"column":1}}},"15":{"name":"(anonymous_14)","line":163,"loc":{"start":{"line":163,"column":39},"end":{"line":168,"column":5}}},"16":{"name":"(anonymous_15)","line":165,"loc":{"start":{"line":165,"column":36},"end":{"line":167,"column":13}}}},"branchMap":{"1":{"line":27,"type":"if","locations":[{"start":{"line":27,"column":23},"end":{"line":27,"column":50}},{"start":{"line":27,"column":23},"end":{"line":27,"column":50}}]},"2":{"line":28,"type":"if","locations":[{"start":{"line":28,"column":23},"end":{"line":28,"column":39}},{"start":{"line":28,"column":23},"end":{"line":28,"column":39}}]},"3":{"line":30,"type":"if","locations":[{"start":{"line":30,"column":23},"end":{"line":30,"column":55}},{"start":{"line":30,"column":23},"end":{"line":30,"column":55}}]},"4":{"line":42,"type":"if","locations":[{"start":{"line":42,"column":8},"end":{"line":44,"column":9}},{"start":{"line":42,"column":8},"end":{"line":44,"column":9}}]},"5":{"line":48,"type":"if","locations":[{"start":{"line":48,"column":12},"end":{"line":68,"column":13}},{"start":{"line":48,"column":12},"end":{"line":68,"column":13}}]},"6":{"line":59,"type":"if","locations":[{"start":{"line":59,"column":24},"end":{"line":62,"column":25}},{"start":{"line":59,"column":24},"end":{"line":62,"column":25}}]},"7":{"line":73,"type":"if","locations":[{"start":{"line":73,"column":12},"end":{"line":75,"column":13}},{"start":{"line":73,"column":12},"end":{"line":75,"column":13}}]},"8":{"line":78,"type":"if","locations":[{"start":{"line":78,"column":12},"end":{"line":80,"column":13}},{"start":{"line":78,"column":12},"end":{"line":80,"column":13}}]},"9":{"line":81,"type":"if","locations":[{"start":{"line":81,"column":12},"end":{"line":83,"column":13}},{"start":{"line":81,"column":12},"end":{"line":83,"column":13}}]},"10":{"line":84,"type":"if","locations":[{"start":{"line":84,"column":12},"end":{"line":86,"column":13}},{"start":{"line":84,"column":12},"end":{"line":86,"column":13}}]},"11":{"line":93,"type":"if","locations":[{"start":{"line":93,"column":20},"end":{"line":96,"column":21}},{"start":{"line":93,"column":20},"end":{"line":96,"column":21}}]},"12":{"line":122,"type":"if","locations":[{"start":{"line":122,"column":8},"end":{"line":125,"column":9}},{"start":{"line":122,"column":8},"end":{"line":125,"column":9}}]},"13":{"line":139,"type":"if","locations":[{"start":{"line":139,"column":24},"end":{"line":139,"column":39}},{"start":{"line":139,"column":24},"end":{"line":139,"column":39}}]},"14":{"line":141,"type":"if","locations":[{"start":{"line":141,"column":24},"end":{"line":141,"column":56}},{"start":{"line":141,"column":24},"end":{"line":141,"column":56}}]},"15":{"line":159,"type":"if","locations":[{"start":{"line":159,"column":23},"end":{"line":159,"column":50}},{"start":{"line":159,"column":23},"end":{"line":159,"column":50}}]},"16":{"line":160,"type":"if","locations":[{"start":{"line":160,"column":23},"end":{"line":160,"column":38}},{"start":{"line":160,"column":23},"end":{"line":160,"column":38}}]},"17":{"line":162,"type":"if","locations":[{"start":{"line":162,"column":23},"end":{"line":162,"column":55}},{"start":{"line":162,"column":23},"end":{"line":162,"column":55}}]}},"s":{"1":1,"2":2,"3":2,"4":2,"5":1,"6":1,"7":1,"8":0,"9":1,"10":1,"11":10,"12":9,"13":9,"14":9,"15":9,"16":9,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":1,"25":1,"26":1,"27":9,"28":4,"29":5,"30":5,"31":0,"32":5,"33":0,"34":5,"35":5,"36":1,"37":10,"38":10,"39":10,"40":1,"41":5,"42":1,"43":1,"44":10,"45":10,"46":10,"47":10,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":1,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":1},"b":{"1":[1,0],"2":[1,0],"3":[1,0],"4":[0,1],"5":[9,1],"6":[0,0],"7":[4,5],"8":[0,5],"9":[0,5],"10":[5,0],"11":[10,0],"12":[10,0],"13":[0,0],"14":[0,0],"15":[0,0],"16":[0,0],"17":[0,0]},"f":{"1":1,"2":1,"3":10,"4":9,"5":0,"6":9,"7":10,"8":10,"9":10,"10":10,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0},"code":["const DEFAULT_MAX = 5;","","export interface Result<T> {"," amountDone: number;"," amountStarted: number;"," amountResolved: number;"," amountRejected: number;"," rejectedIndexes: number[];"," resolvedIndexes: number[];"," taskResults: T[];","}","","export type Task<T> = () => Promise<T>;","export type Tasks<T> = Array<Task<T>>;","export type nextTaskCheck = <T>(status: Result<T>, tasks: Tasks<T>) => Promise<boolean>;","","/**"," * Raw throttle function, which can return extra meta data."," * @param tasks array[] of functions"," * @param maxInProgress integer with the max amount of tasks to be run in parallel"," * @param failFast boolean if true, do fail-fast behaviour (see Promise.all() documentation)"," * @param progressCallback function which can be used to see the progress"," * @param nextCheck"," * @returns {Promise}"," */","export function raw<T>(tasks: Tasks<T>,"," maxInProgress = DEFAULT_MAX,"," failFast = false,"," progressCallback?: (result: Result<T>) => void,"," nextCheck = defaultNextTaskCheck): Promise<Result<T>> {"," return new Promise((resolve, reject) => {"," const result: Result<T> = {"," amountDone: 0,"," amountStarted: 0,"," amountResolved: 0,"," amountRejected: 0,"," rejectedIndexes: [],"," resolvedIndexes: [],"," taskResults: []"," };",""," if (tasks.length === 0) {"," return resolve(result);"," }",""," let failedFast = false;"," const executeTask = (index: number) => {"," if (typeof tasks[index] === 'function') {"," tasks[index]()"," .then((taskResult: T) => {"," result.taskResults[index] = taskResult;"," result.resolvedIndexes.push(index);"," result.amountResolved++;"," taskDone();"," }, error => {"," result.taskResults[index] = error;"," result.rejectedIndexes.push(index);"," result.amountRejected++;"," if (failFast) {"," failedFast = true;"," return reject(result);"," }"," taskDone();"," });"," } else {"," failedFast = true;"," return reject(new Error('tasks[' + index + ']: ' + tasks[index] + ', is supposed to be of type function'));"," }"," };",""," const taskDone = () => {"," //make sure no more tasks are spawned when we failedFast"," if (failedFast) {"," return;"," }",""," result.amountDone++;"," if (progressCallback) {"," progressCallback(result);"," }"," if (result.amountDone === tasks.length) {"," return resolve(result);"," }"," if (result.amountStarted !== tasks.length) {"," nextTask();"," }"," };",""," const nextTask = () => {"," //check if we can execute the next task"," nextCheck(result, tasks)"," .then(canExecuteNextTask => {"," if (canExecuteNextTask === true) {"," //execute it"," executeTask(result.amountStarted++);"," }"," }, reject);"," };",""," //spawn the first X task"," for (let i = 0; i < Math.min(maxInProgress, tasks.length); i++) {"," nextTask();"," }"," });","}","","/**"," * Default checker which validates if a next task should begin."," * This can be overwritten to write own checks for example checking the amount"," * of used ram and waiting till the ram is low enough for a next task."," *"," * It should always resolve with a boolean, either `true` to start a next task"," * or `false` to stop executing a new task."," *"," * If this method rejects, the error will propagate to the caller"," * @param status"," * @param tasks"," * @returns {Promise}"," */","const defaultNextTaskCheck: nextTaskCheck = <T>(status: Result<T>, tasks: Tasks<T>): Promise<boolean> => {"," return new Promise((resolve, reject) => {"," if (status.amountStarted < tasks.length) {"," console.warn('true');"," return resolve(true);"," }"," console.warn('false');"," resolve(false);"," });","};","","/**"," * Simply run all the promises after each other, so in synchronous manner"," * @param tasks required array of tasks to be executed"," * @param failFast optional boolean if we directly reject on a single error defaults to true"," * @param progressCallback optional function to be run to get status updates"," * @param nextCheck function which should return a promise, when resolved the next task will spawn"," */","export function sync<T>(tasks: Tasks<T>,"," failFast = true,"," progressCallback?: () => void,"," nextCheck = defaultNextTaskCheck): Promise<T[]> {"," return new Promise((resolve, reject) => {"," raw(tasks, 1, failFast, progressCallback, nextCheck)"," .then((result: Result<T>) => {"," resolve(result.taskResults);"," }, reject);"," });","}","","/**"," * Exposes the same behaviour as Promise.All(), but throttled!"," * @param tasks required array of tasks to be executed"," * @param maxInProgress optional integer max amount of parallel tasks to be run defaults to 5"," * @param failFast optional boolean if we directly reject on a single error defaults to true"," * @param progressCallback optional function to be run to get status updates"," * @param nextCheck function which should return a promise, when resolved the next task will spawn"," */","export function all<T>(tasks: Tasks<T>,"," maxInProgress = DEFAULT_MAX,"," failFast = true,"," progressCallback?: () => void,"," nextCheck = defaultNextTaskCheck): Promise<T[]> {"," return new Promise((resolve, reject) => {"," raw(tasks, maxInProgress, failFast, progressCallback, nextCheck)"," .then((result: Result<T>) => {"," resolve(result.taskResults);"," }, reject);"," });","}",""],"l":{"1":1,"26":1,"27":2,"28":2,"30":2,"31":1,"32":1,"42":1,"43":0,"46":1,"47":1,"48":10,"49":9,"51":9,"52":9,"53":9,"54":9,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"63":0,"66":1,"67":1,"71":1,"73":9,"74":4,"77":5,"78":5,"79":0,"81":5,"82":0,"84":5,"85":5,"89":1,"91":10,"93":10,"95":10,"101":1,"102":5,"120":1,"121":10,"122":10,"123":10,"124":10,"126":0,"127":0,"138":1,"139":0,"141":0,"142":0,"143":0,"145":0,"158":1,"159":0,"160":0,"162":0,"163":0,"164":0,"166":0}}} | ||
"/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":27,"column":23},"end":{"line":27,"column":50}},"3":{"start":{"line":28,"column":23},"end":{"line":28,"column":39}},"4":{"start":{"line":30,"column":23},"end":{"line":30,"column":55}},"5":{"start":{"line":31,"column":4},"end":{"line":107,"column":7}},"6":{"start":{"line":32,"column":34},"end":{"line":40,"column":9}},"7":{"start":{"line":42,"column":8},"end":{"line":44,"column":9}},"8":{"start":{"line":43,"column":12},"end":{"line":43,"column":35}},"9":{"start":{"line":46,"column":25},"end":{"line":46,"column":30}},"10":{"start":{"line":47,"column":27},"end":{"line":47,"column":28}},"11":{"start":{"line":48,"column":28},"end":{"line":70,"column":9}},"12":{"start":{"line":49,"column":12},"end":{"line":69,"column":13}},"13":{"start":{"line":50,"column":16},"end":{"line":65,"column":23}},"14":{"start":{"line":52,"column":24},"end":{"line":52,"column":63}},"15":{"start":{"line":53,"column":24},"end":{"line":53,"column":59}},"16":{"start":{"line":54,"column":24},"end":{"line":54,"column":48}},"17":{"start":{"line":55,"column":24},"end":{"line":55,"column":35}},"18":{"start":{"line":57,"column":24},"end":{"line":57,"column":58}},"19":{"start":{"line":58,"column":24},"end":{"line":58,"column":59}},"20":{"start":{"line":59,"column":24},"end":{"line":59,"column":48}},"21":{"start":{"line":60,"column":24},"end":{"line":63,"column":25}},"22":{"start":{"line":61,"column":28},"end":{"line":61,"column":46}},"23":{"start":{"line":62,"column":28},"end":{"line":62,"column":50}},"24":{"start":{"line":64,"column":24},"end":{"line":64,"column":35}},"25":{"start":{"line":67,"column":16},"end":{"line":67,"column":34}},"26":{"start":{"line":68,"column":16},"end":{"line":68,"column":123}},"27":{"start":{"line":72,"column":25},"end":{"line":89,"column":9}},"28":{"start":{"line":74,"column":12},"end":{"line":76,"column":13}},"29":{"start":{"line":75,"column":16},"end":{"line":75,"column":23}},"30":{"start":{"line":78,"column":12},"end":{"line":78,"column":32}},"31":{"start":{"line":79,"column":12},"end":{"line":81,"column":13}},"32":{"start":{"line":80,"column":16},"end":{"line":80,"column":41}},"33":{"start":{"line":82,"column":12},"end":{"line":84,"column":13}},"34":{"start":{"line":83,"column":16},"end":{"line":83,"column":39}},"35":{"start":{"line":85,"column":12},"end":{"line":88,"column":13}},"36":{"start":{"line":86,"column":16},"end":{"line":86,"column":31}},"37":{"start":{"line":87,"column":16},"end":{"line":87,"column":27}},"38":{"start":{"line":91,"column":25},"end":{"line":100,"column":9}},"39":{"start":{"line":93,"column":12},"end":{"line":99,"column":27}},"40":{"start":{"line":95,"column":20},"end":{"line":98,"column":21}},"41":{"start":{"line":97,"column":24},"end":{"line":97,"column":60}},"42":{"start":{"line":103,"column":8},"end":{"line":106,"column":9}},"43":{"start":{"line":104,"column":12},"end":{"line":104,"column":27}},"44":{"start":{"line":105,"column":12},"end":{"line":105,"column":23}},"45":{"start":{"line":26,"column":0},"end":{"line":108,"column":1}},"46":{"start":{"line":123,"column":44},"end":{"line":127,"column":1}},"47":{"start":{"line":124,"column":4},"end":{"line":126,"column":7}},"48":{"start":{"line":125,"column":8},"end":{"line":125,"column":53}},"49":{"start":{"line":137,"column":24},"end":{"line":137,"column":39}},"50":{"start":{"line":139,"column":24},"end":{"line":139,"column":56}},"51":{"start":{"line":140,"column":4},"end":{"line":151,"column":7}},"52":{"start":{"line":141,"column":8},"end":{"line":150,"column":15}},"53":{"start":{"line":143,"column":16},"end":{"line":143,"column":44}},"54":{"start":{"line":145,"column":16},"end":{"line":149,"column":17}},"55":{"start":{"line":146,"column":20},"end":{"line":146,"column":34}},"56":{"start":{"line":148,"column":20},"end":{"line":148,"column":72}},"57":{"start":{"line":136,"column":0},"end":{"line":152,"column":1}},"58":{"start":{"line":163,"column":23},"end":{"line":163,"column":50}},"59":{"start":{"line":164,"column":23},"end":{"line":164,"column":38}},"60":{"start":{"line":166,"column":23},"end":{"line":166,"column":55}},"61":{"start":{"line":167,"column":4},"end":{"line":178,"column":7}},"62":{"start":{"line":168,"column":8},"end":{"line":177,"column":15}},"63":{"start":{"line":170,"column":16},"end":{"line":170,"column":44}},"64":{"start":{"line":172,"column":16},"end":{"line":176,"column":17}},"65":{"start":{"line":173,"column":20},"end":{"line":173,"column":34}},"66":{"start":{"line":175,"column":20},"end":{"line":175,"column":72}},"67":{"start":{"line":162,"column":0},"end":{"line":179,"column":1}}},"fnMap":{"1":{"name":"raw","line":30,"loc":{"start":{"line":30,"column":55},"end":{"line":108,"column":1}}},"2":{"name":"(anonymous_1)","line":31,"loc":{"start":{"line":31,"column":39},"end":{"line":107,"column":5}}},"3":{"name":"(anonymous_2)","line":48,"loc":{"start":{"line":48,"column":42},"end":{"line":70,"column":9}}},"4":{"name":"(anonymous_3)","line":51,"loc":{"start":{"line":51,"column":40},"end":{"line":56,"column":21}}},"5":{"name":"(anonymous_4)","line":56,"loc":{"start":{"line":56,"column":28},"end":{"line":65,"column":21}}},"6":{"name":"(anonymous_5)","line":72,"loc":{"start":{"line":72,"column":25},"end":{"line":89,"column":9}}},"7":{"name":"(anonymous_6)","line":91,"loc":{"start":{"line":91,"column":25},"end":{"line":100,"column":9}}},"8":{"name":"(anonymous_7)","line":94,"loc":{"start":{"line":94,"column":40},"end":{"line":99,"column":17}}},"9":{"name":"(anonymous_8)","line":123,"loc":{"start":{"line":123,"column":82},"end":{"line":127,"column":1}}},"10":{"name":"(anonymous_9)","line":124,"loc":{"start":{"line":124,"column":39},"end":{"line":126,"column":5}}},"11":{"name":"sync","line":139,"loc":{"start":{"line":139,"column":56},"end":{"line":152,"column":1}}},"12":{"name":"(anonymous_11)","line":140,"loc":{"start":{"line":140,"column":39},"end":{"line":151,"column":5}}},"13":{"name":"(anonymous_12)","line":142,"loc":{"start":{"line":142,"column":36},"end":{"line":144,"column":13}}},"14":{"name":"(anonymous_13)","line":144,"loc":{"start":{"line":144,"column":38},"end":{"line":150,"column":13}}},"15":{"name":"all","line":166,"loc":{"start":{"line":166,"column":55},"end":{"line":179,"column":1}}},"16":{"name":"(anonymous_15)","line":167,"loc":{"start":{"line":167,"column":39},"end":{"line":178,"column":5}}},"17":{"name":"(anonymous_16)","line":169,"loc":{"start":{"line":169,"column":36},"end":{"line":171,"column":13}}},"18":{"name":"(anonymous_17)","line":171,"loc":{"start":{"line":171,"column":38},"end":{"line":177,"column":13}}}},"branchMap":{"1":{"line":27,"type":"if","locations":[{"start":{"line":27,"column":23},"end":{"line":27,"column":50}},{"start":{"line":27,"column":23},"end":{"line":27,"column":50}}]},"2":{"line":28,"type":"if","locations":[{"start":{"line":28,"column":23},"end":{"line":28,"column":39}},{"start":{"line":28,"column":23},"end":{"line":28,"column":39}}]},"3":{"line":30,"type":"if","locations":[{"start":{"line":30,"column":23},"end":{"line":30,"column":55}},{"start":{"line":30,"column":23},"end":{"line":30,"column":55}}]},"4":{"line":42,"type":"if","locations":[{"start":{"line":42,"column":8},"end":{"line":44,"column":9}},{"start":{"line":42,"column":8},"end":{"line":44,"column":9}}]},"5":{"line":49,"type":"if","locations":[{"start":{"line":49,"column":12},"end":{"line":69,"column":13}},{"start":{"line":49,"column":12},"end":{"line":69,"column":13}}]},"6":{"line":60,"type":"if","locations":[{"start":{"line":60,"column":24},"end":{"line":63,"column":25}},{"start":{"line":60,"column":24},"end":{"line":63,"column":25}}]},"7":{"line":74,"type":"if","locations":[{"start":{"line":74,"column":12},"end":{"line":76,"column":13}},{"start":{"line":74,"column":12},"end":{"line":76,"column":13}}]},"8":{"line":79,"type":"if","locations":[{"start":{"line":79,"column":12},"end":{"line":81,"column":13}},{"start":{"line":79,"column":12},"end":{"line":81,"column":13}}]},"9":{"line":82,"type":"if","locations":[{"start":{"line":82,"column":12},"end":{"line":84,"column":13}},{"start":{"line":82,"column":12},"end":{"line":84,"column":13}}]},"10":{"line":85,"type":"if","locations":[{"start":{"line":85,"column":12},"end":{"line":88,"column":13}},{"start":{"line":85,"column":12},"end":{"line":88,"column":13}}]},"11":{"line":95,"type":"if","locations":[{"start":{"line":95,"column":20},"end":{"line":98,"column":21}},{"start":{"line":95,"column":20},"end":{"line":98,"column":21}}]},"12":{"line":137,"type":"if","locations":[{"start":{"line":137,"column":24},"end":{"line":137,"column":39}},{"start":{"line":137,"column":24},"end":{"line":137,"column":39}}]},"13":{"line":139,"type":"if","locations":[{"start":{"line":139,"column":24},"end":{"line":139,"column":56}},{"start":{"line":139,"column":24},"end":{"line":139,"column":56}}]},"14":{"line":145,"type":"if","locations":[{"start":{"line":145,"column":16},"end":{"line":149,"column":17}},{"start":{"line":145,"column":16},"end":{"line":149,"column":17}}]},"15":{"line":163,"type":"if","locations":[{"start":{"line":163,"column":23},"end":{"line":163,"column":50}},{"start":{"line":163,"column":23},"end":{"line":163,"column":50}}]},"16":{"line":164,"type":"if","locations":[{"start":{"line":164,"column":23},"end":{"line":164,"column":38}},{"start":{"line":164,"column":23},"end":{"line":164,"column":38}}]},"17":{"line":166,"type":"if","locations":[{"start":{"line":166,"column":23},"end":{"line":166,"column":55}},{"start":{"line":166,"column":23},"end":{"line":166,"column":55}}]},"18":{"line":172,"type":"if","locations":[{"start":{"line":172,"column":16},"end":{"line":176,"column":17}},{"start":{"line":172,"column":16},"end":{"line":176,"column":17}}]}},"s":{"1":1,"2":22,"3":22,"4":23,"5":15,"6":15,"7":15,"8":1,"9":14,"10":14,"11":14,"12":60,"13":57,"14":45,"15":45,"16":45,"17":45,"18":12,"19":12,"20":12,"21":12,"22":7,"23":7,"24":5,"25":3,"26":3,"27":14,"28":50,"29":8,"30":42,"31":42,"32":4,"33":42,"34":7,"35":35,"36":14,"37":14,"38":14,"39":61,"40":60,"41":60,"42":14,"43":47,"44":47,"45":1,"46":1,"47":56,"48":56,"49":6,"50":6,"51":3,"52":3,"53":1,"54":2,"55":1,"56":1,"57":1,"58":6,"59":6,"60":6,"61":3,"62":3,"63":1,"64":2,"65":1,"66":1,"67":1},"b":{"1":[7,8],"2":[7,8],"3":[8,7],"4":[1,14],"5":[57,3],"6":[7,5],"7":[8,42],"8":[4,38],"9":[7,35],"10":[14,21],"11":[60,0],"12":[3,0],"13":[3,0],"14":[1,1],"15":[3,0],"16":[3,0],"17":[3,0],"18":[1,1]},"f":{"1":15,"2":15,"3":60,"4":45,"5":12,"6":50,"7":61,"8":60,"9":56,"10":56,"11":3,"12":3,"13":1,"14":2,"15":3,"16":3,"17":1,"18":2},"code":["const DEFAULT_MAX = 5;","","export interface Result<T> {"," amountDone: number;"," amountStarted: number;"," amountResolved: number;"," amountRejected: number;"," rejectedIndexes: number[];"," resolvedIndexes: number[];"," taskResults: T[];","}","","export type Task<T> = () => Promise<T>;","export type Tasks<T> = Array<Task<T>>;","export type nextTaskCheck = <T>(status: Result<T>, tasks: Tasks<T>) => Promise<boolean>;","","/**"," * Raw throttle function, which can return extra meta data."," * @param tasks array[] of functions"," * @param maxInProgress integer with the max amount of tasks to be run in parallel"," * @param failFast boolean if true, do fail-fast behaviour (see Promise.all() documentation)"," * @param progressCallback function which can be used to see the progress"," * @param nextCheck"," * @returns {Promise}"," */","export function raw<T>(tasks: Tasks<T>,"," maxInProgress = DEFAULT_MAX,"," failFast = false,"," progressCallback?: (result: Result<T>) => void,"," nextCheck = defaultNextTaskCheck): Promise<Result<T>> {"," return new Promise((resolve, reject) => {"," const result: Result<T> = {"," amountDone: 0,"," amountStarted: 0,"," amountResolved: 0,"," amountRejected: 0,"," rejectedIndexes: [],"," resolvedIndexes: [],"," taskResults: []"," };",""," if (tasks.length === 0) {"," return resolve(result);"," }",""," let failedFast = false;"," let amountQueued = 0;"," const executeTask = (index: number) => {"," if (typeof tasks[index] === 'function') {"," tasks[index]()"," .then((taskResult: T) => {"," result.taskResults[index] = taskResult;"," result.resolvedIndexes.push(index);"," result.amountResolved++;"," taskDone();"," }, error => {"," result.taskResults[index] = error;"," result.rejectedIndexes.push(index);"," result.amountRejected++;"," if (failFast) {"," failedFast = true;"," return reject(result);"," }"," taskDone();"," });"," } else {"," failedFast = true;"," return reject(new Error('tasks[' + index + ']: ' + tasks[index] + ', is supposed to be of type function'));"," }"," };",""," const taskDone = () => {"," //make sure no more tasks are spawned when we failedFast"," if (failedFast) {"," return;"," }",""," result.amountDone++;"," if (progressCallback) {"," progressCallback(result);"," }"," if (result.amountDone === tasks.length) {"," return resolve(result);"," }"," if (amountQueued < tasks.length) {"," amountQueued++;"," nextTask();"," }"," };",""," const nextTask = () => {"," //check if we can execute the next task"," nextCheck(result, tasks)"," .then(canExecuteNextTask => {"," if (canExecuteNextTask === true) {"," //execute it"," executeTask(result.amountStarted++);"," }"," }, reject);"," };",""," //spawn the first X task"," for (let i = 0; i < Math.min(maxInProgress, tasks.length); i++) {"," amountQueued++;"," nextTask();"," }"," });","}","","/**"," * Default checker which validates if a next task should begin."," * This can be overwritten to write own checks for example checking the amount"," * of used ram and waiting till the ram is low enough for a next task."," *"," * It should always resolve with a boolean, either `true` to start a next task"," * or `false` to stop executing a new task."," *"," * If this method rejects, the error will propagate to the caller"," * @param status"," * @param tasks"," * @returns {Promise}"," */","const defaultNextTaskCheck: nextTaskCheck = <T>(status: Result<T>, tasks: Tasks<T>): Promise<boolean> => {"," return new Promise((resolve, reject) => {"," resolve(status.amountStarted < tasks.length);"," });","};","","/**"," * Simply run all the promises after each other, so in synchronous manner"," * @param tasks required array of tasks to be executed"," * @param failFast optional boolean if we directly reject on a single error defaults to true"," * @param progressCallback optional function to be run to get status updates"," * @param nextCheck function which should return a promise, when resolved the next task will spawn"," */","export function sync<T>(tasks: Tasks<T>,"," failFast = true,"," progressCallback?: () => void,"," nextCheck = defaultNextTaskCheck): Promise<T[]> {"," return new Promise((resolve, reject) => {"," raw(tasks, 1, failFast, progressCallback, nextCheck)"," .then((result: Result<T>) => {"," resolve(result.taskResults);"," }, (error: Error|Result<T>) => {"," if (error instanceof Error) {"," reject(error);"," } else {"," reject(error.taskResults[error.rejectedIndexes[0]]);"," }"," });"," });","}","","/**"," * Exposes the same behaviour as Promise.All(), but throttled!"," * @param tasks required array of tasks to be executed"," * @param maxInProgress optional integer max amount of parallel tasks to be run defaults to 5"," * @param failFast optional boolean if we directly reject on a single error defaults to true"," * @param progressCallback optional function to be run to get status updates"," * @param nextCheck function which should return a promise, when resolved the next task will spawn"," */","export function all<T>(tasks: Tasks<T>,"," maxInProgress = DEFAULT_MAX,"," failFast = true,"," progressCallback?: () => void,"," nextCheck = defaultNextTaskCheck): Promise<T[]> {"," return new Promise((resolve, reject) => {"," raw(tasks, maxInProgress, failFast, progressCallback, nextCheck)"," .then((result: Result<T>) => {"," resolve(result.taskResults);"," }, (error: Error|Result<T>) => {"," if (error instanceof Error) {"," reject(error);"," } else {"," reject(error.taskResults[error.rejectedIndexes[0]]);"," }"," });"," });","}",""],"l":{"1":1,"26":1,"27":22,"28":22,"30":23,"31":15,"32":15,"42":15,"43":1,"46":14,"47":14,"48":14,"49":60,"50":57,"52":45,"53":45,"54":45,"55":45,"57":12,"58":12,"59":12,"60":12,"61":7,"62":7,"64":5,"67":3,"68":3,"72":14,"74":50,"75":8,"78":42,"79":42,"80":4,"82":42,"83":7,"85":35,"86":14,"87":14,"91":14,"93":61,"95":60,"97":60,"103":14,"104":47,"105":47,"123":1,"124":56,"125":56,"136":1,"137":6,"139":6,"140":3,"141":3,"143":1,"145":2,"146":1,"148":1,"162":1,"163":6,"164":6,"166":6,"167":3,"168":3,"170":1,"172":2,"173":1,"175":1}}} |
--------------|----------|----------|----------|----------|----------------| | ||
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines | | ||
--------------|----------|----------|----------|----------|----------------| | ||
[33;1msrc/ [0m |[33;1m 62.9[0m |[31;1m 38.24[0m |[33;1m 56.25[0m |[33;1m 62.9[0m |[31;1m [0m | | ||
[33;1mthrottle.ts[0m |[33;1m 62.9[0m |[31;1m 38.24[0m |[33;1m 56.25[0m |[33;1m 62.9[0m |[31;1m... 163,164,166[0m | | ||
[32;1msrc/ [0m |[32;1m 100[0m |[32;1m 83.33[0m |[32;1m 100[0m |[32;1m 100[0m |[31;1m [0m | | ||
[32;1mthrottle.ts[0m |[32;1m 100[0m |[32;1m 83.33[0m |[32;1m 100[0m |[32;1m 100[0m |[31;1m [0m | | ||
--------------|----------|----------|----------|----------|----------------| | ||
[33;1mAll files [0m |[33;1m 62.9[0m |[31;1m 38.24[0m |[33;1m 56.25[0m |[33;1m 62.9[0m |[31;1m [0m | | ||
[32;1mAll files [0m |[32;1m 100[0m |[32;1m 83.33[0m |[32;1m 100[0m |[32;1m 100[0m |[31;1m [0m | | ||
--------------|----------|----------|----------|----------|----------------| |
{ | ||
"name": "promise-parallel-throttle", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Run promises in parallel, but throttled", | ||
@@ -10,3 +10,3 @@ "main": "build/throttle.js", | ||
"declarations": "tsc --declaration", | ||
"test": "yarn lint && jest", | ||
"test": "yarn lint && jest --coverage", | ||
"test:watch": "jest --watch", | ||
@@ -13,0 +13,0 @@ "lint": "tslint -p ./tsconfig.json", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
266651
1248
0