Last change
on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1021 bytes
|
Line | |
---|
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;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.