@aminzer/traverse-directory 1.2.5 → 1.2.7
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/LICENSE +9 -9
- package/README.md +88 -88
- package/package.json +59 -59
package/LICENSE
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Aliaksei Minzer
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Aliaksei Minzer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
### Overview
|
|
2
|
-
|
|
3
|
-
[NodeJS](https://nodejs.org) utility for recursively iterating over directory contents.
|
|
4
|
-
|
|
5
|
-
It allows to traverse through all subdirectories and files within a specified directory.
|
|
6
|
-
|
|
7
|
-
### Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm i @aminzer/traverse-directory
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
### Usage examples
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
import { traverseDirectory } from '@aminzer/traverse-directory';
|
|
17
|
-
|
|
18
|
-
await traverseDirectory('/path/to/directory', ({ isFile, relativePath }) => {
|
|
19
|
-
console.log(`${isFile ? 'File' : 'Directory'} ${relativePath} was found`);
|
|
20
|
-
});
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### API
|
|
24
|
-
|
|
25
|
-
**traverseDirectory**
|
|
26
|
-
|
|
27
|
-
##### Overview
|
|
28
|
-
|
|
29
|
-
`traverseDirectory` recursively iterates over the contents of a directory.
|
|
30
|
-
|
|
31
|
-
```typescript
|
|
32
|
-
import { directoryExists } from '@aminzer/traverse-directory';
|
|
33
|
-
|
|
34
|
-
await traverseDirectory(dirPath, onEachChild);
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
##### Parameters
|
|
38
|
-
|
|
39
|
-
* `dirPath` (`string`, required) - path to the directory whose contents should be iterated.
|
|
40
|
-
* `onEachChild` (`function`, required) - callback invoked for each child file and directory.
|
|
41
|
-
|
|
42
|
-
`onEachChild` callback accepts following arguments:
|
|
43
|
-
* `fsEntry` (`FsEntry`) - currently iterated child file or directory.
|
|
44
|
-
* `additionalArgs` (`object`, optional) - additional callback arguments:
|
|
45
|
-
* `skipEntryChildrenIteration` (`function`) - call this function within `onEachChild` to skip iterating the children of the current entry.
|
|
46
|
-
|
|
47
|
-
##### Return value
|
|
48
|
-
|
|
49
|
-
`Promise` that resolves when the directory traversal is complete.
|
|
50
|
-
|
|
51
|
-
**FsEntry**
|
|
52
|
-
|
|
53
|
-
##### Overview
|
|
54
|
-
|
|
55
|
-
`FsEntry` - class representing File System Entry (file or directory).
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
import { FsEntry } from '@aminzer/traverse-directory';
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Instance properties:
|
|
62
|
-
* `name` (`string`) - name of entry.
|
|
63
|
-
* `absolutePath` (`string`) - absolute path to entry.
|
|
64
|
-
* `relativePath` (`string`) - relative path to entry. It's relative to the directory passed to `traverseDirectory`.
|
|
65
|
-
* `size` (`number`) - size of file in bytes, `0` for directories.
|
|
66
|
-
* `isFile` (`boolean`) - `true` if entry is file.
|
|
67
|
-
* `isDirectory` (`boolean`) - `true` if entry is directory.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
**directoryExists**
|
|
71
|
-
|
|
72
|
-
##### Overview
|
|
73
|
-
|
|
74
|
-
`directoryExists` is an async function that checks if a given path exists and corresponds to a directory.
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
import { directoryExists } from '@aminzer/traverse-directory';
|
|
78
|
-
|
|
79
|
-
const exists = await directoryExists('/path/to/directory');
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
##### Parameters
|
|
83
|
-
|
|
84
|
-
* `dirPath` (`string`, required) - path to the directory to check.
|
|
85
|
-
|
|
86
|
-
##### Return value
|
|
87
|
-
|
|
88
|
-
`Promise<boolean>` that resolves to `true` if the directory exists, or `false` otherwise.
|
|
1
|
+
### Overview
|
|
2
|
+
|
|
3
|
+
[NodeJS](https://nodejs.org) utility for recursively iterating over directory contents.
|
|
4
|
+
|
|
5
|
+
It allows to traverse through all subdirectories and files within a specified directory.
|
|
6
|
+
|
|
7
|
+
### Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i @aminzer/traverse-directory
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Usage examples
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { traverseDirectory } from '@aminzer/traverse-directory';
|
|
17
|
+
|
|
18
|
+
await traverseDirectory('/path/to/directory', ({ isFile, relativePath }) => {
|
|
19
|
+
console.log(`${isFile ? 'File' : 'Directory'} ${relativePath} was found`);
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### API
|
|
24
|
+
|
|
25
|
+
**traverseDirectory**
|
|
26
|
+
|
|
27
|
+
##### Overview
|
|
28
|
+
|
|
29
|
+
`traverseDirectory` recursively iterates over the contents of a directory.
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { directoryExists } from '@aminzer/traverse-directory';
|
|
33
|
+
|
|
34
|
+
await traverseDirectory(dirPath, onEachChild);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
##### Parameters
|
|
38
|
+
|
|
39
|
+
* `dirPath` (`string`, required) - path to the directory whose contents should be iterated.
|
|
40
|
+
* `onEachChild` (`function`, required) - callback invoked for each child file and directory.
|
|
41
|
+
|
|
42
|
+
`onEachChild` callback accepts following arguments:
|
|
43
|
+
* `fsEntry` (`FsEntry`) - currently iterated child file or directory.
|
|
44
|
+
* `additionalArgs` (`object`, optional) - additional callback arguments:
|
|
45
|
+
* `skipEntryChildrenIteration` (`function`) - call this function within `onEachChild` to skip iterating the children of the current entry.
|
|
46
|
+
|
|
47
|
+
##### Return value
|
|
48
|
+
|
|
49
|
+
`Promise` that resolves when the directory traversal is complete.
|
|
50
|
+
|
|
51
|
+
**FsEntry**
|
|
52
|
+
|
|
53
|
+
##### Overview
|
|
54
|
+
|
|
55
|
+
`FsEntry` - class representing File System Entry (file or directory).
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { FsEntry } from '@aminzer/traverse-directory';
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Instance properties:
|
|
62
|
+
* `name` (`string`) - name of entry.
|
|
63
|
+
* `absolutePath` (`string`) - absolute path to entry.
|
|
64
|
+
* `relativePath` (`string`) - relative path to entry. It's relative to the directory passed to `traverseDirectory`.
|
|
65
|
+
* `size` (`number`) - size of file in bytes, `0` for directories.
|
|
66
|
+
* `isFile` (`boolean`) - `true` if entry is file.
|
|
67
|
+
* `isDirectory` (`boolean`) - `true` if entry is directory.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
**directoryExists**
|
|
71
|
+
|
|
72
|
+
##### Overview
|
|
73
|
+
|
|
74
|
+
`directoryExists` is an async function that checks if a given path exists and corresponds to a directory.
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { directoryExists } from '@aminzer/traverse-directory';
|
|
78
|
+
|
|
79
|
+
const exists = await directoryExists('/path/to/directory');
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
##### Parameters
|
|
83
|
+
|
|
84
|
+
* `dirPath` (`string`, required) - path to the directory to check.
|
|
85
|
+
|
|
86
|
+
##### Return value
|
|
87
|
+
|
|
88
|
+
`Promise<boolean>` that resolves to `true` if the directory exists, or `false` otherwise.
|
package/package.json
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@aminzer/traverse-directory",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "Utility for directory child entries recursive iteration",
|
|
5
|
-
"publishConfig": {
|
|
6
|
-
"access": "public"
|
|
7
|
-
},
|
|
8
|
-
"type": "module",
|
|
9
|
-
"keywords": [
|
|
10
|
-
"traverse",
|
|
11
|
-
"directory",
|
|
12
|
-
"fs",
|
|
13
|
-
"filesystem",
|
|
14
|
-
"file",
|
|
15
|
-
"folder",
|
|
16
|
-
"iterate",
|
|
17
|
-
"recursion",
|
|
18
|
-
"recursive"
|
|
19
|
-
],
|
|
20
|
-
"repository": {
|
|
21
|
-
"type": "git",
|
|
22
|
-
"url": "https://github.com/aminzer/traverse-directory.git"
|
|
23
|
-
},
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"author": "aminzer",
|
|
26
|
-
"main": "dist/index.js",
|
|
27
|
-
"types": "dist/index.d.ts",
|
|
28
|
-
"files": [
|
|
29
|
-
"dist"
|
|
30
|
-
],
|
|
31
|
-
"scripts": {
|
|
32
|
-
"build": "tsc --project tsconfig.build.json",
|
|
33
|
-
"build:watch": "npm run build -- --watch",
|
|
34
|
-
"clean": "rimraf dist",
|
|
35
|
-
"codestyle": "run-p lint typescript:check",
|
|
36
|
-
"lint": "eslint src/**/*.ts",
|
|
37
|
-
"lint:fix": "npm run lint -- --fix",
|
|
38
|
-
"prepare": "npm run rebuild",
|
|
39
|
-
"rebuild": "run-s clean build",
|
|
40
|
-
"test": "tsx --test src/**/*.test.ts",
|
|
41
|
-
"typescript:check": "tsc --project tsconfig.json --noEmit"
|
|
42
|
-
},
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"@eslint/js": "^9.36.0",
|
|
45
|
-
"@types/node": "^24.5.2",
|
|
46
|
-
"eslint": "^9.36.0",
|
|
47
|
-
"eslint-config-prettier": "^10.1.8",
|
|
48
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
49
|
-
"npm-run-all": "^4.1.5",
|
|
50
|
-
"prettier": "^3.6.2",
|
|
51
|
-
"rimraf": "^6.0.1",
|
|
52
|
-
"tsx": "^4.20.6",
|
|
53
|
-
"typescript": "^5.9.2",
|
|
54
|
-
"typescript-eslint": "^8.44.1"
|
|
55
|
-
},
|
|
56
|
-
"engines": {
|
|
57
|
-
"node": ">=22.0.0"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@aminzer/traverse-directory",
|
|
3
|
+
"version": "1.2.7",
|
|
4
|
+
"description": "Utility for directory child entries recursive iteration",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"traverse",
|
|
11
|
+
"directory",
|
|
12
|
+
"fs",
|
|
13
|
+
"filesystem",
|
|
14
|
+
"file",
|
|
15
|
+
"folder",
|
|
16
|
+
"iterate",
|
|
17
|
+
"recursion",
|
|
18
|
+
"recursive"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/aminzer/traverse-directory.git"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"author": "aminzer",
|
|
26
|
+
"main": "dist/index.js",
|
|
27
|
+
"types": "dist/index.d.ts",
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc --project tsconfig.build.json",
|
|
33
|
+
"build:watch": "npm run build -- --watch",
|
|
34
|
+
"clean": "rimraf dist",
|
|
35
|
+
"codestyle": "run-p lint typescript:check",
|
|
36
|
+
"lint": "eslint src/**/*.ts",
|
|
37
|
+
"lint:fix": "npm run lint -- --fix",
|
|
38
|
+
"prepare": "npm run rebuild",
|
|
39
|
+
"rebuild": "run-s clean build",
|
|
40
|
+
"test": "tsx --test src/**/*.test.ts",
|
|
41
|
+
"typescript:check": "tsc --project tsconfig.json --noEmit"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@eslint/js": "^9.36.0",
|
|
45
|
+
"@types/node": "^24.5.2",
|
|
46
|
+
"eslint": "^9.36.0",
|
|
47
|
+
"eslint-config-prettier": "^10.1.8",
|
|
48
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
49
|
+
"npm-run-all": "^4.1.5",
|
|
50
|
+
"prettier": "^3.6.2",
|
|
51
|
+
"rimraf": "^6.0.1",
|
|
52
|
+
"tsx": "^4.20.6",
|
|
53
|
+
"typescript": "^5.9.2",
|
|
54
|
+
"typescript-eslint": "^8.44.1"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=22.0.0"
|
|
58
|
+
}
|
|
59
|
+
}
|