• File: number-readable.js
  • Full Path: /var/www/nodejs/callDir/node_modules/dev-null/test/fixtures/number-readable.js
  • Date Modified: 06/03/2024 5:11 PM
  • File size: 486 bytes
  • MIME-type: text/plain
  • Charset: utf-8
'use strict';

var util = require('util')
  , stream = require('stream')
  , Readable = stream.Readable

module.exports = NumberReadable;

util.inherits(NumberReadable, Readable);

function NumberReadable (opts) {
  if (!(this instanceof NumberReadable)) return new NumberReadable(opts);
  Readable.call(this, opts);
  this.idx = 0;
  this.to = opts.to;
}

NumberReadable.prototype._read = function () {
  if (this.idx > this.to) return this.push(null);
  this.push('' + this.idx++);
}