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:
1013 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | const stream_1 = require("../readers/stream");
|
---|
| 4 | const provider_1 = require("./provider");
|
---|
| 5 | class ProviderAsync extends provider_1.default {
|
---|
| 6 | constructor() {
|
---|
| 7 | super(...arguments);
|
---|
| 8 | this._reader = new stream_1.default(this._settings);
|
---|
| 9 | }
|
---|
| 10 | read(task) {
|
---|
| 11 | const root = this._getRootDirectory(task);
|
---|
| 12 | const options = this._getReaderOptions(task);
|
---|
| 13 | const entries = [];
|
---|
| 14 | return new Promise((resolve, reject) => {
|
---|
| 15 | const stream = this.api(root, task, options);
|
---|
| 16 | stream.once('error', reject);
|
---|
| 17 | stream.on('data', (entry) => entries.push(options.transform(entry)));
|
---|
| 18 | stream.once('end', () => resolve(entries));
|
---|
| 19 | });
|
---|
| 20 | }
|
---|
| 21 | api(root, task, options) {
|
---|
| 22 | if (task.dynamic) {
|
---|
| 23 | return this._reader.dynamic(root, options);
|
---|
| 24 | }
|
---|
| 25 | return this._reader.static(task.patterns, options);
|
---|
| 26 | }
|
---|
| 27 | }
|
---|
| 28 | exports.default = ProviderAsync;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.