tiny-readdir 2.7.0 → 2.7.2
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/dist/index.d.ts +2 -2
- package/dist/utils.js +5 -0
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/utils.ts +10 -0
- package/test/index.js +14 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Dirent, Options, Result } from './types';
|
|
1
|
+
import type { Dirent, Options, ResultDirectory, ResultDirectories, Result } from './types';
|
|
2
2
|
declare const readdir: (rootPath: string, options?: Options) => Promise<Result>;
|
|
3
3
|
export default readdir;
|
|
4
|
-
export type { Dirent, Options, Result };
|
|
4
|
+
export type { Dirent, Options, ResultDirectory, ResultDirectories, Result };
|
package/dist/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "tiny-readdir",
|
|
3
3
|
"repository": "github:fabiospampinato/tiny-readdir",
|
|
4
4
|
"description": "A simple promisified recursive readdir function.",
|
|
5
|
-
"version": "2.7.
|
|
5
|
+
"version": "2.7.2",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"exports": "./dist/index.js",
|
package/src/index.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -40,6 +40,16 @@ const makeCounterPromise = (): { promise: Promise<void>, increment: Callback, de
|
|
|
40
40
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
const init = (): void => { // Accounting for no increment/decrement calls
|
|
44
|
+
|
|
45
|
+
increment ();
|
|
46
|
+
|
|
47
|
+
queueMicrotask ( decrement );
|
|
48
|
+
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
init ();
|
|
52
|
+
|
|
43
53
|
return { promise, increment, decrement };
|
|
44
54
|
|
|
45
55
|
};
|
package/test/index.js
CHANGED
|
@@ -149,6 +149,20 @@ describe ( 'Tiny Readdir', it => {
|
|
|
149
149
|
|
|
150
150
|
});
|
|
151
151
|
|
|
152
|
+
it ( 'supports a depth option', async t => {
|
|
153
|
+
|
|
154
|
+
const cwdPath = process.cwd ();
|
|
155
|
+
|
|
156
|
+
const {files: files0} = await readdir ( cwdPath, { depth: 0 } );
|
|
157
|
+
const {files: files1} = await readdir ( cwdPath, { depth: 1 } );
|
|
158
|
+
const {files: filesInfinity} = await readdir ( cwdPath, { depth: Infinity } );
|
|
159
|
+
|
|
160
|
+
t.true ( files0.length === 0 );
|
|
161
|
+
t.true ( files1.length > 0 && files1.length < 10 );
|
|
162
|
+
t.true ( filesInfinity.length > 100 );
|
|
163
|
+
|
|
164
|
+
});
|
|
165
|
+
|
|
152
166
|
it ( 'supports a limit option', async t => {
|
|
153
167
|
|
|
154
168
|
const cwdPath = process.cwd ();
|