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 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
@@ -19,6 +19,11 @@ const makeCounterPromise = () => {
19
19
  return;
20
20
  resolve();
21
21
  };
22
+ const init = () => {
23
+ increment();
24
+ queueMicrotask(decrement);
25
+ };
26
+ init();
22
27
  return { promise, increment, decrement };
23
28
  };
24
29
  /* EXPORT */
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.0",
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
@@ -253,4 +253,4 @@ const readdir = ( rootPath: string, options?: Options ): Promise<Result> => {
253
253
  /* EXPORT */
254
254
 
255
255
  export default readdir;
256
- export type {Dirent, Options, Result};
256
+ export type {Dirent, Options, ResultDirectory, ResultDirectories, Result};
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 ();