lib/random-stream.js
function RandomStream(options) {
  if (!(this instanceof RandomStream)) {
    return new RandomStream(options);
  }

  this._options = merge(Object.create(RandomStream.DEFAULTS), options);

  assert(typeof this._options.length === 'number', 'Invalid length supplied');
  assert(typeof this._options.size === 'number', 'Invalid size supplied');
  assert(typeof this._options.hash === 'string', 'Invalid hash alg supplied');

  this.hash = crypto.createHash(this._options.hash);
  this.bytes = 0;

  ReadableStream.call(this);
}
function RandomStream(options) {
  if (!(this instanceof RandomStream)) {
    return new RandomStream(options);
  }

  this._options = merge(Object.create(RandomStream.DEFAULTS), options);

  assert(typeof this._options.length === 'number', 'Invalid length supplied');
  assert(typeof this._options.size === 'number', 'Invalid size supplied');
  assert(typeof this._options.hash === 'string', 'Invalid hash alg supplied');

  this.hash = crypto.createHash(this._options.hash);
  this.bytes = 0;

  ReadableStream.call(this);
}
function RandomStream ( options ) { if ( ! ( this instanceof RandomStream ) ) { return new RandomStream ( options ) ; } this . _options = merge ( Object . create ( RandomStream . DEFAULTS ) , options ) ; assert ( typeof this . _options . length === 'number' , 'Invalid length supplied' ) ; assert ( typeof this . _options . size === 'number' , 'Invalid size supplied' ) ; assert ( typeof this . _options . hash === 'string' , 'Invalid hash alg supplied' ) ; this . hash = crypto . createHash ( this . _options . hash ) ; this . bytes = 0 ; ReadableStream . call ( this ) ; }
Create a readable stream of random data
@extends {ReadableStream}
@constructor
@param {Object} options
@param {Number} options.length - The total length of the stream in bytes
@param {Number} options.size - The number of bytes in each data chunk
@param {String} options.hash - The hash algorithm to use
Create a readable stream of random data