@rust-gear/glob 0.2.2 → 0.2.4
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 +38 -11
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
A high-performance globbing library for Node.js, powered by native Rust code.
|
|
4
4
|
|
|
5
|
+
## ⚡ Performance
|
|
6
|
+
|
|
7
|
+
Significantly faster than Node.js built-in `fs.globSync`:
|
|
8
|
+
|
|
9
|
+
- **2-3x faster** for typical glob patterns
|
|
10
|
+
- **8x faster** for large file sets (5000+ files)
|
|
11
|
+
|
|
12
|
+
Based on benchmarks with 4,000-12,000 files across various patterns.
|
|
13
|
+
|
|
5
14
|
## Installation
|
|
6
15
|
|
|
7
16
|
```sh
|
|
@@ -13,52 +22,70 @@ npm install --save-dev @rust-gear/glob
|
|
|
13
22
|
```js
|
|
14
23
|
import { globSync, glob } from "@rust-gear/glob";
|
|
15
24
|
|
|
25
|
+
// Synchronous
|
|
16
26
|
const files = globSync("src/**/*.rs");
|
|
17
27
|
console.log(files);
|
|
18
28
|
|
|
29
|
+
// Asynchronous
|
|
19
30
|
const filesAsync = await glob("src/**/*.rs");
|
|
20
31
|
console.log(filesAsync);
|
|
21
32
|
```
|
|
22
33
|
|
|
23
34
|
## Options
|
|
24
35
|
|
|
25
|
-
|
|
36
|
+
Both `globSync` and `glob` accept an optional options object as the second argument.
|
|
26
37
|
|
|
27
38
|
> **Return path type:**
|
|
28
|
-
>
|
|
29
|
-
>
|
|
39
|
+
> Absolute patterns return absolute paths.
|
|
40
|
+
> Relative patterns return paths relative to the specified `cwd`.
|
|
30
41
|
|
|
31
42
|
| Option | Type | Description |
|
|
32
43
|
| :------ | :------- | :-------------------------------------- |
|
|
33
44
|
| cwd | string | Current working directory for searching |
|
|
34
45
|
| exclude | string[] | Array of glob patterns to exclude |
|
|
35
46
|
|
|
36
|
-
###
|
|
47
|
+
### Examples
|
|
37
48
|
|
|
38
49
|
```js
|
|
39
|
-
// Relative pattern
|
|
50
|
+
// Relative pattern - returns paths relative to cwd
|
|
40
51
|
const files = globSync("**/*.rs", {
|
|
41
52
|
cwd: "src",
|
|
42
53
|
exclude: ["**/test/**", "**/target/**"],
|
|
43
54
|
});
|
|
44
55
|
|
|
45
|
-
// Convert
|
|
56
|
+
// Convert relative paths to absolute
|
|
46
57
|
const absFiles = globSync("**/*.rs", {
|
|
47
58
|
cwd: "src",
|
|
48
59
|
exclude: ["**/test/**", "**/target/**"],
|
|
49
60
|
}).map((f) => path.resolve(cwd(), f));
|
|
50
61
|
|
|
51
|
-
// Absolute pattern
|
|
62
|
+
// Absolute pattern - returns absolute paths
|
|
52
63
|
const absoluteFiles = globSync("/Users/foo/project/src/**/*.rs");
|
|
53
64
|
```
|
|
54
65
|
|
|
55
66
|
## API
|
|
56
67
|
|
|
57
|
-
|
|
58
|
-
|
|
68
|
+
### `globSync(pattern, options?)`
|
|
69
|
+
|
|
70
|
+
Synchronously returns an array of file paths matching the pattern.
|
|
71
|
+
|
|
72
|
+
**Parameters:**
|
|
73
|
+
|
|
74
|
+
- `pattern` - A glob pattern string or array of patterns
|
|
75
|
+
- `options?` - Optional configuration object
|
|
76
|
+
|
|
77
|
+
**Returns:** `string[]`
|
|
78
|
+
|
|
79
|
+
### `glob(pattern, options?)`
|
|
80
|
+
|
|
81
|
+
Asynchronously returns an array of file paths matching the pattern.
|
|
82
|
+
|
|
83
|
+
**Parameters:**
|
|
84
|
+
|
|
85
|
+
- `pattern` - A glob pattern string or array of patterns
|
|
86
|
+
- `options?` - Optional configuration object
|
|
59
87
|
|
|
60
|
-
**
|
|
61
|
-
Asynchronously returns an array of file paths.
|
|
88
|
+
**Returns:** `Promise<string[]>`
|
|
62
89
|
|
|
63
90
|
## License
|
|
64
91
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rust-gear/glob",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Node.js bindings for Rust glob library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rust-gear",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"url": "git+https://github.com/rust-gear-project/rust-gear.git"
|
|
14
14
|
},
|
|
15
15
|
"license": "Apache-2.0",
|
|
16
|
-
"author": "Refirst",
|
|
16
|
+
"author": "Refirst 11",
|
|
17
17
|
"main": "index.js",
|
|
18
18
|
"module": "index.mjs",
|
|
19
19
|
"types": "index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"build": "napi build --platform --release",
|
|
41
41
|
"packages": "node ../../scripts/generate-platform-packages.js",
|
|
42
42
|
"readme": "node ../../scripts/generate-platform-readme.js",
|
|
43
|
-
"test": "
|
|
43
|
+
"test": "ava"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=10"
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
"@napi-rs/cli": "^2.18.4"
|
|
54
54
|
},
|
|
55
55
|
"optionalDependencies": {
|
|
56
|
-
"@rust-gear/glob-darwin-arm64": "0.2.
|
|
57
|
-
"@rust-gear/glob-darwin-x64": "0.2.
|
|
58
|
-
"@rust-gear/glob-linux-arm64-gnu": "0.2.
|
|
59
|
-
"@rust-gear/glob-linux-arm64-musl": "0.2.
|
|
60
|
-
"@rust-gear/glob-linux-x64-gnu": "0.2.
|
|
61
|
-
"@rust-gear/glob-linux-x64-musl": "0.2.
|
|
62
|
-
"@rust-gear/glob-win32-arm64-msvc": "0.2.
|
|
63
|
-
"@rust-gear/glob-win32-ia32-msvc": "0.2.
|
|
64
|
-
"@rust-gear/glob-win32-x64-msvc": "0.2.
|
|
56
|
+
"@rust-gear/glob-darwin-arm64": "0.2.4",
|
|
57
|
+
"@rust-gear/glob-darwin-x64": "0.2.4",
|
|
58
|
+
"@rust-gear/glob-linux-arm64-gnu": "0.2.4",
|
|
59
|
+
"@rust-gear/glob-linux-arm64-musl": "0.2.4",
|
|
60
|
+
"@rust-gear/glob-linux-x64-gnu": "0.2.4",
|
|
61
|
+
"@rust-gear/glob-linux-x64-musl": "0.2.4",
|
|
62
|
+
"@rust-gear/glob-win32-arm64-msvc": "0.2.4",
|
|
63
|
+
"@rust-gear/glob-win32-ia32-msvc": "0.2.4",
|
|
64
|
+
"@rust-gear/glob-win32-x64-msvc": "0.2.4"
|
|
65
65
|
}
|
|
66
66
|
}
|