rrdir 8.2.1 → 9.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 +6 -6
- package/index.js +12 -14
- package/package.json +12 -14
package/README.md
CHANGED
|
@@ -10,26 +10,26 @@
|
|
|
10
10
|
npm i rrdir
|
|
11
11
|
```
|
|
12
12
|
```js
|
|
13
|
-
|
|
13
|
+
import {rrdir, rrdirAsync, rrdirSync} from "rrdir";
|
|
14
14
|
|
|
15
15
|
for await (const entry of rrdir("dir")) {
|
|
16
16
|
// => {path: 'dir/file', directory: false, symlink: false}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const entries = await
|
|
19
|
+
const entries = await rrdirAsync("dir");
|
|
20
20
|
// => [{path: 'dir/file', directory: false, symlink: false}]
|
|
21
21
|
|
|
22
|
-
const entries =
|
|
22
|
+
const entries = rrdirSync("dir");
|
|
23
23
|
// => [{path: 'dir/file', directory: false, symlink: false}]
|
|
24
24
|
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## API
|
|
28
28
|
### `rrdir(dir, [options])`
|
|
29
|
-
### `
|
|
30
|
-
### `
|
|
29
|
+
### `rrdirAsync(dir, [options])`
|
|
30
|
+
### `rrdirSync(dir, [options])`
|
|
31
31
|
|
|
32
|
-
`rrdir` is an async iterator which yields `entry`. `
|
|
32
|
+
`rrdir` is an async iterator which yields `entry`. `rrdirAsync` and `rrdirSync` return an Array of `entry`.
|
|
33
33
|
|
|
34
34
|
#### `dir` *String* | *Buffer*
|
|
35
35
|
|
package/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const {sep} = require("path");
|
|
6
|
-
const picomatch = require("picomatch");
|
|
1
|
+
import {readdir, stat, lstat} from "fs/promises";
|
|
2
|
+
import {readdirSync, statSync, lstatSync} from "fs";
|
|
3
|
+
import {sep} from "path";
|
|
4
|
+
import picomatch from "picomatch";
|
|
7
5
|
|
|
8
6
|
const sepBuffer = Buffer.from(sep);
|
|
9
7
|
|
|
@@ -42,7 +40,7 @@ function makeMatchers({include, exclude, match}) {
|
|
|
42
40
|
};
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
|
|
43
|
+
export async function* rrdir(dir, opts = {}, {includeMatcher, excludeMatcher, encoding} = {}) {
|
|
46
44
|
if (includeMatcher === undefined) {
|
|
47
45
|
opts = Object.assign({}, defaults, opts);
|
|
48
46
|
({includeMatcher, excludeMatcher} = makeMatchers(opts));
|
|
@@ -94,9 +92,9 @@ const rrdir = module.exports = async function* (dir, opts = {}, {includeMatcher,
|
|
|
94
92
|
|
|
95
93
|
if (recurse) yield* await rrdir(path, opts, {includeMatcher, excludeMatcher, encoding});
|
|
96
94
|
}
|
|
97
|
-
}
|
|
95
|
+
}
|
|
98
96
|
|
|
99
|
-
|
|
97
|
+
export async function rrdirAsync(dir, opts = {}, {includeMatcher, excludeMatcher, encoding} = {}) {
|
|
100
98
|
if (includeMatcher === undefined) {
|
|
101
99
|
opts = Object.assign({}, defaults, opts);
|
|
102
100
|
({includeMatcher, excludeMatcher} = makeMatchers(opts));
|
|
@@ -147,13 +145,13 @@ module.exports.async = async (dir, opts = {}, {includeMatcher, excludeMatcher, e
|
|
|
147
145
|
recurse = true;
|
|
148
146
|
}
|
|
149
147
|
|
|
150
|
-
if (recurse) results.push(...await
|
|
148
|
+
if (recurse) results.push(...await rrdirAsync(path, opts, {includeMatcher, excludeMatcher, encoding}));
|
|
151
149
|
}));
|
|
152
150
|
|
|
153
151
|
return results;
|
|
154
|
-
}
|
|
152
|
+
}
|
|
155
153
|
|
|
156
|
-
|
|
154
|
+
export function rrdirSync(dir, opts = {}, {includeMatcher, excludeMatcher, encoding} = {}) {
|
|
157
155
|
if (includeMatcher === undefined) {
|
|
158
156
|
opts = Object.assign({}, defaults, opts);
|
|
159
157
|
({includeMatcher, excludeMatcher} = makeMatchers(opts));
|
|
@@ -203,8 +201,8 @@ module.exports.sync = (dir, opts = {}, {includeMatcher, excludeMatcher, encoding
|
|
|
203
201
|
recurse = true;
|
|
204
202
|
}
|
|
205
203
|
|
|
206
|
-
if (recurse) results.push(...
|
|
204
|
+
if (recurse) results.push(...rrdirSync(path, opts, {includeMatcher, excludeMatcher, encoding}));
|
|
207
205
|
}
|
|
208
206
|
|
|
209
207
|
return results;
|
|
210
|
-
}
|
|
208
|
+
}
|
package/package.json
CHANGED
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rrdir",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Recursive directory reader with a delightful API",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
6
|
"repository": "silverwind/rrdir",
|
|
7
7
|
"license": "BSD-2-Clause",
|
|
8
8
|
"main": "index.js",
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"sideEffects": false,
|
|
12
11
|
"engines": {
|
|
13
|
-
"node": ">=
|
|
12
|
+
"node": ">=14"
|
|
14
13
|
},
|
|
15
14
|
"files": [
|
|
16
15
|
"index.js"
|
|
17
16
|
],
|
|
18
17
|
"dependencies": {
|
|
19
|
-
"picomatch": "^2.
|
|
18
|
+
"picomatch": "^2.3.1"
|
|
20
19
|
},
|
|
21
20
|
"devDependencies": {
|
|
22
|
-
"
|
|
23
|
-
"eslint": "
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"versions": "8.4.4"
|
|
21
|
+
"eslint": "8.23.1",
|
|
22
|
+
"eslint-config-silverwind": "54.0.2",
|
|
23
|
+
"jest": "29.0.3",
|
|
24
|
+
"semver": "7.3.7",
|
|
25
|
+
"tempy": "3.0.0",
|
|
26
|
+
"updates": "13.1.5",
|
|
27
|
+
"versions": "9.3.0"
|
|
30
28
|
},
|
|
31
29
|
"keywords": [
|
|
32
30
|
"recursive readdir",
|