filehound 2.0.0-beta.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -11
- package/dist/arrays.d.ts +1 -0
- package/dist/arrays.js +4 -0
- package/dist/file.d.ts +108 -0
- package/dist/file.js +184 -0
- package/dist/filehound.d.ts +356 -0
- package/dist/filehound.js +498 -0
- package/dist/files.d.ts +4 -0
- package/dist/files.js +37 -0
- package/dist/filetype.d.ts +10 -0
- package/dist/filetype.js +9 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/matchers.d.ts +324 -0
- package/dist/matchers.js +419 -0
- package/dist/walker/async.d.ts +4 -0
- package/dist/walker/async.js +237 -0
- package/dist/walker/heap.d.ts +7 -0
- package/dist/walker/heap.js +49 -0
- package/dist/walker/sync.d.ts +4 -0
- package/dist/walker/sync.js +66 -0
- package/dist/walker/walk.d.ts +33 -0
- package/dist/walker/walk.js +80 -0
- package/package.json +45 -48
- package/.github/stale.yml +0 -42
- package/.travis.yml +0 -8
- package/.vscode/launch.json +0 -21
- package/.vscode/settings.json +0 -3
- package/CONTRIBUTING.md +0 -8
- package/_config.yml +0 -1
- package/coverage/coverage.raw.json +0 -1
- package/coverage/lcov-report/arrays.ts.html +0 -98
- package/coverage/lcov-report/base.css +0 -212
- package/coverage/lcov-report/filehound.ts.html +0 -2078
- package/coverage/lcov-report/files.ts.html +0 -260
- package/coverage/lcov-report/functions.ts.html +0 -122
- package/coverage/lcov-report/index.html +0 -132
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -1
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -158
- package/coverage/lcov.info +0 -378
- package/dist/src/arrays.js +0 -15
- package/dist/src/arrays.js.map +0 -1
- package/dist/src/asyncWalker.js +0 -59
- package/dist/src/asyncWalker.js.map +0 -1
- package/dist/src/bind.js +0 -15
- package/dist/src/bind.js.map +0 -1
- package/dist/src/filehound.js +0 -597
- package/dist/src/filehound.js.map +0 -1
- package/dist/src/files.js +0 -60
- package/dist/src/files.js.map +0 -1
- package/dist/src/matcher.js +0 -51
- package/dist/src/matcher.js.map +0 -1
- package/dist/src/syncWalker.js +0 -47
- package/dist/src/syncWalker.js.map +0 -1
- package/dist/src/walkAsync.js +0 -33
- package/dist/src/walkAsync.js.map +0 -1
- package/dist/src/walkSync.js +0 -21
- package/dist/src/walkSync.js.map +0 -1
- package/dist/src/walker/walk.js +0 -68
- package/dist/src/walker/walk.js.map +0 -1
- package/dist/src/walker/walkAsync.js +0 -33
- package/dist/src/walker/walkAsync.js.map +0 -1
- package/dist/src/walker/walkSync.js +0 -21
- package/dist/src/walker/walkSync.js.map +0 -1
- package/dist/test/filehound.js +0 -872
- package/dist/test/filehound.js.map +0 -1
- package/dist/test/files.js +0 -29
- package/dist/test/files.js.map +0 -1
- package/docconfig/jsdoc.json +0 -26
- package/docconfig/template/LICENSE +0 -61
- package/docconfig/template/README.md +0 -86
- package/docconfig/template/package.json +0 -22
- package/docconfig/template/publish.js +0 -676
- package/docconfig/template/static/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docconfig/template/static/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/docconfig/template/static/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docconfig/template/static/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docconfig/template/static/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/docconfig/template/static/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docconfig/template/static/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docconfig/template/static/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/docconfig/template/static/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docconfig/template/static/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docconfig/template/static/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/docconfig/template/static/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docconfig/template/static/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docconfig/template/static/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/docconfig/template/static/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docconfig/template/static/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docconfig/template/static/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/docconfig/template/static/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docconfig/template/static/fonts/OpenSans-Semibold-webfont.eot +0 -0
- package/docconfig/template/static/fonts/OpenSans-Semibold-webfont.svg +0 -1830
- package/docconfig/template/static/fonts/OpenSans-Semibold-webfont.ttf +0 -0
- package/docconfig/template/static/fonts/OpenSans-Semibold-webfont.woff +0 -0
- package/docconfig/template/static/fonts/OpenSans-SemiboldItalic-webfont.eot +0 -0
- package/docconfig/template/static/fonts/OpenSans-SemiboldItalic-webfont.svg +0 -1830
- package/docconfig/template/static/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
- package/docconfig/template/static/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
- package/docconfig/template/static/scripts/linenumber.js +0 -25
- package/docconfig/template/static/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docconfig/template/static/scripts/prettify/lang-css.js +0 -2
- package/docconfig/template/static/scripts/prettify/prettify.js +0 -28
- package/docconfig/template/static/styles/jsdoc-default.css +0 -605
- package/docconfig/template/static/styles/prettify-jsdoc.css +0 -111
- package/docconfig/template/static/styles/prettify-tomorrow.css +0 -132
- package/docconfig/template/tmpl/augments.tmpl +0 -10
- package/docconfig/template/tmpl/container.tmpl +0 -183
- package/docconfig/template/tmpl/details.tmpl +0 -143
- package/docconfig/template/tmpl/example.tmpl +0 -2
- package/docconfig/template/tmpl/examples.tmpl +0 -13
- package/docconfig/template/tmpl/exceptions.tmpl +0 -32
- package/docconfig/template/tmpl/layout.tmpl +0 -47
- package/docconfig/template/tmpl/mainpage.tmpl +0 -10
- package/docconfig/template/tmpl/members.tmpl +0 -38
- package/docconfig/template/tmpl/method.tmpl +0 -105
- package/docconfig/template/tmpl/params.tmpl +0 -124
- package/docconfig/template/tmpl/properties.tmpl +0 -108
- package/docconfig/template/tmpl/returns.tmpl +0 -19
- package/docconfig/template/tmpl/source.tmpl +0 -8
- package/docconfig/template/tmpl/tutorial.tmpl +0 -19
- package/docconfig/template/tmpl/type.tmpl +0 -7
- package/docs/FileHound.html +0 -3079
- package/docs/FileHound_modified.html +0 -245
- package/docs/_config.yml +0 -1
- package/docs/filehound.js.html +0 -697
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Semibold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Semibold-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Semibold-webfont.ttf +0 -0
- package/docs/fonts/OpenSans-Semibold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-SemiboldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-SemiboldItalic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
- package/docs/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
- package/docs/global.html +0 -288
- package/docs/index.html +0 -154
- package/docs/scripts/linenumber.js +0 -25
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/scripts/prettify/lang-css.js +0 -2
- package/docs/scripts/prettify/prettify.js +0 -28
- package/docs/styles/jsdoc-default.css +0 -605
- package/docs/styles/prettify-jsdoc.css +0 -111
- package/docs/styles/prettify-tomorrow.css +0 -132
- package/docs.md +0 -164
- package/index.js +0 -1
- package/issue_template.md +0 -6
- package/test/filehound.ts +0 -1076
- package/test/files.ts +0 -29
- package/test/fixtures/custom/failed.txt +0 -0
- package/test/fixtures/custom/passed.txt +0 -0
- package/test/fixtures/deeplyNested/c.json +0 -0
- package/test/fixtures/deeplyNested/d.json +0 -0
- package/test/fixtures/deeplyNested/mydir/e.json +0 -0
- package/test/fixtures/deeplyNested/mydir/mydir2/f.json +0 -0
- package/test/fixtures/deeplyNested/mydir/mydir2/mydir3/mydir4/failed.json +0 -0
- package/test/fixtures/deeplyNested/mydir/mydir2/mydir3/z.json +0 -0
- package/test/fixtures/deeplyNested/mydir/mydir2/y.json +0 -0
- package/test/fixtures/deeplyNestedWithHiddenDir/c.json +0 -0
- package/test/fixtures/deeplyNestedWithHiddenDir/d.json +0 -0
- package/test/fixtures/deeplyNestedWithHiddenDir/mydir/e.json +0 -0
- package/test/fixtures/deeplyNestedWithHiddenDir/mydir/mydir2/f.json +0 -0
- package/test/fixtures/deeplyNestedWithHiddenDir/mydir/mydir2/mydir3/mydir4/.mydir5/.keep +0 -0
- package/test/fixtures/deeplyNestedWithHiddenDir/mydir/mydir2/mydir3/mydir4/failed.json +0 -0
- package/test/fixtures/deeplyNestedWithHiddenDir/mydir/mydir2/mydir3/z.json +0 -0
- package/test/fixtures/deeplyNestedWithHiddenDir/mydir/mydir2/y.json +0 -0
- package/test/fixtures/ext/Dummy.java +0 -0
- package/test/fixtures/ext/Dumpy.go +0 -0
- package/test/fixtures/ext/dummy.json +0 -0
- package/test/fixtures/ext/dummy.txt +0 -0
- package/test/fixtures/justFiles/a.json +0 -0
- package/test/fixtures/justFiles/b.json +0 -0
- package/test/fixtures/justFiles/dummy.txt +0 -0
- package/test/fixtures/mixed/a.json +0 -0
- package/test/fixtures/mixed/aabbcc.json +0 -0
- package/test/fixtures/mixed/ab.json +0 -0
- package/test/fixtures/mixed/z.json +0 -0
- package/test/fixtures/nested/.hidden1/bad.txt +0 -0
- package/test/fixtures/nested/c.json +0 -0
- package/test/fixtures/nested/d.json +0 -0
- package/test/fixtures/nested/mydir/e.json +0 -0
- package/test/fixtures/sizes/10b.txt +0 -0
- package/test/fixtures/sizes/1b.txt +0 -0
- package/test/fixtures/sizes/1k.txt +0 -0
- package/test/fixtures/sizes/2k.txt +0 -0
- package/test/fixtures/visibility/.hidden/.hidden.json +0 -0
- package/test/fixtures/visibility/.hidden/visible.json +0 -3
- package/test/fixtures/visibility/.hidden.json +0 -3
- package/test/fixtures/visibility/visible/.hidden.json +0 -3
- package/test/fixtures/visibility/visible.json +0 -3
- package/test/mocha.opts +0 -4
- package/tsconfig.json +0 -16
- package/tslint.json +0 -44
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import type { Stats } from 'node:fs';
|
|
3
|
+
import { type FilePredicate } from './matchers.js';
|
|
4
|
+
import { FileType } from './filetype.js';
|
|
5
|
+
/**
|
|
6
|
+
* Options for {@link FileHound.find} and {@link FileHound.iterate}.
|
|
7
|
+
*/
|
|
8
|
+
export type SearchOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* Stops the search when aborted. The search then rejects with the
|
|
11
|
+
* signal's reason, which is an `AbortError` unless another is given.
|
|
12
|
+
*/
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A match returned when {@link FileHound.includeFileStats} is set.
|
|
17
|
+
*/
|
|
18
|
+
export type FileWithStats = {
|
|
19
|
+
/** the path of the matching file */
|
|
20
|
+
path: string;
|
|
21
|
+
/** the file's stats, as returned by `fs.stat` */
|
|
22
|
+
stats: Stats;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A fluent query for searching the file system.
|
|
26
|
+
*
|
|
27
|
+
* @typeParam T - the type of each match: a path, or a {@link FileWithStats}
|
|
28
|
+
* when {@link FileHound.includeFileStats} is set
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Configure a query by chaining methods, then run it with {@link FileHound.find}
|
|
32
|
+
* or {@link FileHound.findSync}. Once a search has started the query is locked
|
|
33
|
+
* and can no longer be modified.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { FileHound, ext } from 'filehound';
|
|
38
|
+
*
|
|
39
|
+
* const files = await FileHound.create()
|
|
40
|
+
* .paths('/tmp')
|
|
41
|
+
* .match(ext('json'))
|
|
42
|
+
* .depth(1)
|
|
43
|
+
* .find();
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare class FileHound<T = string> extends EventEmitter {
|
|
47
|
+
#private;
|
|
48
|
+
constructor();
|
|
49
|
+
/**
|
|
50
|
+
* Static factory method to create an instance of FileHound
|
|
51
|
+
*
|
|
52
|
+
* @returns a new FileHound instance
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { FileHound } from 'filehound';
|
|
56
|
+
*
|
|
57
|
+
* const filehound = FileHound.create();
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
static create(): FileHound;
|
|
61
|
+
/**
|
|
62
|
+
* Executes one or more FileHound queries and combines their results
|
|
63
|
+
*
|
|
64
|
+
* @param args - the FileHound instances to execute
|
|
65
|
+
* @returns a Promise of all matches. If the Promise fulfils,
|
|
66
|
+
* the fulfilment value is an array of all files matched by any of the queries
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* import { FileHound } from 'filehound';
|
|
70
|
+
*
|
|
71
|
+
* const files = await FileHound.any(fh1, fh2);
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
static any<T>(...args: FileHound<T>[]): Promise<T[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Defines the search paths: the directories to search. Duplicate paths are
|
|
77
|
+
* removed and each path is normalised. Defaults to the current working directory.
|
|
78
|
+
*
|
|
79
|
+
* @param paths - one or more directory paths
|
|
80
|
+
* @returns the FileHound instance
|
|
81
|
+
* @throws `Error`
|
|
82
|
+
* Thrown if the query is locked because a search has started. A path that
|
|
83
|
+
* doesn't exist, or isn't a directory, is rejected when the search runs.
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* import { FileHound } from 'filehound';
|
|
87
|
+
*
|
|
88
|
+
* const files = await FileHound.create()
|
|
89
|
+
* .paths('/tmp', '/etc') // or ['/tmp', '/etc']
|
|
90
|
+
* .find();
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
paths(...paths: string[]): this;
|
|
94
|
+
/**
|
|
95
|
+
* Defines the search paths from an array.
|
|
96
|
+
*
|
|
97
|
+
* @param paths - an array of paths
|
|
98
|
+
* @returns the FileHound instance
|
|
99
|
+
*/
|
|
100
|
+
paths(paths: string[]): this;
|
|
101
|
+
/**
|
|
102
|
+
* Specifies the criteria that files must satisfy to be included in the
|
|
103
|
+
* results. Defaults to matching all files.
|
|
104
|
+
*
|
|
105
|
+
* @param query - the predicate used to test each file
|
|
106
|
+
* @returns the FileHound instance
|
|
107
|
+
* @throws `Error`
|
|
108
|
+
* Thrown if the query is locked because a search has started.
|
|
109
|
+
* @throws `TypeError`
|
|
110
|
+
* Thrown if the query is not a valid matcher.
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* import { FileHound, ext } from 'filehound';
|
|
114
|
+
*
|
|
115
|
+
* const files = await FileHound.create()
|
|
116
|
+
* .match(ext('json'))
|
|
117
|
+
* .find();
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
match(query: FilePredicate): this;
|
|
121
|
+
/**
|
|
122
|
+
* Skips directories by name: a directory whose name matches any of the
|
|
123
|
+
* given names is neither searched nor returned. Use it to keep the search
|
|
124
|
+
* out of directories such as `node_modules`, which a {@link FileHound.match}
|
|
125
|
+
* predicate can only exclude from the results after searching them.
|
|
126
|
+
* Calling it again replaces the names.
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* Each name is matched against a directory's name only, not its path,
|
|
130
|
+
* following Node's [`path.matchesGlob`](https://nodejs.org/api/path.html#pathmatchesglobpath-pattern).
|
|
131
|
+
* A plain name, such as `'node_modules'`, matches exactly, and a glob, such
|
|
132
|
+
* as `'build-*'`, matches any name it describes. Every directory below the
|
|
133
|
+
* search paths is tested, including linked directories, but not the search
|
|
134
|
+
* paths themselves.
|
|
135
|
+
*
|
|
136
|
+
* @param names - one or more directory names or globs
|
|
137
|
+
* @returns the FileHound instance
|
|
138
|
+
* @throws `Error`
|
|
139
|
+
* Thrown if the query is locked because a search has started.
|
|
140
|
+
* @throws `RangeError`
|
|
141
|
+
* Thrown if no names are given.
|
|
142
|
+
* @throws `TypeError`
|
|
143
|
+
* Thrown if a name is not a non-empty string, or contains a path separator.
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* import { FileHound, ext } from 'filehound';
|
|
147
|
+
*
|
|
148
|
+
* const files = await FileHound.create()
|
|
149
|
+
* .skipDirectories('node_modules', '.git', 'build-*')
|
|
150
|
+
* .match(ext('js'))
|
|
151
|
+
* .find();
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
skipDirectories(...names: string[]): this;
|
|
155
|
+
/**
|
|
156
|
+
* Specify the directory search depth. If set to zero, recursive searching
|
|
157
|
+
* will be disabled. Directories at the limit are not searched, but are
|
|
158
|
+
* still returned when {@link FileHound.type} includes directories.
|
|
159
|
+
*
|
|
160
|
+
* @param depth - the maximum search depth (a non-negative integer)
|
|
161
|
+
* @returns the FileHound instance
|
|
162
|
+
* @throws `Error`
|
|
163
|
+
* Thrown if the query is locked because a search has started.
|
|
164
|
+
* @throws `RangeError`
|
|
165
|
+
* Thrown if depth is negative or not an integer.
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* import { FileHound } from 'filehound';
|
|
169
|
+
*
|
|
170
|
+
* const files = await FileHound.create()
|
|
171
|
+
* .depth(0)
|
|
172
|
+
* .find(); // array of file names only in the current directory
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
depth(depth: number): this;
|
|
176
|
+
/**
|
|
177
|
+
* Specifies the types of file system entry to return. Defaults to
|
|
178
|
+
* regular files only.
|
|
179
|
+
*
|
|
180
|
+
* @param types - one or more file types
|
|
181
|
+
* @returns the FileHound instance
|
|
182
|
+
* @throws `Error`
|
|
183
|
+
* Thrown if the query is locked because a search has started.
|
|
184
|
+
* @throws `RangeError`
|
|
185
|
+
* Thrown if no file types are given.
|
|
186
|
+
* @throws `TypeError`
|
|
187
|
+
* Thrown if an invalid file type is given.
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* import { FileHound, FileType } from 'filehound';
|
|
191
|
+
*
|
|
192
|
+
* const directories = await FileHound.create()
|
|
193
|
+
* .type(FileType.DIRECTORY)
|
|
194
|
+
* .find();
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
type(...types: FileType[]): this;
|
|
198
|
+
/**
|
|
199
|
+
* Excludes hidden files (names beginning with a dot) from the results
|
|
200
|
+
*
|
|
201
|
+
* @returns the FileHound instance
|
|
202
|
+
* @throws `Error`
|
|
203
|
+
* Thrown if the query is locked because a search has started.
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts
|
|
206
|
+
* import { FileHound } from 'filehound';
|
|
207
|
+
*
|
|
208
|
+
* const files = await FileHound.create()
|
|
209
|
+
* .ignoreHiddenFiles()
|
|
210
|
+
* .find();
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
ignoreHiddenFiles(): this;
|
|
214
|
+
/**
|
|
215
|
+
* Excludes hidden directories (names beginning with a dot), and their
|
|
216
|
+
* contents, from the search
|
|
217
|
+
*
|
|
218
|
+
* @returns the FileHound instance
|
|
219
|
+
* @throws `Error`
|
|
220
|
+
* Thrown if the query is locked because a search has started.
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* import { FileHound } from 'filehound';
|
|
224
|
+
*
|
|
225
|
+
* const files = await FileHound.create()
|
|
226
|
+
* .ignoreHiddenDirectories()
|
|
227
|
+
* .find();
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
ignoreHiddenDirectories(): this;
|
|
231
|
+
/**
|
|
232
|
+
* Excludes symbolic links from the search. Linked files are not matched
|
|
233
|
+
* and linked directories are not searched.
|
|
234
|
+
*
|
|
235
|
+
* @remarks
|
|
236
|
+
* By default, symbolic links are followed: a linked file is matched as its
|
|
237
|
+
* target and a linked directory is searched. Broken links, and links back to
|
|
238
|
+
* a directory already being searched, are always skipped.
|
|
239
|
+
*
|
|
240
|
+
* @returns the FileHound instance
|
|
241
|
+
* @throws `Error`
|
|
242
|
+
* Thrown if the query is locked because a search has started.
|
|
243
|
+
* @example
|
|
244
|
+
* ```ts
|
|
245
|
+
* import { FileHound } from 'filehound';
|
|
246
|
+
*
|
|
247
|
+
* const files = await FileHound.create()
|
|
248
|
+
* .ignoreSymlinks()
|
|
249
|
+
* .find();
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
ignoreSymlinks(): this;
|
|
253
|
+
/**
|
|
254
|
+
* Returns each match with its stats, as `{ path, stats }`, in place of
|
|
255
|
+
* its path. Stats already fetched by a predicate are reused.
|
|
256
|
+
*
|
|
257
|
+
* @returns the FileHound instance, typed to return {@link FileWithStats} matches
|
|
258
|
+
* @throws `Error`
|
|
259
|
+
* Thrown if the query is locked because a search has started.
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* import { FileHound } from 'filehound';
|
|
263
|
+
*
|
|
264
|
+
* const files = await FileHound.create()
|
|
265
|
+
* .includeFileStats()
|
|
266
|
+
* .find();
|
|
267
|
+
*
|
|
268
|
+
* files.forEach(({ path, stats }) => console.log(path, stats.size));
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
includeFileStats(): FileHound<FileWithStats>;
|
|
272
|
+
/**
|
|
273
|
+
* Asynchronously executes a file search. Once called, the query is
|
|
274
|
+
* locked and can no longer be modified.
|
|
275
|
+
*
|
|
276
|
+
* @param options - a signal to stop the search
|
|
277
|
+
* @returns a Promise of all matches. If the Promise fulfils,
|
|
278
|
+
* the fulfilment value is an array of all matching files
|
|
279
|
+
*
|
|
280
|
+
* @remarks
|
|
281
|
+
* Emits a `match` event for each matching file, an `error` event if the
|
|
282
|
+
* search fails or is aborted and an `end` event when the search completes.
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```ts
|
|
286
|
+
* import { FileHound } from 'filehound';
|
|
287
|
+
*
|
|
288
|
+
* const filehound = FileHound.create();
|
|
289
|
+
* const files = await filehound.find();
|
|
290
|
+
*
|
|
291
|
+
* console.log(files);
|
|
292
|
+
* ```
|
|
293
|
+
* @example
|
|
294
|
+
* Giving up on a search after five seconds:
|
|
295
|
+
* ```ts
|
|
296
|
+
* const files = await FileHound.create()
|
|
297
|
+
* .paths('/')
|
|
298
|
+
* .find({ signal: AbortSignal.timeout(5000) });
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
find(options?: SearchOptions): Promise<T[]>;
|
|
302
|
+
/**
|
|
303
|
+
* Asynchronously executes a file search, returning matches one at a time
|
|
304
|
+
* as they are found, in the same order as {@link FileHound.find}. Once
|
|
305
|
+
* called, the query is locked and can no longer be modified.
|
|
306
|
+
*
|
|
307
|
+
* @remarks
|
|
308
|
+
* The search runs ahead of the loop by a bounded amount, so a large search
|
|
309
|
+
* can be read without holding every match in memory. Breaking out of the
|
|
310
|
+
* loop stops the search.
|
|
311
|
+
*
|
|
312
|
+
* Emits a `match` event as each match is returned, an `error` event if the
|
|
313
|
+
* search fails or is aborted and an `end` event when the search finishes:
|
|
314
|
+
* when every match has been returned, the search fails or is aborted, or
|
|
315
|
+
* the loop is left early.
|
|
316
|
+
*
|
|
317
|
+
* @param options - a signal to stop the search
|
|
318
|
+
* @returns an async iterator of matches
|
|
319
|
+
* @example
|
|
320
|
+
* ```ts
|
|
321
|
+
* import { FileHound, ext } from 'filehound';
|
|
322
|
+
*
|
|
323
|
+
* const query = FileHound.create()
|
|
324
|
+
* .paths('/tmp')
|
|
325
|
+
* .match(ext('json'));
|
|
326
|
+
*
|
|
327
|
+
* for await (const file of query.iterate()) {
|
|
328
|
+
* console.log(file);
|
|
329
|
+
* }
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
iterate(options?: SearchOptions): AsyncGenerator<T>;
|
|
333
|
+
/**
|
|
334
|
+
* Synchronously executes a file search. Once called, the query is
|
|
335
|
+
* locked and can no longer be modified. No events are emitted.
|
|
336
|
+
*
|
|
337
|
+
* @returns an array of all matching files
|
|
338
|
+
* @example
|
|
339
|
+
* ```ts
|
|
340
|
+
* import { FileHound } from 'filehound';
|
|
341
|
+
*
|
|
342
|
+
* const filehound = FileHound.create();
|
|
343
|
+
* const files = filehound.findSync();
|
|
344
|
+
* console.log(files);
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
347
|
+
findSync(): T[];
|
|
348
|
+
/**
|
|
349
|
+
* Returns the paths that will be searched. When no depth is set, any path
|
|
350
|
+
* that is a subdirectory of another search path is removed, as it would
|
|
351
|
+
* otherwise be searched twice.
|
|
352
|
+
*
|
|
353
|
+
* @returns a copy of the search paths
|
|
354
|
+
*/
|
|
355
|
+
getPaths(): string[];
|
|
356
|
+
}
|