Debian Codegraph @

nodelib-fswalk/out/providers/async.js

raw
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 }