source: trip-planner-front/node_modules/fast-glob/out/providers/stream.js@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const stream_1 = require("stream");
4const stream_2 = require("../readers/stream");
5const provider_1 = require("./provider");
6class ProviderStream extends provider_1.default {
7 constructor() {
8 super(...arguments);
9 this._reader = new stream_2.default(this._settings);
10 }
11 read(task) {
12 const root = this._getRootDirectory(task);
13 const options = this._getReaderOptions(task);
14 const source = this.api(root, task, options);
15 const destination = new stream_1.Readable({ objectMode: true, read: () => { } });
16 source
17 .once('error', (error) => destination.emit('error', error))
18 .on('data', (entry) => destination.emit('data', options.transform(entry)))
19 .once('end', () => destination.emit('end'));
20 destination
21 .once('close', () => source.destroy());
22 return destination;
23 }
24 api(root, task, options) {
25 if (task.dynamic) {
26 return this._reader.dynamic(root, options);
27 }
28 return this._reader.static(task.patterns, options);
29 }
30}
31exports.default = ProviderStream;
Note: See TracBrowser for help on using the repository browser.