source: trip-planner-front/node_modules/globby/index.d.ts@ bdd6491

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

initial commit

  • Property mode set to 100644
File size: 5.9 KB
Line 
1import {Options as FastGlobOptions, Entry as FastGlobEntry} from 'fast-glob';
2
3declare namespace globby {
4 type ExpandDirectoriesOption =
5 | boolean
6 | readonly string[]
7 | {files?: readonly string[]; extensions?: readonly string[]};
8
9 type Entry = FastGlobEntry;
10
11 interface GlobbyOptions extends FastGlobOptions {
12 /**
13 If set to `true`, `globby` will automatically glob directories for you. If you define an `Array` it will only glob files that matches the patterns inside the `Array`. You can also define an `Object` with `files` and `extensions` like in the example below.
14
15 Note that if you set this option to `false`, you won't get back matched directories unless you set `onlyFiles: false`.
16
17 @default true
18
19 @example
20 ```
21 import globby = require('globby');
22
23 (async () => {
24 const paths = await globby('images', {
25 expandDirectories: {
26 files: ['cat', 'unicorn', '*.jpg'],
27 extensions: ['png']
28 }
29 });
30
31 console.log(paths);
32 //=> ['cat.png', 'unicorn.png', 'cow.jpg', 'rainbow.jpg']
33 })();
34 ```
35 */
36 readonly expandDirectories?: ExpandDirectoriesOption;
37
38 /**
39 Respect ignore patterns in `.gitignore` files that apply to the globbed files.
40
41 @default false
42 */
43 readonly gitignore?: boolean;
44 }
45
46 interface GlobTask {
47 readonly pattern: string;
48 readonly options: GlobbyOptions;
49 }
50
51 interface GitignoreOptions {
52 readonly cwd?: string;
53 readonly ignore?: readonly string[];
54 }
55
56 type FilterFunction = (path: string) => boolean;
57}
58
59interface Gitignore {
60 /**
61 @returns A filter function indicating whether a given path is ignored via a `.gitignore` file.
62 */
63 sync: (options?: globby.GitignoreOptions) => globby.FilterFunction;
64
65 /**
66 `.gitignore` files matched by the ignore config are not used for the resulting filter function.
67
68 @returns A filter function indicating whether a given path is ignored via a `.gitignore` file.
69
70 @example
71 ```
72 import {gitignore} from 'globby';
73
74 (async () => {
75 const isIgnored = await gitignore();
76 console.log(isIgnored('some/file'));
77 })();
78 ```
79 */
80 (options?: globby.GitignoreOptions): Promise<globby.FilterFunction>;
81}
82
83declare const globby: {
84 /**
85 Find files and directories using glob patterns.
86
87 Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
88
89 @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
90 @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
91 @returns The matching paths.
92 */
93 sync: ((
94 patterns: string | readonly string[],
95 options: globby.GlobbyOptions & {objectMode: true}
96 ) => globby.Entry[]) & ((
97 patterns: string | readonly string[],
98 options?: globby.GlobbyOptions
99 ) => string[]);
100
101 /**
102 Find files and directories using glob patterns.
103
104 Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
105
106 @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
107 @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
108 @returns The stream of matching paths.
109
110 @example
111 ```
112 import globby = require('globby');
113
114 (async () => {
115 for await (const path of globby.stream('*.tmp')) {
116 console.log(path);
117 }
118 })();
119 ```
120 */
121 stream: (
122 patterns: string | readonly string[],
123 options?: globby.GlobbyOptions
124 ) => NodeJS.ReadableStream;
125
126 /**
127 Note that you should avoid running the same tasks multiple times as they contain a file system cache. Instead, run this method each time to ensure file system changes are taken into consideration.
128
129 @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
130 @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
131 @returns An object in the format `{pattern: string, options: object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages.
132 */
133 generateGlobTasks: (
134 patterns: string | readonly string[],
135 options?: globby.GlobbyOptions
136 ) => globby.GlobTask[];
137
138 /**
139 Note that the options affect the results.
140
141 This function is backed by [`fast-glob`](https://github.com/mrmlnc/fast-glob#isdynamicpatternpattern-options).
142
143 @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
144 @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3).
145 @returns Whether there are any special glob characters in the `patterns`.
146 */
147 hasMagic: (
148 patterns: string | readonly string[],
149 options?: FastGlobOptions
150 ) => boolean;
151
152 readonly gitignore: Gitignore;
153
154 (
155 patterns: string | readonly string[],
156 options: globby.GlobbyOptions & {objectMode: true}
157 ): Promise<globby.Entry[]>;
158
159 /**
160 Find files and directories using glob patterns.
161
162 Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
163
164 @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
165 @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
166 @returns The matching paths.
167
168 @example
169 ```
170 import globby = require('globby');
171
172 (async () => {
173 const paths = await globby(['*', '!cake']);
174
175 console.log(paths);
176 //=> ['unicorn', 'rainbow']
177 })();
178 ```
179 */
180 (
181 patterns: string | readonly string[],
182 options?: globby.GlobbyOptions
183 ): Promise<string[]>;
184};
185
186export = globby;
Note: See TracBrowser for help on using the repository browser.