@autonomys/asynchronous 1.4.19 → 1.4.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"weightedRequestsConcurrencyController.d.ts","sourceRoot":"","sources":["../../src/concurrency/weightedRequestsConcurrencyController.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,CAAA;AAErC,KAAK,qBAAqB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;AAOhF,eAAO,MAAM,oCAAoC,GAC/C,gBAAgB,MAAM,EACtB,cAAa,OAAe,KAC3B,
|
|
1
|
+
{"version":3,"file":"weightedRequestsConcurrencyController.d.ts","sourceRoot":"","sources":["../../src/concurrency/weightedRequestsConcurrencyController.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,CAAA;AAErC,KAAK,qBAAqB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;AAOhF,eAAO,MAAM,oCAAoC,GAC/C,gBAAgB,MAAM,EACtB,cAAa,OAAe,KAC3B,qBA4DF,CAAA"}
|
|
@@ -46,6 +46,12 @@ const weightedRequestConcurrencyController = (maxConcurrency, ensureOrder = fals
|
|
|
46
46
|
return job().finally(() => manageJobFinalization(concurrency));
|
|
47
47
|
});
|
|
48
48
|
const runJob = (job, concurrency) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
if (concurrency < 0) {
|
|
50
|
+
throw new Error('Concurrency must be greater than 0');
|
|
51
|
+
}
|
|
52
|
+
if (concurrency > maxConcurrency) {
|
|
53
|
+
throw new Error('Concurrency must be less than or equal to max concurrency');
|
|
54
|
+
}
|
|
49
55
|
const exceededMaxConcurrency = active + concurrency > maxConcurrency;
|
|
50
56
|
const shouldRespectOrder = ensureOrder && queue.length > 0;
|
|
51
57
|
if (exceededMaxConcurrency || shouldRespectOrder) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autonomys/asynchronous",
|
|
3
3
|
"packageManager": "yarn@4.7.0",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.21",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"ts-jest": "^29.3.1",
|
|
30
30
|
"typescript": "^5.8.3"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "384c92c0f560ee85b9681617dfb9082e243ebdc9"
|
|
33
33
|
}
|
|
@@ -53,6 +53,13 @@ export const weightedRequestConcurrencyController = (
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const runJob = async <T>(job: Job<T>, concurrency: number): Promise<T> => {
|
|
56
|
+
if (concurrency < 0) {
|
|
57
|
+
throw new Error('Concurrency must be greater than 0')
|
|
58
|
+
}
|
|
59
|
+
if (concurrency > maxConcurrency) {
|
|
60
|
+
throw new Error('Concurrency must be less than or equal to max concurrency')
|
|
61
|
+
}
|
|
62
|
+
|
|
56
63
|
const exceededMaxConcurrency = active + concurrency > maxConcurrency
|
|
57
64
|
const shouldRespectOrder = ensureOrder && queue.length > 0
|
|
58
65
|
if (exceededMaxConcurrency || shouldRespectOrder) {
|