index.js
function createWorkerProxy(workersOrFunctions, opt_options) {
    var options = {
      // Automatically call the callback after a call if the return value is not
      // undefined.
      autoCallback: false,
      // Catch errors and automatically respond with an error callback. Off by
      // default since it breaks standard behavior.
      catchErrors: false,
      // A list of functions that can be called. This list will be used to make
      // the proxy functions available when Proxy is not supported. Note that
      // this is generally not needed since the worker will also publish its
      // known functions.
      functionNames: [],
      // Call console.time and console.timeEnd for calls sent though the proxy.
      timeCalls: false
    };

    if (opt_options) {
      for (var key in opt_options) {
        if (!(key in options)) continue;
        options[key] = opt_options[key];
      }
    }
    Object.freeze(options);

    // Ensure that we have an array of workers (even if only using one worker).
    if (typeof Worker != 'undefined' && (workersOrFunctions instanceof Worker)) {
      workersOrFunctions = [workersOrFunctions];
    }

    if (Array.isArray(workersOrFunctions)) {
      return sendCallsToWorker(workersOrFunctions, options);
    } else {
      receiveCallsFromOwner(workersOrFunctions, options);
    }
  }
function createWorkerProxy(workersOrFunctions, opt_options) {
    var options = {
      // Automatically call the callback after a call if the return value is not
      // undefined.
      autoCallback: false,
      // Catch errors and automatically respond with an error callback. Off by
      // default since it breaks standard behavior.
      catchErrors: false,
      // A list of functions that can be called. This list will be used to make
      // the proxy functions available when Proxy is not supported. Note that
      // this is generally not needed since the worker will also publish its
      // known functions.
      functionNames: [],
      // Call console.time and console.timeEnd for calls sent though the proxy.
      timeCalls: false
    };

    if (opt_options) {
      for (var key in opt_options) {
        if (!(key in options)) continue;
        options[key] = opt_options[key];
      }
    }
    Object.freeze(options);

    // Ensure that we have an array of workers (even if only using one worker).
    if (typeof Worker != 'undefined' && (workersOrFunctions instanceof Worker)) {
      workersOrFunctions = [workersOrFunctions];
    }

    if (Array.isArray(workersOrFunctions)) {
      return sendCallsToWorker(workersOrFunctions, options);
    } else {
      receiveCallsFromOwner(workersOrFunctions, options);
    }
  }
function createWorkerProxy ( workersOrFunctions , opt_options ) { var options = { // Automatically call the callback after a call if the return value is not // undefined. autoCallback : false , // Catch errors and automatically respond with an error callback. Off by // default since it breaks standard behavior. catchErrors : false , // A list of functions that can be called. This list will be used to make // the proxy functions available when Proxy is not supported. Note that // this is generally not needed since the worker will also publish its // known functions. functionNames : [ ] , // Call console.time and console.timeEnd for calls sent though the proxy. timeCalls : false } ; if ( opt_options ) { for ( var key in opt_options ) { if ( ! ( key in options ) ) continue ; options [ key ] = opt_options [ key ] ; } } Object . freeze ( options ) ; // Ensure that we have an array of workers (even if only using one worker). if ( typeof Worker != 'undefined' && ( workersOrFunctions instanceof Worker ) ) { workersOrFunctions = [ workersOrFunctions ] ; } if ( Array . isArray ( workersOrFunctions ) ) { return sendCallsToWorker ( workersOrFunctions , options ) ; } else { receiveCallsFromOwner ( workersOrFunctions , options ) ; } }
Call this function with either a Worker instance, a list of them, or a map
of functions that can be called inside the worker.
Call this function with either a Worker instance a list of them or a map of functions that can be called inside the worker .