tiny-readdir 2.1.0 → 2.2.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/dist/index.js +3 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +6 -0
- package/package.json +1 -1
- package/src/index.ts +3 -1
- package/src/types.ts +1 -1
- package/src/utils.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/* IMPORT */
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { isFunction } from './utils.js';
|
|
4
5
|
/* MAIN */
|
|
5
6
|
const readdir = (rootPath, options) => {
|
|
6
7
|
const followSymlinks = options?.followSymlinks ?? false;
|
|
7
8
|
const maxDepth = options?.depth ?? Infinity;
|
|
8
9
|
const maxPaths = options?.limit ?? Infinity;
|
|
9
|
-
const
|
|
10
|
+
const ignore = options?.ignore ?? (() => false);
|
|
11
|
+
const isIgnored = isFunction(ignore) ? ignore : (targetPath) => ignore.test(targetPath);
|
|
10
12
|
const signal = options?.signal ?? { aborted: false };
|
|
11
13
|
const directories = [];
|
|
12
14
|
const files = [];
|
package/dist/types.d.ts
CHANGED
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
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.
|
|
5
|
+
"version": "2.2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"exports": "./dist/index.js",
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import fs from 'node:fs';
|
|
5
5
|
import path from 'node:path';
|
|
6
|
+
import {isFunction} from './utils';
|
|
6
7
|
import type {Promisable, Options, ResultDirectory, ResultDirectories, Result} from './types';
|
|
7
8
|
|
|
8
9
|
/* MAIN */
|
|
@@ -12,7 +13,8 @@ const readdir = ( rootPath: string, options?: Options ): Promise<Result> => {
|
|
|
12
13
|
const followSymlinks = options?.followSymlinks ?? false;
|
|
13
14
|
const maxDepth = options?.depth ?? Infinity;
|
|
14
15
|
const maxPaths = options?.limit ?? Infinity;
|
|
15
|
-
const
|
|
16
|
+
const ignore = options?.ignore ?? (() => false);
|
|
17
|
+
const isIgnored = isFunction ( ignore ) ? ignore : ( targetPath: string ) => ignore.test ( targetPath );
|
|
16
18
|
const signal = options?.signal ?? { aborted: false };
|
|
17
19
|
const directories: string[] = [];
|
|
18
20
|
const files: string[] = [];
|
package/src/types.ts
CHANGED