Front end of the Slack clone application.

number-readable.js 486B

12345678910111213141516171819202122
  1. 'use strict';
  2. var util = require('util')
  3. , stream = require('stream')
  4. , Readable = stream.Readable
  5. module.exports = NumberReadable;
  6. util.inherits(NumberReadable, Readable);
  7. function NumberReadable (opts) {
  8. if (!(this instanceof NumberReadable)) return new NumberReadable(opts);
  9. Readable.call(this, opts);
  10. this.idx = 0;
  11. this.to = opts.to;
  12. }
  13. NumberReadable.prototype._read = function () {
  14. if (this.idx > this.to) return this.push(null);
  15. this.push('' + this.idx++);
  16. }