rrdir 14.2.10 → 14.2.12
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 +7 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -7,13 +7,13 @@ This module is able to read any path including ones that contain invalid UTF-8 s
|
|
|
7
7
|
|
|
8
8
|
| Benchmark | rrdir | fdir |
|
|
9
9
|
|---|---|---|
|
|
10
|
-
| async |
|
|
11
|
-
| sync |
|
|
12
|
-
| async + glob |
|
|
13
|
-
| sync + glob |
|
|
14
|
-
| async + exclude |
|
|
15
|
-
| sync + exclude |
|
|
16
|
-
| async iterator |
|
|
10
|
+
| async | 59ms | 58ms |
|
|
11
|
+
| sync | 158ms | 183ms |
|
|
12
|
+
| async + glob | 58ms | 58ms |
|
|
13
|
+
| sync + glob | 175ms | 198ms |
|
|
14
|
+
| async + exclude | 38ms | 38ms |
|
|
15
|
+
| sync + exclude | 122ms | 121ms |
|
|
16
|
+
| async iterator | 80ms | — |
|
|
17
17
|
|
|
18
18
|
Results for 122K entries (111K files, 11K dirs), Node.js on macOS. rrdir returns richer entries (path + directory + symlink) while fdir returns only paths. fdir uses [picomatch](https://github.com/micromatch/picomatch) for glob matching, rrdir has a built-in glob matcher. Run with `make bench`.
|
|
19
19
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Stats } from "node:fs";
|
|
2
2
|
|
|
3
3
|
//#region index.d.ts
|
|
4
|
-
/** A directory path, either as a string or a
|
|
5
|
-
type Dir = string |
|
|
4
|
+
/** A directory path, either as a string or a Uint8Array for raw byte paths. */
|
|
5
|
+
type Dir = string | Uint8Array;
|
|
6
6
|
/** Options for `rrdir`, `rrdirAsync`, and `rrdirSync`. */
|
|
7
7
|
type RRDirOpts = {
|
|
8
8
|
/** Whether to throw immediately when reading an entry fails. Default: `false`. */strict?: boolean; /** Whether to include `entry.stats`. Will reduce performance. Default: `false`. */
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{lstat as e,readdir as t,stat as n}from"node:fs/promises";import{
|
|
1
|
+
import{lstat as e,readdir as t,stat as n}from"node:fs/promises";import{lstat as r,lstatSync as i,readdir as a,readdirSync as o,stat as s,statSync as c}from"node:fs";import{isAbsolute as l,resolve as u,sep as d}from"node:path";const f=new TextDecoder,p=f.decode.bind(f),m=new TextEncoder().encode(d);function h(e,t){if(t){let t=e;if(t.length===1&&t[0]===46)return t.subarray(0,0);let n=new Uint8Array(t.length+m.length);return n.set(t,0),n.set(m,t.length),n}return e===`.`?``:e+d}function g(e,t,n){if(n){let n=t;if(n.length===0)return e;let r=e,i=new Uint8Array(n.length+r.length);return i.set(n,0),i.set(r,n.length),i}return t+e}function _(e,t,n,r,i){return i?{path:e,directory:t,symlink:n,stats:r}:{path:e,directory:t,symlink:n}}function v(e,t){e=e.replace(/\\/g,`/`);let n=e.endsWith(`/**`),r=e.replace(/\*\*|\*|[.+?^${}()|[\]\\]/g,e=>e===`**`?`.*`:e===`*`?`[^/]*`:`\\${e}`);return n?(r=r.slice(0,-3),r=`^${r}(?:/.*)?$`):r=`^${r}$`,new RegExp(r,t?`i`:``)}function y(e,t,n){if(!e?.length)return null;let r=e.map(e=>v(e,t)),i=n?``:u(`.`)+d,a=r.length;return d===`\\`?e=>{let t=(i+e).replace(/\\/g,`/`);for(let e=0;e<a;e++)if(r[e].test(t))return!0;return!1}:e=>{let t=i+e;for(let e=0;e<a;e++)if(r[e].test(t))return!0;return!1}}function b(t,a){if(t instanceof Uint8Array){let e=t[t.length-1];(e===47||e===92)&&(t=t.subarray(0,-1))}else /[/\\]$/.test(t)&&(t=t.substring(0,t.length-1));let o=t instanceof Uint8Array,u=a.insensitive||!1,d=t instanceof Uint8Array?l(p(t)):l(t),f=y(a.include,u,d),m=y(a.exclude,u,d),h=!!a.followSymlinks;return{dir:t,internalOpts:{includeMatcher:f,excludeMatcher:m,isBuffer:o,followSymlinks:h,needStats:!!a.stats,strict:!!a.strict,readdirOpts:{encoding:o?`buffer`:`utf8`,withFileTypes:!0},statFn:h?n:e,statCbFn:h?s:r,statSyncFn:h?c:i}}}async function*x(e,n={}){let r=b(e,n),{includeMatcher:i,excludeMatcher:a,isBuffer:o,followSymlinks:s,needStats:c,strict:l,readdirOpts:u,statFn:d}=r.internalOpts;e=r.dir;let f=[e];for(;f.length>0;){let e=await Promise.all(f.map(e=>t(e,u).then(t=>({dir:e,dirents:t}),t=>({dir:e,err:t})))),n=[];for(let t of e){if(`err`in t){if(l)throw t.err;yield{path:t.dir,err:t.err};continue}let e=h(t.dir,o);for(let r of t.dirents){let t=g(r.name,e,o),u=!0;if(a||i){let e=o?p(t):t;if(a?.(e))continue;i&&(u=i(e))}let f=!1,m=!1;r.isFile()||(f=r.isDirectory(),f||(m=r.isSymbolicLink()));let h,v;if(s&&m||u&&c)try{h=await d(t)}catch(e){if(l)throw e;u&&(v={path:t,err:e})}let y=h?h.isDirectory():f;u&&(yield v??_(t,y,m&&!s,h,c)),y&&n.push(t)}}f=n}}function S(e,t={}){let n=b(e,t),r=[];return new Promise((e,t)=>{C(n.dir,n.internalOpts,r,n=>{n?t(n):e(r)})})}function C(e,t,n,r){let{includeMatcher:i,excludeMatcher:o,isBuffer:s,followSymlinks:c,needStats:l,strict:u,readdirOpts:d,statCbFn:f}=t;a(e,d,(a,d)=>{if(a)return u?r(a):(n.push({path:e,err:a}),r());let m=d;if(!m.length)return r();let v=h(e,s),y=[],b=0,x=!1,S,w=!1,T=()=>{if(w)return;if(S)return w=!0,r(S);if(!x||b>0)return;if(w=!0,!y.length)return r();let e=y.length,i=t=>{t&&!S&&(S=t),--e===0&&r(S)};for(let e of y)C(e,t,n,i)};for(let e of m){let t=g(e.name,v,s),r=!0;if(o||i){let e=s?p(t):t;if(o?.(e))continue;i&&(r=i(e))}let a=!1,d=!1;e.isFile()||(a=e.isDirectory(),a||(d=e.isSymbolicLink())),c&&d||r&&l?(b++,f(t,(e,i)=>{if(e)u?S??=e:r&&n.push({path:t,err:e});else{let e=i.isDirectory();r&&n.push(_(t,e,d&&!c,i,l)),e&&y.push(t)}b--,T()})):(r&&n.push(_(t,a,d&&!c,void 0,l)),a&&y.push(t))}x=!0,T()})}function w(e,t={}){let n=b(e,t),r=[];return T(n.dir,n.internalOpts,r),r}function T(e,t,n){let{includeMatcher:r,excludeMatcher:i,isBuffer:a,followSymlinks:s,needStats:c,strict:l,readdirOpts:u,statSyncFn:d}=t,f=[e];for(;f.length>0;){let e=f.pop(),t=[];try{t=o(e,u)}catch(t){if(l)throw t;n.push({path:e,err:t});continue}if(!t.length)continue;let m=h(e,a);for(let e of t){let t=g(e.name,m,a),o=!0;if(i||r){let e=a?p(t):t;if(i?.(e))continue;r&&(o=r(e))}let u=!1,h=!1;e.isFile()||(u=e.isDirectory(),u||(h=e.isSymbolicLink()));let v,y;if(s&&h||o&&c)try{v=d(t)}catch(e){if(l)throw e;o&&(y={path:t,err:e})}let b=v?v.isDirectory():u;o&&n.push(y??_(t,b,h&&!s,v,c)),b&&f.push(t)}}}export{x as rrdir,S as rrdirAsync,w as rrdirSync};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rrdir",
|
|
3
|
-
"version": "14.2.
|
|
3
|
+
"version": "14.2.12",
|
|
4
4
|
"description": "Recursive directory reader with a delightful API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"recursive",
|
|
@@ -29,20 +29,20 @@
|
|
|
29
29
|
"bun": "*"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "25.
|
|
33
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
34
|
-
"eslint": "10.
|
|
35
|
-
"eslint-config-silverwind": "
|
|
32
|
+
"@types/node": "25.8.0",
|
|
33
|
+
"@typescript/native-preview": "7.0.0-dev.20260515.1",
|
|
34
|
+
"eslint": "10.4.0",
|
|
35
|
+
"eslint-config-silverwind": "133.0.2",
|
|
36
36
|
"fdir": "6.5.0",
|
|
37
37
|
"jest-extended": "7.0.0",
|
|
38
|
-
"tsdown": "0.
|
|
39
|
-
"tsdown-config-silverwind": "
|
|
38
|
+
"tsdown": "0.22.0",
|
|
39
|
+
"tsdown-config-silverwind": "3.0.1",
|
|
40
40
|
"typescript": "6.0.3",
|
|
41
41
|
"typescript-config-silverwind": "18.0.0",
|
|
42
|
-
"updates": "17.16.
|
|
43
|
-
"updates-config-silverwind": "
|
|
44
|
-
"versions": "15.0.
|
|
45
|
-
"vitest": "4.1.
|
|
46
|
-
"vitest-config-silverwind": "11.3.
|
|
42
|
+
"updates": "17.16.12",
|
|
43
|
+
"updates-config-silverwind": "3.0.2",
|
|
44
|
+
"versions": "15.0.4",
|
|
45
|
+
"vitest": "4.1.6",
|
|
46
|
+
"vitest-config-silverwind": "11.3.5"
|
|
47
47
|
}
|
|
48
48
|
}
|