@parcel/utils 2.0.0-nightly.1501 → 2.0.0-nightly.1502
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.
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
- package/src/PromiseQueue.js +13 -0
- package/test/PromiseQueue.test.js +28 -0
package/lib/index.js
CHANGED
|
@@ -34335,6 +34335,7 @@ class $31bd78e367586e0a$export$2e2bcd8739ae039 {
|
|
|
34335
34335
|
_runPromise = null;
|
|
34336
34336
|
_count = 0;
|
|
34337
34337
|
_results = [];
|
|
34338
|
+
_addSubscriptions = new Set();
|
|
34338
34339
|
constructor(opts = {
|
|
34339
34340
|
maxConcurrent: Infinity
|
|
34340
34341
|
}){
|
|
@@ -34354,9 +34355,16 @@ class $31bd78e367586e0a$export$2e2bcd8739ae039 {
|
|
|
34354
34355
|
reject(err);
|
|
34355
34356
|
throw err;
|
|
34356
34357
|
}));
|
|
34358
|
+
for (const addFn of this._addSubscriptions)addFn();
|
|
34357
34359
|
if (this._numRunning > 0 && this._numRunning < this._maxConcurrent) this._next();
|
|
34358
34360
|
});
|
|
34359
34361
|
}
|
|
34362
|
+
subscribeToAdd(fn) {
|
|
34363
|
+
this._addSubscriptions.add(fn);
|
|
34364
|
+
return ()=>{
|
|
34365
|
+
this._addSubscriptions.delete(fn);
|
|
34366
|
+
};
|
|
34367
|
+
}
|
|
34360
34368
|
run() {
|
|
34361
34369
|
if (this._runPromise != null) return this._runPromise;
|
|
34362
34370
|
if (this._queue.length === 0) return Promise.resolve([]);
|