InStream.js 796 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @file Simple wrapper for stream.Readable, used for receiving binary data
  3. */
  4. 'use strict'
  5. var util = require('util'),
  6. stream = require('stream')
  7. /**
  8. * Represents the readable stream for binary frames
  9. * @class
  10. * @event readable
  11. * @event end
  12. */
  13. function InStream() {
  14. stream.Readable.call(this)
  15. }
  16. module.exports = InStream
  17. util.inherits(InStream, stream.Readable)
  18. /**
  19. * No logic here, the pushs are made outside _read
  20. * @private
  21. */
  22. InStream.prototype._read = function () {}
  23. /**
  24. * Add more data to the stream and fires "readable" event
  25. * @param {Buffer} data
  26. * @private
  27. */
  28. InStream.prototype.addData = function (data) {
  29. this.push(data)
  30. }
  31. /**
  32. * Indicates there is no more data to add to the stream
  33. * @private
  34. */
  35. InStream.prototype.end = function () {
  36. this.push(null)
  37. }