.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / fast-glob / out / providers / reader-stream.js
1 "use strict";\r
2 var __extends = (this && this.__extends) || (function () {\r
3     var extendStatics = function (d, b) {\r
4         extendStatics = Object.setPrototypeOf ||\r
5             ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r
6             function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r
7         return extendStatics(d, b);\r
8     };\r
9     return function (d, b) {\r
10         extendStatics(d, b);\r
11         function __() { this.constructor = d; }\r
12         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r
13     };\r
14 })();\r
15 Object.defineProperty(exports, "__esModule", { value: true });\r
16 var stream = require("stream");\r
17 var readdir = require("@mrmlnc/readdir-enhanced");\r
18 var reader_1 = require("./reader");\r
19 var fs_stream_1 = require("../adapters/fs-stream");\r
20 var TransformStream = /** @class */ (function (_super) {\r
21     __extends(TransformStream, _super);\r
22     function TransformStream(reader) {\r
23         var _this = _super.call(this, { objectMode: true }) || this;\r
24         _this.reader = reader;\r
25         return _this;\r
26     }\r
27     TransformStream.prototype._transform = function (entry, _encoding, callback) {\r
28         callback(null, this.reader.transform(entry));\r
29     };\r
30     return TransformStream;\r
31 }(stream.Transform));\r
32 var ReaderStream = /** @class */ (function (_super) {\r
33     __extends(ReaderStream, _super);\r
34     function ReaderStream() {\r
35         return _super !== null && _super.apply(this, arguments) || this;\r
36     }\r
37     Object.defineProperty(ReaderStream.prototype, "fsAdapter", {\r
38         /**\r
39          * Returns FileSystem adapter.\r
40          */\r
41         get: function () {\r
42             return new fs_stream_1.default(this.options);\r
43         },\r
44         enumerable: true,\r
45         configurable: true\r
46     });\r
47     /**\r
48      * Use stream API to read entries for Task.\r
49      */\r
50     ReaderStream.prototype.read = function (task) {\r
51         var _this = this;\r
52         var root = this.getRootDirectory(task);\r
53         var options = this.getReaderOptions(task);\r
54         var transform = new TransformStream(this);\r
55         var readable = this.api(root, task, options);\r
56         return readable\r
57             .on('error', function (err) { return _this.isEnoentCodeError(err) ? null : transform.emit('error', err); })\r
58             .pipe(transform);\r
59     };\r
60     /**\r
61      * Returns founded paths.\r
62      */\r
63     ReaderStream.prototype.api = function (root, task, options) {\r
64         if (task.dynamic) {\r
65             return this.dynamicApi(root, options);\r
66         }\r
67         return this.staticApi(task, options);\r
68     };\r
69     /**\r
70      * Api for dynamic tasks.\r
71      */\r
72     ReaderStream.prototype.dynamicApi = function (root, options) {\r
73         return readdir.readdirStreamStat(root, options);\r
74     };\r
75     /**\r
76      * Api for static tasks.\r
77      */\r
78     ReaderStream.prototype.staticApi = function (task, options) {\r
79         return this.fsAdapter.read(task.patterns, options.filter);\r
80     };\r
81     return ReaderStream;\r
82 }(reader_1.default));\r
83 exports.default = ReaderStream;\r