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:
895 bytes
|
Line | |
---|
1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | const async_1 = require("../readers/async");
|
---|
4 | class AsyncProvider {
|
---|
5 | constructor(_root, _settings) {
|
---|
6 | this._root = _root;
|
---|
7 | this._settings = _settings;
|
---|
8 | this._reader = new async_1.default(this._root, this._settings);
|
---|
9 | this._storage = [];
|
---|
10 | }
|
---|
11 | read(callback) {
|
---|
12 | this._reader.onError((error) => {
|
---|
13 | callFailureCallback(callback, error);
|
---|
14 | });
|
---|
15 | this._reader.onEntry((entry) => {
|
---|
16 | this._storage.push(entry);
|
---|
17 | });
|
---|
18 | this._reader.onEnd(() => {
|
---|
19 | callSuccessCallback(callback, this._storage);
|
---|
20 | });
|
---|
21 | this._reader.read();
|
---|
22 | }
|
---|
23 | }
|
---|
24 | exports.default = AsyncProvider;
|
---|
25 | function callFailureCallback(callback, error) {
|
---|
26 | callback(error);
|
---|
27 | }
|
---|
28 | function callSuccessCallback(callback, entries) {
|
---|
29 | callback(null, entries);
|
---|
30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.