lib/worker.js
function Worker(baseUrl, opts = {}) {

  if (!(this instanceof Worker)) {
    return new Worker(baseUrl, opts);
  }

  // inheritance
  Emitter.call(this);

  this.options = extend({
    workerId: uuid.v4()
  }, defaultOptions, opts);

  this.subscriptions = {};

  this.state = STATE_NEW;

  // apply extensions
  if (this.options.use) {
    this.extend(this.options.use);
  }

  // local variables
  this.engineApi = new EngineApi(
    baseUrl,
    this.options.requestOptions,
    this.options.apiVersion
  );

  if (this.options.pollingDelay) {
    throw new Error('options.pollingDelay got replaced with options.autoPoll');
  }

  // start
  if (this.options.autoPoll) {
    this.start();
  }
}
function Worker(baseUrl, opts = {}) {

  if (!(this instanceof Worker)) {
    return new Worker(baseUrl, opts);
  }

  // inheritance
  Emitter.call(this);

  this.options = extend({
    workerId: uuid.v4()
  }, defaultOptions, opts);

  this.subscriptions = {};

  this.state = STATE_NEW;

  // apply extensions
  if (this.options.use) {
    this.extend(this.options.use);
  }

  // local variables
  this.engineApi = new EngineApi(
    baseUrl,
    this.options.requestOptions,
    this.options.apiVersion
  );

  if (this.options.pollingDelay) {
    throw new Error('options.pollingDelay got replaced with options.autoPoll');
  }

  // start
  if (this.options.autoPoll) {
    this.start();
  }
}
function Worker ( baseUrl , opts = { } ) { if ( ! ( this instanceof Worker ) ) { return new Worker ( baseUrl , opts ) ; } // inheritance Emitter . call ( this ) ; this . options = extend ( { workerId : uuid . v4 ( ) } , defaultOptions , opts ) ; this . subscriptions = { } ; this . state = STATE_NEW ; // apply extensions if ( this . options . use ) { this . extend ( this . options . use ) ; } // local variables this . engineApi = new EngineApi ( baseUrl , this . options . requestOptions , this . options . apiVersion ) ; if ( this . options . pollingDelay ) { throw new Error ( 'options.pollingDelay got replaced with options.autoPoll' ) ; } // start if ( this . options . autoPoll ) { this . start ( ) ; } }
Instantiate a worker.

@param {String} baseUrl
@param {Object} [opts={}]
Instantiate a worker .