rrdir 10.0.2 → 10.0.4
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 +1 -1
- package/index.js +7 -4
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
> Recursive directory reader with a delightful API
|
|
5
5
|
|
|
6
|
-
`rrdir` recursively reads a directory and returns entries within via an async iterator or async/sync as Array. It has
|
|
6
|
+
`rrdir` recursively reads a directory and returns entries within via an async iterator or async/sync as Array. It has no dependencies and can typically iterate millions of files in a matter of seconds. Memory usage is `O(1)` for the async iterator and `O(n)` for the Array variants.
|
|
7
7
|
|
|
8
8
|
## Usage
|
|
9
9
|
```console
|
package/index.js
CHANGED
|
@@ -12,6 +12,8 @@ const defaults = {
|
|
|
12
12
|
include: undefined,
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
const escRe = str => str.replace(/[|\\{}()[\]^$+*?.-]/g, "\\$&");
|
|
16
|
+
|
|
15
17
|
function makePath(entry, dir, encoding) {
|
|
16
18
|
if (encoding === "buffer") {
|
|
17
19
|
return dir === "." ? entry.name : Buffer.from([...dir, ...sepBuffer, ...entry.name]);
|
|
@@ -30,11 +32,12 @@ function build(dirent, path, stats, opts) {
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
function makeMatcher(filters) {
|
|
35
|
+
const res = filters.map(f => {
|
|
36
|
+
return new RegExp(`${escRe(f).replace(/\\\*+/g, ".*").replace(/\/\.\*/, ".*")}$`);
|
|
37
|
+
});
|
|
33
38
|
return str => {
|
|
34
|
-
for (const
|
|
35
|
-
|
|
36
|
-
const matches = re.test(str);
|
|
37
|
-
if (matches) return true;
|
|
39
|
+
for (const re of res) {
|
|
40
|
+
if (re.test(str)) return true;
|
|
38
41
|
}
|
|
39
42
|
return false;
|
|
40
43
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rrdir",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.4",
|
|
4
4
|
"description": "Recursive directory reader with a delightful API",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
6
|
"repository": "silverwind/rrdir",
|
|
@@ -15,13 +15,12 @@
|
|
|
15
15
|
"index.js"
|
|
16
16
|
],
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"eslint": "8.
|
|
19
|
-
"eslint-config-silverwind": "
|
|
18
|
+
"eslint": "8.24.0",
|
|
19
|
+
"eslint-config-silverwind": "55.0.0",
|
|
20
20
|
"jest": "29.0.3",
|
|
21
|
-
"semver": "7.3.7",
|
|
22
21
|
"tempy": "3.0.0",
|
|
23
|
-
"updates": "13.1.
|
|
24
|
-
"versions": "9.3.
|
|
22
|
+
"updates": "13.1.7",
|
|
23
|
+
"versions": "9.3.2"
|
|
25
24
|
},
|
|
26
25
|
"keywords": [
|
|
27
26
|
"recursive readdir",
|