@@ -6,7 +6,9 @@ export interface ConcurrencyPool { | ||
| export declare class BoundedConcurrencyPool implements ConcurrencyPool { | ||
| #private; | ||
| private concurrencyFactor; | ||
| private inFlight; | ||
| private pending; | ||
| constructor(concurrencyFactor: number | (() => number)); | ||
| run<T>(src: () => Promise<T>): Promise<T>; | ||
| get inFlight(): number; | ||
| get inQueue(): number; | ||
| } |
@@ -11,2 +11,14 @@ "use strict"; | ||
| }; | ||
| var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
| if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
| if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
| return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
| }; | ||
| var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
| if (kind === "m") throw new TypeError("Private method is not writable"); | ||
| if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
| if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
| return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
| }; | ||
| var _BoundedConcurrencyPool_inFlight; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -21,4 +33,4 @@ exports.BoundedConcurrencyPool = exports.UnboundedConcurrencyPool = void 0; | ||
| constructor(concurrencyFactor) { | ||
| this.inFlight = 0; | ||
| this.pending = []; | ||
| _BoundedConcurrencyPool_inFlight.set(this, 0); | ||
| if (typeof concurrencyFactor === 'number') { | ||
@@ -32,7 +44,8 @@ this.concurrencyFactor = () => concurrencyFactor; | ||
| run(src) { | ||
| var _a, _b; | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| if (this.inFlight >= this.concurrencyFactor()) { | ||
| if (__classPrivateFieldGet(this, _BoundedConcurrencyPool_inFlight, "f") >= this.concurrencyFactor()) { | ||
| yield new Promise((resolve) => this.pending.push(resolve)); | ||
| } | ||
| this.inFlight++; | ||
| __classPrivateFieldSet(this, _BoundedConcurrencyPool_inFlight, (_a = __classPrivateFieldGet(this, _BoundedConcurrencyPool_inFlight, "f"), _a++, _a), "f"); | ||
| try { | ||
@@ -43,3 +56,3 @@ let res = yield src(); | ||
| finally { | ||
| this.inFlight--; | ||
| __classPrivateFieldSet(this, _BoundedConcurrencyPool_inFlight, (_b = __classPrivateFieldGet(this, _BoundedConcurrencyPool_inFlight, "f"), _b--, _b), "f"); | ||
| if (this.pending.length > 0) { | ||
@@ -53,4 +66,11 @@ let p = this.pending[0]; | ||
| } | ||
| get inFlight() { | ||
| return __classPrivateFieldGet(this, _BoundedConcurrencyPool_inFlight, "f"); | ||
| } | ||
| get inQueue() { | ||
| return this.pending.length; | ||
| } | ||
| } | ||
| exports.BoundedConcurrencyPool = BoundedConcurrencyPool; | ||
| _BoundedConcurrencyPool_inFlight = new WeakMap(); | ||
| //# sourceMappingURL=ConcurrencyPool.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"ConcurrencyPool.js","sourceRoot":"","sources":["../../src/sync/ConcurrencyPool.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIa,QAAA,wBAAwB,GAAoB;IACrD,GAAG,EAAE,CAAI,GAAqB,EAAE,EAAE;QAC9B,OAAO,GAAG,EAAE,CAAC;IACjB,CAAC;CACJ,CAAC;AAEF,MAAa,sBAAsB;IAK/B,YAAY,iBAA0C;QAH9C,aAAQ,GAAG,CAAC,CAAC;QACb,YAAO,GAAmB,EAAE,CAAC;QAGjC,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE;YACvC,IAAI,CAAC,iBAAiB,GAAG,GAAG,EAAE,CAAC,iBAAiB,CAAC;SACpD;aAAM;YACH,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;SAC9C;IACL,CAAC;IAEK,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AU,IAAI,IAAI,CAAC,iBAAiB,EAAE,EAAE;gBAC5C,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;aACpE;YACD,+DAAA,CAAA,wEAAc,EAAd,IAAgB,IAAA,CAAA,MAAA,CAAC;YACjB,IAAI;gBACA,IAAI,GAAG,GAAG,MAAM,GAAG,EAAE,CAAC;gBACtB,OAAO,GAAG,CAAC;aACd;oBAAS;gBACN,+DAAA,CAAA,wEAAc,EAAd,IAAgB,IAAA,CAAA,MAAA,CAAC;gBACjB,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;oBACzB,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;oBACxB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;oBACrB,CAAC,EAAE,CAAC;iBACP;aACJ;;KACJ;IAED,IAAW,QAAQ;QACf,OAAO,uBAAA,IAAI,wCAAU,CAAC;IAC1B,CAAC;IAED,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC/B,CAAC;CACJ;AAvCD,wDAuCC"} |
+1
-1
| { | ||
| "name": "teslabot", | ||
| "version": "1.4.1", | ||
| "version": "1.5.0", | ||
| "repository": "https://github.com/ex3ndr/teslabot.git", | ||
@@ -5,0 +5,0 @@ "author": "Steve Korshakov <steve@korshakov.com>", |
35007
5.86%539
4.26%