supervisor.js
function FA2LayoutSupervisor(graph, params) {
  params = params || {};

  // Validation
  if (!isGraph(graph))
    throw new Error('graphology-layout-forceatlas2/worker: the given graph is not a valid graphology instance.');

  // Validating settings
  var settings = helpers.assign({}, DEFAULT_SETTINGS, params.settings),
      validationError = helpers.validateSettings(settings);

  if (validationError)
    throw new Error('graphology-layout-forceatlas2/worker: ' + validationError.message);

  // Properties
  this.worker = new Worker();
  this.graph = graph;
  this.settings = settings;
  this.matrices = null;
  this.running = false;
  this.killed = false;

  // Binding listeners
  this.handleMessage = this.handleMessage.bind(this);

  this.worker.addEventListener('message', this.handleMessage.bind(this));
}
function FA2LayoutSupervisor(graph, params) {
  params = params || {};

  // Validation
  if (!isGraph(graph))
    throw new Error('graphology-layout-forceatlas2/worker: the given graph is not a valid graphology instance.');

  // Validating settings
  var settings = helpers.assign({}, DEFAULT_SETTINGS, params.settings),
      validationError = helpers.validateSettings(settings);

  if (validationError)
    throw new Error('graphology-layout-forceatlas2/worker: ' + validationError.message);

  // Properties
  this.worker = new Worker();
  this.graph = graph;
  this.settings = settings;
  this.matrices = null;
  this.running = false;
  this.killed = false;

  // Binding listeners
  this.handleMessage = this.handleMessage.bind(this);

  this.worker.addEventListener('message', this.handleMessage.bind(this));
}
function FA2LayoutSupervisor ( graph , params ) { params = params || { } ; // Validation if ( ! isGraph ( graph ) ) throw new Error ( 'graphology-layout-forceatlas2/worker: the given graph is not a valid graphology instance.' ) ; // Validating settings var settings = helpers . assign ( { } , DEFAULT_SETTINGS , params . settings ) , validationError = helpers . validateSettings ( settings ) ; if ( validationError ) throw new Error ( 'graphology-layout-forceatlas2/worker: ' + validationError . message ) ; // Properties this . worker = new Worker ( ) ; this . graph = graph ; this . settings = settings ; this . matrices = null ; this . running = false ; this . killed = false ; // Binding listeners this . handleMessage = this . handleMessage . bind ( this ) ; this . worker . addEventListener ( 'message' , this . handleMessage . bind ( this ) ) ; }
Class representing a FA2 layout run by a webworker.

@constructor
@param  {Graph}         graph        - Target graph.
@param  {object|number} params       - Parameters:
@param  {object}          [settings] - Settings.
Class representing a FA2 layout run by a webworker .