function JSONStream(runner, options) {
  Base.call(this, runner, options);

  var self = this;
  var total = runner.total;

  runner.once(EVENT_RUN_BEGIN, function() {
    writeEvent(['start', {total: total}]);
  });

  runner.on(EVENT_TEST_PASS, function(test) {
    writeEvent(['pass', clean(test)]);
  });

  runner.on(EVENT_TEST_FAIL, function(test, err) {
    test = clean(test);
    test.err = err.message;
    test.stack = err.stack || null;
    writeEvent(['fail', test]);
  });

  runner.once(EVENT_RUN_END, function() {
    writeEvent(['end', self.stats]);
  });
}
function JSONStream(runner, options) {
  Base.call(this, runner, options);

  var self = this;
  var total = runner.total;

  runner.once(EVENT_RUN_BEGIN, function() {
    writeEvent(['start', {total: total}]);
  });

  runner.on(EVENT_TEST_PASS, function(test) {
    writeEvent(['pass', clean(test)]);
  });

  runner.on(EVENT_TEST_FAIL, function(test, err) {
    test = clean(test);
    test.err = err.message;
    test.stack = err.stack || null;
    writeEvent(['fail', test]);
  });

  runner.once(EVENT_RUN_END, function() {
    writeEvent(['end', self.stats]);
  });
}
function JSONStream ( runner , options ) { Base . call ( this , runner , options ) ; var self = this ; var total = runner . total ; runner . once ( EVENT_RUN_BEGIN , function ( ) { writeEvent ( [ 'start' , { total : total } ] ) ; } ) ; runner . on ( EVENT_TEST_PASS , function ( test ) { writeEvent ( [ 'pass' , clean ( test ) ] ) ; } ) ; runner . on ( EVENT_TEST_FAIL , function ( test , err ) { test = clean ( test ) ; test . err = err . message ; test . stack = err . stack || null ; writeEvent ( [ 'fail' , test ] ) ; } ) ; runner . once ( EVENT_RUN_END , function ( ) { writeEvent ( [ 'end' , self . stats ] ) ; } ) ; }
Constructs a new `JSONStream` reporter instance.

@public
@class
@memberof Mocha.reporters
@extends Mocha.reporters.Base
@param {Runner} runner - Instance triggers reporter actions.
@param {Object} [options] - runner options
Constructs a new JSONStream reporter instance .
A JSON stream that can be used to write the results of a test.