spark.js
function Spark(primus, headers, address, query, id, request, socket) {
  this.fuse();

  var writable = this.writable
    , spark = this
    , idgen = primus.options.idGenerator;

  query = query || {};
  id = idgen ? idgen() : (id || nanoid());
  headers = headers || {};
  address = address || {};
  request = request || headers['primus::req::backup'];

  writable('id', id);                   // Unique id for socket.
  writable('primus', primus);           // References to Primus.
  writable('remote', address);          // The remote address location.
  writable('headers', headers);         // The request headers.
  writable('request', request);         // Reference to an HTTP request.
  writable('socket', socket);           // Reference to the transformer's socket
  writable('writable', true);           // Silly stream compatibility.
  writable('readable', true);           // Silly stream compatibility.
  writable('queue', []);                // Data queue for data events.
  writable('query', query);             // The query string.
  writable('ultron', new Ultron(this)); // Our event listening cleanup.
  writable('alive', true);              // Flag used to detect zombie sparks.

  //
  // Parse our query string.
  //
  if ('string' === typeof this.query) {
    this.query = parse(this.query);
  }

  this.__initialise.forEach(function execute(initialise) {
    initialise.call(spark);
  });
}
function Spark(primus, headers, address, query, id, request, socket) {
  this.fuse();

  var writable = this.writable
    , spark = this
    , idgen = primus.options.idGenerator;

  query = query || {};
  id = idgen ? idgen() : (id || nanoid());
  headers = headers || {};
  address = address || {};
  request = request || headers['primus::req::backup'];

  writable('id', id);                   // Unique id for socket.
  writable('primus', primus);           // References to Primus.
  writable('remote', address);          // The remote address location.
  writable('headers', headers);         // The request headers.
  writable('request', request);         // Reference to an HTTP request.
  writable('socket', socket);           // Reference to the transformer's socket
  writable('writable', true);           // Silly stream compatibility.
  writable('readable', true);           // Silly stream compatibility.
  writable('queue', []);                // Data queue for data events.
  writable('query', query);             // The query string.
  writable('ultron', new Ultron(this)); // Our event listening cleanup.
  writable('alive', true);              // Flag used to detect zombie sparks.

  //
  // Parse our query string.
  //
  if ('string' === typeof this.query) {
    this.query = parse(this.query);
  }

  this.__initialise.forEach(function execute(initialise) {
    initialise.call(spark);
  });
}
function Spark ( primus , headers , address , query , id , request , socket ) { this . fuse ( ) ; var writable = this . writable , spark = this , idgen = primus . options . idGenerator ; query = query || { } ; id = idgen ? idgen ( ) : ( id || nanoid ( ) ) ; headers = headers || { } ; address = address || { } ; request = request || headers [ 'primus::req::backup' ] ; writable ( 'id' , id ) ; // Unique id for socket. writable ( 'primus' , primus ) ; // References to Primus. writable ( 'remote' , address ) ; // The remote address location. writable ( 'headers' , headers ) ; // The request headers. writable ( 'request' , request ) ; // Reference to an HTTP request. writable ( 'socket' , socket ) ; // Reference to the transformer's socket writable ( 'writable' , true ) ; // Silly stream compatibility. writable ( 'readable' , true ) ; // Silly stream compatibility. writable ( 'queue' , [ ] ) ; // Data queue for data events. writable ( 'query' , query ) ; // The query string. writable ( 'ultron' , new Ultron ( this ) ) ; // Our event listening cleanup. writable ( 'alive' , true ) ; // Flag used to detect zombie sparks. // // Parse our query string. // if ( 'string' === typeof this . query ) { this . query = parse ( this . query ) ; } this . __initialise . forEach ( function execute ( initialise ) { initialise . call ( spark ) ; } ) ; }
The Spark is an indefinable, indescribable energy or soul of a transformer
which can be used to create new transformers. In our case, it's a simple
wrapping interface.

@constructor
@param {Primus} primus Reference to the Primus server. (Set using .bind)
@param {Object} headers The request headers for this connection.
@param {Object} address The object that holds the remoteAddress and port.
@param {Object} query The query string of request.
@param {String} id An optional id of the socket, or we will generate one.
@param {Request} request The HTTP Request instance that initialised the spark.
@param {Mixed} socket Reference to the transformer socket.
@api public
The Spark is an indefinable indescribable energy or soul of a transformer which can be used to create new transformers . In our case it s a simple wrapping interface .