Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
resolve(events)
return
}
- workerNode.on(workerNodeEvent, () => {
- ++events
- if (events === numberOfEventsToWait) {
- resolve(events)
- }
- })
+ switch (workerNodeEvent) {
+ case 'idle':
+ case 'backPressure':
+ case 'taskFinished':
+ workerNode.on(workerNodeEvent, () => {
+ ++events
+ if (events === numberOfEventsToWait) {
+ resolve(events)
+ }
+ })
+ break
+ default:
+ throw new Error('Invalid worker node event')
+ }
if (timeout >= 0) {
setTimeout(() => {
resolve(events)