lib/createWorkers.js
function _wait(eventName, timeout = 1000) {
    return new Promise((resolve, reject) => {
      let timeoutId = null;

      timeoutId = setTimeout(() => {
        timeoutId = null;
        reject(new Error(`event ${eventName} didn't occur after ${timeout}ms`));
      }, timeout);

      emitter.once(eventName, () => {
        if (timeoutId !== null) {
          clearTimeout(timeoutId);
          resolve();
        }
      });
    });
  }
function _wait(eventName, timeout = 1000) {
    return new Promise((resolve, reject) => {
      let timeoutId = null;

      timeoutId = setTimeout(() => {
        timeoutId = null;
        reject(new Error(`event ${eventName} didn't occur after ${timeout}ms`));
      }, timeout);

      emitter.once(eventName, () => {
        if (timeoutId !== null) {
          clearTimeout(timeoutId);
          resolve();
        }
      });
    });
  }
function _wait ( eventName , timeout = 1000 ) { return new Promise ( ( resolve , reject ) => { let timeoutId = null ; timeoutId = setTimeout ( ( ) => { timeoutId = null ; reject ( new Error ( ` ${ eventName } ${ timeout } ` ) ) ; } , timeout ) ; emitter . once ( eventName , ( ) => { if ( timeoutId !== null ) { clearTimeout ( timeoutId ) ; resolve ( ) ; } } ) ; } ) ; }
Wait for an event for a given amount of time.

@param {string} eventName The name of the event to wait for.
@param {number} timeout The maximum number of milliseconds to wait for, defaults to 1000.
@return {Promise} A promise which is resolved when the event emitted, or rejected
if the timeout occurs first.
@private
Wait for an event for a given amount of time .