base_stream.js 454 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. const stream = require('stream');
  3. class BaseStream extends stream.Readable {
  4. addEntry(/* entry, opts */) {
  5. throw new Error('.addEntry not implemented in sub class!');
  6. }
  7. _read() {}
  8. emit(event, data) {
  9. if (event === 'error') {
  10. const error = data;
  11. if (error.name === 'Error') {
  12. error.name = this.constructor.name + 'Error';
  13. }
  14. }
  15. super.emit(event, data);
  16. }
  17. }
  18. module.exports = BaseStream;