source: trip-planner-front/node_modules/fast-glob/out/index.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.7 KB
Line 
1"use strict";
2const taskManager = require("./managers/tasks");
3const async_1 = require("./providers/async");
4const stream_1 = require("./providers/stream");
5const sync_1 = require("./providers/sync");
6const settings_1 = require("./settings");
7const utils = require("./utils");
8async function FastGlob(source, options) {
9 assertPatternsInput(source);
10 const works = getWorks(source, async_1.default, options);
11 const result = await Promise.all(works);
12 return utils.array.flatten(result);
13}
14// https://github.com/typescript-eslint/typescript-eslint/issues/60
15// eslint-disable-next-line no-redeclare
16(function (FastGlob) {
17 function sync(source, options) {
18 assertPatternsInput(source);
19 const works = getWorks(source, sync_1.default, options);
20 return utils.array.flatten(works);
21 }
22 FastGlob.sync = sync;
23 function stream(source, options) {
24 assertPatternsInput(source);
25 const works = getWorks(source, stream_1.default, options);
26 /**
27 * The stream returned by the provider cannot work with an asynchronous iterator.
28 * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
29 * This affects performance (+25%). I don't see best solution right now.
30 */
31 return utils.stream.merge(works);
32 }
33 FastGlob.stream = stream;
34 function generateTasks(source, options) {
35 assertPatternsInput(source);
36 const patterns = [].concat(source);
37 const settings = new settings_1.default(options);
38 return taskManager.generate(patterns, settings);
39 }
40 FastGlob.generateTasks = generateTasks;
41 function isDynamicPattern(source, options) {
42 assertPatternsInput(source);
43 const settings = new settings_1.default(options);
44 return utils.pattern.isDynamicPattern(source, settings);
45 }
46 FastGlob.isDynamicPattern = isDynamicPattern;
47 function escapePath(source) {
48 assertPatternsInput(source);
49 return utils.path.escape(source);
50 }
51 FastGlob.escapePath = escapePath;
52})(FastGlob || (FastGlob = {}));
53function getWorks(source, _Provider, options) {
54 const patterns = [].concat(source);
55 const settings = new settings_1.default(options);
56 const tasks = taskManager.generate(patterns, settings);
57 const provider = new _Provider(settings);
58 return tasks.map(provider.read, provider);
59}
60function assertPatternsInput(input) {
61 const source = [].concat(input);
62 const isValidSource = source.every((item) => utils.string.isString(item) && !utils.string.isEmpty(item));
63 if (!isValidSource) {
64 throw new TypeError('Patterns must be a string (non empty) or an array of strings');
65 }
66}
67module.exports = FastGlob;
Note: See TracBrowser for help on using the repository browser.