UNPKG

2.11 kBTypeScriptView Raw
1/// <reference types="node" />
2
3import { PicomatchOptions } from "picomatch";
4import { Readable } from "streamx";
5
6declare function globStream(glob: string | string[]): Readable<globStream.Entry>;
7declare function globStream(glob: string | string[], options: globStream.Options): Readable<globStream.Entry>;
8
9declare namespace globStream {
10 export interface Entry {
11 cwd: string;
12 base: string;
13 path: string;
14 }
15
16 export type UniqueByStringPredicate = keyof Entry;
17 export type UniqueByFunctionPredicate = (entry: Entry) => string;
18
19 // Here, the settings interface provided by `picomatch` is used rather than the `anymatch` one's.
20 // This is due to the fact that `anymatch` redirects its options to `picomatch`.
21 // Furthermore, `anymatch`s type declaration of the `picomatch` options is hand-written and describes some of the available options incorrectly.
22 export interface Options extends PicomatchOptions {
23 /**
24 * Whether or not to error upon an empty singular glob.
25 */
26 allowEmpty?: boolean | undefined;
27 /**
28 * The current working directory that the glob is resolved against.
29 */
30 cwd?: string | undefined;
31 /**
32 * The root path that the glob is resolved against.
33 */
34 root?: string | undefined;
35 /**
36 * The absolute segment of the glob path that isn't a glob. This value is attached
37 * to each glob object and is useful for relative pathing.
38 */
39 base?: string | undefined;
40 /**
41 * Whether or not the {@linkcode cwd} and {@linkcode base} should be the same.
42 */
43 cwdbase?: boolean | undefined;
44 /**
45 * Filters stream to remove duplicates based on the string property name or the result of function.
46 * When using a function, the function receives the streamed
47 * data (objects containing `cwd`, `base`, `path` properties) to compare against.
48 */
49 uniqueBy?: UniqueByStringPredicate | UniqueByFunctionPredicate | undefined;
50 }
51}
52
53export = globStream;