Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stream.js 1021B

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const stream_1 = require("stream");
  4. const async_1 = require("../readers/async");
  5. class StreamProvider {
  6. constructor(_root, _settings) {
  7. this._root = _root;
  8. this._settings = _settings;
  9. this._reader = new async_1.default(this._root, this._settings);
  10. this._stream = new stream_1.Readable({
  11. objectMode: true,
  12. read: () => { },
  13. destroy: () => {
  14. if (!this._reader.isDestroyed) {
  15. this._reader.destroy();
  16. }
  17. }
  18. });
  19. }
  20. read() {
  21. this._reader.onError((error) => {
  22. this._stream.emit('error', error);
  23. });
  24. this._reader.onEntry((entry) => {
  25. this._stream.push(entry);
  26. });
  27. this._reader.onEnd(() => {
  28. this._stream.push(null);
  29. });
  30. this._reader.read();
  31. return this._stream;
  32. }
  33. }
  34. exports.default = StreamProvider;