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,324 @@
|
|
|
1
|
+
import type { FileView } from './file.js';
|
|
2
|
+
/**
|
|
3
|
+
* A composable test applied to each file found during a search
|
|
4
|
+
*/
|
|
5
|
+
export interface FilePredicate {
|
|
6
|
+
/**
|
|
7
|
+
* Negates this predicate
|
|
8
|
+
*
|
|
9
|
+
* @returns a predicate that matches when this one does not
|
|
10
|
+
*/
|
|
11
|
+
not(): FilePredicate;
|
|
12
|
+
/**
|
|
13
|
+
* Combines this predicate with another using logical OR
|
|
14
|
+
*
|
|
15
|
+
* @param predicate - the predicate to combine with
|
|
16
|
+
* @returns a predicate that matches when either predicate matches
|
|
17
|
+
*/
|
|
18
|
+
or(predicate: FilePredicate): FilePredicate;
|
|
19
|
+
/**
|
|
20
|
+
* Combines this predicate with another using logical AND
|
|
21
|
+
*
|
|
22
|
+
* @param predicate - the predicate to combine with
|
|
23
|
+
* @returns a predicate that matches when both predicates match
|
|
24
|
+
*/
|
|
25
|
+
and(predicate: FilePredicate): FilePredicate;
|
|
26
|
+
/**
|
|
27
|
+
* Asynchronously tests whether a file satisfies this predicate. Used by
|
|
28
|
+
* {@link FileHound.find}.
|
|
29
|
+
*
|
|
30
|
+
* @param file - the file to test
|
|
31
|
+
* @returns a Promise that fulfils with true if the file matches
|
|
32
|
+
*/
|
|
33
|
+
test(file: FileView): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Synchronously tests whether a file satisfies this predicate. Used by
|
|
36
|
+
* {@link FileHound.findSync}.
|
|
37
|
+
*
|
|
38
|
+
* @param file - the file to test
|
|
39
|
+
* @returns true if the file matches
|
|
40
|
+
* @throws `TypeError`
|
|
41
|
+
* Thrown if the predicate can only be tested asynchronously.
|
|
42
|
+
*/
|
|
43
|
+
testSync(file: FileView): boolean;
|
|
44
|
+
}
|
|
45
|
+
declare const sync: unique symbol;
|
|
46
|
+
export interface SyncFilePredicate extends FilePredicate {
|
|
47
|
+
readonly [sync]: true;
|
|
48
|
+
}
|
|
49
|
+
export declare function isSyncPredicate(predicate: FilePredicate): predicate is SyncFilePredicate;
|
|
50
|
+
export declare abstract class AbstractFilePredicate implements FilePredicate {
|
|
51
|
+
or(f: FilePredicate): FilePredicate;
|
|
52
|
+
and(f: FilePredicate): FilePredicate;
|
|
53
|
+
not(): FilePredicate;
|
|
54
|
+
test(file: FileView): Promise<boolean>;
|
|
55
|
+
abstract testSync(file: FileView): boolean;
|
|
56
|
+
}
|
|
57
|
+
export declare class And extends AbstractFilePredicate {
|
|
58
|
+
#private;
|
|
59
|
+
constructor(left: FilePredicate, right: FilePredicate);
|
|
60
|
+
get [sync](): boolean;
|
|
61
|
+
test(file: FileView): Promise<boolean>;
|
|
62
|
+
testSync(file: FileView): boolean;
|
|
63
|
+
}
|
|
64
|
+
export declare class Not extends AbstractFilePredicate {
|
|
65
|
+
#private;
|
|
66
|
+
constructor(filePredicate: FilePredicate);
|
|
67
|
+
get [sync](): boolean;
|
|
68
|
+
test(file: FileView): Promise<boolean>;
|
|
69
|
+
testSync(file: FileView): boolean;
|
|
70
|
+
}
|
|
71
|
+
export declare class Or extends AbstractFilePredicate {
|
|
72
|
+
#private;
|
|
73
|
+
constructor(left: FilePredicate, right: FilePredicate);
|
|
74
|
+
get [sync](): boolean;
|
|
75
|
+
test(file: FileView): Promise<boolean>;
|
|
76
|
+
testSync(file: FileView): boolean;
|
|
77
|
+
}
|
|
78
|
+
export declare class Extension extends AbstractFilePredicate {
|
|
79
|
+
#private;
|
|
80
|
+
readonly [sync] = true;
|
|
81
|
+
constructor(extensions: string[]);
|
|
82
|
+
testSync(file: FileView): boolean;
|
|
83
|
+
}
|
|
84
|
+
export declare class Glob extends AbstractFilePredicate {
|
|
85
|
+
#private;
|
|
86
|
+
readonly [sync] = true;
|
|
87
|
+
constructor(globPattern: string);
|
|
88
|
+
testSync(file: FileView): boolean;
|
|
89
|
+
}
|
|
90
|
+
export declare class TextMatch extends AbstractFilePredicate {
|
|
91
|
+
#private;
|
|
92
|
+
readonly [sync] = true;
|
|
93
|
+
constructor(pattern: string, flags?: string);
|
|
94
|
+
testSync(file: FileView): boolean;
|
|
95
|
+
}
|
|
96
|
+
export declare class CustomFilter extends AbstractFilePredicate {
|
|
97
|
+
#private;
|
|
98
|
+
constructor(fn: (file: FileView) => boolean | Promise<boolean>);
|
|
99
|
+
test(file: FileView): Promise<boolean>;
|
|
100
|
+
testSync(_file: FileView): boolean;
|
|
101
|
+
}
|
|
102
|
+
export declare class CustomFilterSync extends AbstractFilePredicate {
|
|
103
|
+
#private;
|
|
104
|
+
readonly [sync] = true;
|
|
105
|
+
constructor(fn: (file: FileView) => boolean);
|
|
106
|
+
testSync(file: FileView): boolean;
|
|
107
|
+
}
|
|
108
|
+
export declare class Size extends AbstractFilePredicate {
|
|
109
|
+
#private;
|
|
110
|
+
constructor(sizeExpression: string | number);
|
|
111
|
+
test(file: FileView): Promise<boolean>;
|
|
112
|
+
testSync(file: FileView): boolean;
|
|
113
|
+
}
|
|
114
|
+
export declare class Modified extends AbstractFilePredicate {
|
|
115
|
+
#private;
|
|
116
|
+
constructor(expression: string);
|
|
117
|
+
test(file: FileView): Promise<boolean>;
|
|
118
|
+
testSync(file: FileView): boolean;
|
|
119
|
+
}
|
|
120
|
+
export declare class Accessed extends AbstractFilePredicate {
|
|
121
|
+
#private;
|
|
122
|
+
constructor(expression: string);
|
|
123
|
+
test(file: FileView): Promise<boolean>;
|
|
124
|
+
testSync(file: FileView): boolean;
|
|
125
|
+
}
|
|
126
|
+
export declare class Changed extends AbstractFilePredicate {
|
|
127
|
+
#private;
|
|
128
|
+
constructor(expression: string);
|
|
129
|
+
test(file: FileView): Promise<boolean>;
|
|
130
|
+
testSync(file: FileView): boolean;
|
|
131
|
+
}
|
|
132
|
+
export declare class MatchAll extends AbstractFilePredicate {
|
|
133
|
+
readonly [sync] = true;
|
|
134
|
+
testSync(_file: FileView): boolean;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Matches files with any of the given extensions. A leading dot is optional.
|
|
138
|
+
*
|
|
139
|
+
* @param extensions - one or more extensions
|
|
140
|
+
* @returns the predicate
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* FileHound.create().match(ext('json', '.txt'));
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export declare function ext(...extensions: string[]): FilePredicate;
|
|
147
|
+
/**
|
|
148
|
+
* Matches files with any of the given extensions. A leading dot is optional.
|
|
149
|
+
*
|
|
150
|
+
* @param extensions - an array of extensions
|
|
151
|
+
* @returns the predicate
|
|
152
|
+
*/
|
|
153
|
+
export declare function ext(extensions: string[]): FilePredicate;
|
|
154
|
+
/**
|
|
155
|
+
* Matches every file
|
|
156
|
+
*
|
|
157
|
+
* @returns the predicate
|
|
158
|
+
*/
|
|
159
|
+
export declare function matchAll(): FilePredicate;
|
|
160
|
+
/**
|
|
161
|
+
* Matches files by size, using an expression of an optional operator, a
|
|
162
|
+
* whole number and an optional unit, such as `'>10kb'` or `'<= 1 mb'`.
|
|
163
|
+
*
|
|
164
|
+
* The operators are `<`, `<=`, `>`, `>=` and `==` (or `=`), which is the
|
|
165
|
+
* default. The units, in multiples of 1024, are bytes (`b`, the default),
|
|
166
|
+
* kilobytes (`k`, `kb`), megabytes (`m`, `mb`), gigabytes (`g`, `gb`) and
|
|
167
|
+
* terabytes (`t`, `tb`), in any case. Use {@link sizeEquals} for an exact
|
|
168
|
+
* number of bytes.
|
|
169
|
+
*
|
|
170
|
+
* @param expression - the size expression
|
|
171
|
+
* @returns the predicate
|
|
172
|
+
* @throws `TypeError`
|
|
173
|
+
* Thrown if the expression is not a string.
|
|
174
|
+
* @throws `ExpressionError`
|
|
175
|
+
* Thrown if the expression can't be parsed or has an unknown unit.
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* FileHound.create().match(size('>1mb'));
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
export declare function size(expression: string): FilePredicate;
|
|
182
|
+
/**
|
|
183
|
+
* Matches files of an exact size
|
|
184
|
+
*
|
|
185
|
+
* @param bytes - the size in bytes
|
|
186
|
+
* @returns the predicate
|
|
187
|
+
* @throws `RangeError`
|
|
188
|
+
* Thrown if bytes is negative or not an integer.
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* FileHound.create().match(sizeEquals(1024));
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
export declare function sizeEquals(bytes: number): FilePredicate;
|
|
195
|
+
/**
|
|
196
|
+
* Matches files with a size of zero bytes
|
|
197
|
+
*
|
|
198
|
+
* @returns the predicate
|
|
199
|
+
*/
|
|
200
|
+
export declare function isEmpty(): FilePredicate;
|
|
201
|
+
/**
|
|
202
|
+
* Matches files whose path, relative to the search path, satisfies a glob
|
|
203
|
+
* pattern. Patterns follow Node's `path.matchesGlob` and `fs.glob` rules:
|
|
204
|
+
* `*.json` matches only the top level of the search path, and a leading `**`
|
|
205
|
+
* segment matches at any depth. Wildcards, including `**`, do not match names
|
|
206
|
+
* beginning with a dot.
|
|
207
|
+
*
|
|
208
|
+
* @param globPattern - the glob pattern
|
|
209
|
+
* @returns the predicate
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* FileHound.create().match(glob('*.json'));
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export declare function glob(globPattern: string): FilePredicate;
|
|
216
|
+
/**
|
|
217
|
+
* Matches files using a custom function, which may be asynchronous. Can only
|
|
218
|
+
* be used with {@link FileHound.find}; use {@link applyFilterSync} with
|
|
219
|
+
* {@link FileHound.findSync}.
|
|
220
|
+
*
|
|
221
|
+
* @param fn - returns, or fulfils with, true for files to include
|
|
222
|
+
* @returns the predicate
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* FileHound.create().match(applyFilter(async file => await file.size() > 0));
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export declare function applyFilter(fn: (file: FileView) => boolean | Promise<boolean>): FilePredicate;
|
|
229
|
+
/**
|
|
230
|
+
* Matches files using a synchronous custom function. Can be used with both
|
|
231
|
+
* {@link FileHound.find} and {@link FileHound.findSync}.
|
|
232
|
+
*
|
|
233
|
+
* @param fn - returns true for files to include
|
|
234
|
+
* @returns the predicate
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* FileHound.create().match(applyFilterSync(file => file.sizeSync() > 0));
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
export declare function applyFilterSync(fn: (file: FileView) => boolean): FilePredicate;
|
|
241
|
+
/**
|
|
242
|
+
* Matches files whose path satisfies a regular expression pattern
|
|
243
|
+
*
|
|
244
|
+
* @param pattern - the regular expression pattern
|
|
245
|
+
* @returns the predicate
|
|
246
|
+
*/
|
|
247
|
+
export declare function like(pattern: string): FilePredicate;
|
|
248
|
+
/**
|
|
249
|
+
* Excludes files whose path satisfies any of the given regular expression patterns
|
|
250
|
+
*
|
|
251
|
+
* @remarks
|
|
252
|
+
* Used with {@link FileHound.match}, a discarded directory is left out of the
|
|
253
|
+
* results but still searched. To keep the search out of it, pass its name
|
|
254
|
+
* to {@link FileHound.skipDirectories} instead.
|
|
255
|
+
*
|
|
256
|
+
* @param patterns - one or more regular expression patterns
|
|
257
|
+
* @returns the predicate
|
|
258
|
+
* @example
|
|
259
|
+
* ```ts
|
|
260
|
+
* FileHound.create().match(discard('node_modules', '\\.git'));
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
export declare function discard(...patterns: string[]): FilePredicate;
|
|
264
|
+
/**
|
|
265
|
+
* Matches files by when they were last modified, using an expression of their
|
|
266
|
+
* age: an optional operator, a whole number and an optional unit, such as
|
|
267
|
+
* `'<2 days'`, `'>8h'` or `'>=1 week'`.
|
|
268
|
+
*
|
|
269
|
+
* The operators are `<`, `<=`, `>`, `>=` and `==` (or `=`), which is the
|
|
270
|
+
* default. The units are minutes (`m`, `min`, `mins`, `minute`, `minutes`),
|
|
271
|
+
* hours (`h`, `hour`, `hours`), days (`d`, `day`, `days`, the default) and
|
|
272
|
+
* weeks (`w`, `week`, `weeks`), in any case.
|
|
273
|
+
*
|
|
274
|
+
* @remarks
|
|
275
|
+
* Ages are compared in whole units, like `find -mtime`: a file modified two
|
|
276
|
+
* and a half days ago is 2 days old, so it matches `'=2 days'`, `'>=2 days'`
|
|
277
|
+
* and `'<3 days'`, but not `'>2 days'`. Days and weeks are calendar days, so
|
|
278
|
+
* stay correct across daylight saving changes. Ages are measured when each
|
|
279
|
+
* file is tested.
|
|
280
|
+
*
|
|
281
|
+
* @param expression - the age expression
|
|
282
|
+
* @returns the predicate
|
|
283
|
+
* @throws `TypeError`
|
|
284
|
+
* Thrown if the expression is not a string.
|
|
285
|
+
* @throws `ExpressionError`
|
|
286
|
+
* Thrown if the expression can't be parsed or has an unknown unit.
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* FileHound.create().match(modified('<2 days'));
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
export declare function modified(expression: string): FilePredicate;
|
|
293
|
+
/**
|
|
294
|
+
* Matches files by when they were last accessed, using an age expression as
|
|
295
|
+
* for {@link modified}
|
|
296
|
+
*
|
|
297
|
+
* @param expression - the age expression
|
|
298
|
+
* @returns the predicate
|
|
299
|
+
* @throws `TypeError`
|
|
300
|
+
* Thrown if the expression is not a string.
|
|
301
|
+
* @throws `ExpressionError`
|
|
302
|
+
* Thrown if the expression can't be parsed or has an unknown unit.
|
|
303
|
+
*/
|
|
304
|
+
export declare function accessed(expression: string): FilePredicate;
|
|
305
|
+
/**
|
|
306
|
+
* Matches files by when their status, such as their permissions, last
|
|
307
|
+
* changed, using an age expression as for {@link modified}
|
|
308
|
+
*
|
|
309
|
+
* @param expression - the age expression
|
|
310
|
+
* @returns the predicate
|
|
311
|
+
* @throws `TypeError`
|
|
312
|
+
* Thrown if the expression is not a string.
|
|
313
|
+
* @throws `ExpressionError`
|
|
314
|
+
* Thrown if the expression can't be parsed or has an unknown unit.
|
|
315
|
+
*/
|
|
316
|
+
export declare function changed(expression: string): FilePredicate;
|
|
317
|
+
/**
|
|
318
|
+
* Negates a predicate
|
|
319
|
+
*
|
|
320
|
+
* @param fn - the predicate to negate
|
|
321
|
+
* @returns a predicate that matches when the given one does not
|
|
322
|
+
*/
|
|
323
|
+
export declare function not(fn: FilePredicate): FilePredicate;
|
|
324
|
+
export {};
|