it-parallel
Advanced tools
Comparing version 2.0.1 to 2.0.2
export = parallel; | ||
/** | ||
* @template T | ||
* @typedef {object} Operation | ||
* @property {boolean} done | ||
* @property {boolean} ok | ||
* @property {Error} err | ||
* @property {T} value | ||
*/ | ||
/** | ||
* Takes an (async) iterator that emits promise-returning functions, | ||
@@ -12,0 +4,0 @@ * invokes them in parallel and emits the results as they become available but |
16
index.js
@@ -0,5 +1,5 @@ | ||
/* global EventTarget Event */ | ||
'use strict' | ||
const defer = require('p-defer') | ||
const EventEmitter = require('events').EventEmitter | ||
@@ -15,2 +15,4 @@ /** | ||
const CustomEvent = globalThis.CustomEvent || Event | ||
/** | ||
@@ -36,3 +38,3 @@ * Takes an (async) iterator that emits promise-returning functions, | ||
const ordered = options.ordered == null ? false : options.ordered | ||
const emitter = new EventEmitter() | ||
const emitter = new EventTarget() | ||
@@ -47,3 +49,3 @@ /** @type {Operation<T>[]}} */ | ||
emitter.on('task-complete', () => { | ||
emitter.addEventListener('task-complete', () => { | ||
resultAvailable.resolve() | ||
@@ -77,7 +79,7 @@ }) | ||
op.value = result | ||
emitter.emit('task-complete') | ||
emitter.dispatchEvent(new CustomEvent('task-complete')) | ||
}, err => { | ||
op.done = true | ||
op.err = err | ||
emitter.emit('task-complete') | ||
emitter.dispatchEvent(new CustomEvent('task-complete')) | ||
}) | ||
@@ -87,6 +89,6 @@ } | ||
sourceFinished = true | ||
emitter.emit('task-complete') | ||
emitter.dispatchEvent(new CustomEvent('task-complete')) | ||
} catch (err) { | ||
sourceErr = err | ||
emitter.emit('task-complete') | ||
emitter.dispatchEvent(new CustomEvent('task-complete')) | ||
} | ||
@@ -93,0 +95,0 @@ }) |
{ | ||
"name": "it-parallel", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Takes an (async) iterable that emits promise-returning functions, invokes them in parallel up to the concurrency limit and emits the results as they become available, optionally in the same order as the input", | ||
@@ -40,3 +40,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "29126fa87dae108acef381693812f22ac8f9362b" | ||
"gitHead": "b621056a11c9bfe991d1040b22a46651fa907a3c" | ||
} |
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
12821
379