+++ /dev/null
-"use strict";\r
-var __extends = (this && this.__extends) || (function () {\r
- var extendStatics = function (d, b) {\r
- extendStatics = Object.setPrototypeOf ||\r
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r
- return extendStatics(d, b);\r
- };\r
- return function (d, b) {\r
- extendStatics(d, b);\r
- function __() { this.constructor = d; }\r
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r
- };\r
-})();\r
-Object.defineProperty(exports, "__esModule", { value: true });\r
-var readdir = require("@mrmlnc/readdir-enhanced");\r
-var reader_1 = require("./reader");\r
-var fs_stream_1 = require("../adapters/fs-stream");\r
-var ReaderAsync = /** @class */ (function (_super) {\r
- __extends(ReaderAsync, _super);\r
- function ReaderAsync() {\r
- return _super !== null && _super.apply(this, arguments) || this;\r
- }\r
- Object.defineProperty(ReaderAsync.prototype, "fsAdapter", {\r
- /**\r
- * Returns FileSystem adapter.\r
- */\r
- get: function () {\r
- return new fs_stream_1.default(this.options);\r
- },\r
- enumerable: true,\r
- configurable: true\r
- });\r
- /**\r
- * Use async API to read entries for Task.\r
- */\r
- ReaderAsync.prototype.read = function (task) {\r
- var _this = this;\r
- var root = this.getRootDirectory(task);\r
- var options = this.getReaderOptions(task);\r
- var entries = [];\r
- return new Promise(function (resolve, reject) {\r
- var stream = _this.api(root, task, options);\r
- stream.on('error', function (err) {\r
- _this.isEnoentCodeError(err) ? resolve([]) : reject(err);\r
- stream.pause();\r
- });\r
- stream.on('data', function (entry) { return entries.push(_this.transform(entry)); });\r
- stream.on('end', function () { return resolve(entries); });\r
- });\r
- };\r
- /**\r
- * Returns founded paths.\r
- */\r
- ReaderAsync.prototype.api = function (root, task, options) {\r
- if (task.dynamic) {\r
- return this.dynamicApi(root, options);\r
- }\r
- return this.staticApi(task, options);\r
- };\r
- /**\r
- * Api for dynamic tasks.\r
- */\r
- ReaderAsync.prototype.dynamicApi = function (root, options) {\r
- return readdir.readdirStreamStat(root, options);\r
- };\r
- /**\r
- * Api for static tasks.\r
- */\r
- ReaderAsync.prototype.staticApi = function (task, options) {\r
- return this.fsAdapter.read(task.patterns, options.filter);\r
- };\r
- return ReaderAsync;\r
-}(reader_1.default));\r
-exports.default = ReaderAsync;\r