bigpipe.js
function BigPipe(options) {
  if (!(this instanceof BigPipe)) return new BigPipe(options);

  options = options || {};

  this.expected = +options.pagelets || 0; // Pagelets that this page requires.
  this.allowed = +options.pagelets || 0;  // Pagelets that are allowed for this page.
  this.maximum = options.limit || 20;     // Max Pagelet instances we can reuse.
  this.readyState = BigPipe.LOADING;      // Current readyState.
  this.options = options;                 // Reference to the used options.
  this.templates = {};                    // Collection of templates.
  this.pagelets = [];                     // Collection of different pagelets.
  this.freelist = [];                     // Collection of unused Pagelet instances.
  this.rendered = [];                     // List of already rendered pagelets.
  this.progress = 0;                      // Percentage loaded.
  this.assets = {};                       // Asset cache.
  this.root = document.documentElement;   // The <html> element.

  EventEmitter.call(this);

  this.configure(options);
}
function BigPipe(options) {
  if (!(this instanceof BigPipe)) return new BigPipe(options);

  options = options || {};

  this.expected = +options.pagelets || 0; // Pagelets that this page requires.
  this.allowed = +options.pagelets || 0;  // Pagelets that are allowed for this page.
  this.maximum = options.limit || 20;     // Max Pagelet instances we can reuse.
  this.readyState = BigPipe.LOADING;      // Current readyState.
  this.options = options;                 // Reference to the used options.
  this.templates = {};                    // Collection of templates.
  this.pagelets = [];                     // Collection of different pagelets.
  this.freelist = [];                     // Collection of unused Pagelet instances.
  this.rendered = [];                     // List of already rendered pagelets.
  this.progress = 0;                      // Percentage loaded.
  this.assets = {};                       // Asset cache.
  this.root = document.documentElement;   // The <html> element.

  EventEmitter.call(this);

  this.configure(options);
}
function BigPipe ( options ) { if ( ! ( this instanceof BigPipe ) ) return new BigPipe ( options ) ; options = options || { } ; this . expected = + options . pagelets || 0 ; // Pagelets that this page requires. this . allowed = + options . pagelets || 0 ; // Pagelets that are allowed for this page. this . maximum = options . limit || 20 ; // Max Pagelet instances we can reuse. this . readyState = BigPipe . LOADING ; // Current readyState. this . options = options ; // Reference to the used options. this . templates = { } ; // Collection of templates. this . pagelets = [ ] ; // Collection of different pagelets. this . freelist = [ ] ; // Collection of unused Pagelet instances. this . rendered = [ ] ; // List of already rendered pagelets. this . progress = 0 ; // Percentage loaded. this . assets = { } ; // Asset cache. this . root = document . documentElement ; // The <html> element. EventEmitter . call ( this ) ; this . configure ( options ) ; }
BigPipe is the client-side library which is automatically added to pages which
uses the BigPipe framework.

Options:

- limit: The amount pagelet instances we can reuse.
- pagelets: The amount of pagelets we're expecting to load.
- id: The id of the page that we're loading.

@constructor
@param {Object} options BigPipe configuration.
@api public
BigPipe is the client - side library which is automatically added to pages which uses the BigPipe framework .