extract-base-iterator 3.3.0 → 3.3.1
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/cjs/waitForAccess.d.cts +1 -1
- package/dist/cjs/waitForAccess.d.ts +1 -1
- package/dist/cjs/waitForAccess.js +19 -32
- package/dist/cjs/waitForAccess.js.map +1 -1
- package/dist/esm/waitForAccess.d.ts +1 -1
- package/dist/esm/waitForAccess.js +19 -31
- package/dist/esm/waitForAccess.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { NoParamCallback } from './types.js';
|
|
2
|
-
export default function waitForAccess(fullPath: string,
|
|
2
|
+
export default function waitForAccess(fullPath: string, noFollow: boolean | NoParamCallback, callback?: NoParamCallback | number): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { NoParamCallback } from './types.js';
|
|
2
|
-
export default function waitForAccess(fullPath: string,
|
|
2
|
+
export default function waitForAccess(fullPath: string, noFollow: boolean | NoParamCallback, callback?: NoParamCallback | number): void;
|
|
@@ -15,58 +15,45 @@ function _interop_require_default(obj) {
|
|
|
15
15
|
default: obj
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (typeof noFollowOrCallback === 'function') {
|
|
25
|
-
// Old signature: waitForAccess(path, callback, attempts?)
|
|
26
|
-
noFollow = false;
|
|
27
|
-
callback = noFollowOrCallback;
|
|
28
|
-
attempts = callbackOrAttempts || 0;
|
|
29
|
-
} else {
|
|
30
|
-
// New signature: waitForAccess(path, noFollow, callback, attempts?)
|
|
31
|
-
noFollow = noFollowOrCallback;
|
|
32
|
-
callback = callbackOrAttempts;
|
|
33
|
-
}
|
|
34
|
-
// POSIX: finish event is reliable after decompression stream fixes
|
|
35
|
-
// Avoid Zalgo: ensure callback is always async for consistent API
|
|
36
|
-
if (!isWindows) return process.nextTick(callback);
|
|
37
|
-
// Windows: NTFS metadata may not be committed yet, verify accessibility
|
|
38
|
-
// For symlinks (noFollow=true), use lstat to check the link itself exists
|
|
39
|
-
// For files/dirs/hardlinks, use open to verify the file is accessible
|
|
40
|
-
if (noFollow) {
|
|
18
|
+
function waitForAccess(fullPath, noFollow, callback) {
|
|
19
|
+
callback = typeof noFollow === 'function' ? noFollow : callback;
|
|
20
|
+
noFollow = typeof noFollow === 'function' ? false : noFollow;
|
|
21
|
+
// Exponential backoff: 5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560ms
|
|
22
|
+
// Total max wait: ~5 seconds
|
|
23
|
+
function waitSymlink(attempts, cb) {
|
|
41
24
|
_fs.default.lstat(fullPath, function(err) {
|
|
42
25
|
if (err) {
|
|
43
26
|
if (err.code === 'ENOENT' && attempts < 10) {
|
|
44
27
|
var delay = Math.min(5 * Math.pow(2, attempts), 2560);
|
|
45
28
|
return setTimeout(function() {
|
|
46
|
-
return
|
|
29
|
+
return waitSymlink(attempts + 1, cb);
|
|
47
30
|
}, delay);
|
|
48
31
|
}
|
|
49
|
-
return
|
|
32
|
+
return cb(err);
|
|
50
33
|
}
|
|
51
|
-
|
|
34
|
+
cb();
|
|
52
35
|
});
|
|
53
|
-
}
|
|
36
|
+
}
|
|
37
|
+
function waitOpen(attempts, cb) {
|
|
54
38
|
_fs.default.open(fullPath, 'r', function(err, fd) {
|
|
55
39
|
if (err) {
|
|
56
40
|
if (err.code === 'ENOENT' && attempts < 10) {
|
|
57
|
-
// Exponential backoff: 5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560ms
|
|
58
|
-
// Total max wait: ~5 seconds
|
|
59
41
|
var delay = Math.min(5 * Math.pow(2, attempts), 2560);
|
|
60
42
|
return setTimeout(function() {
|
|
61
|
-
return
|
|
43
|
+
return waitOpen(attempts + 1, cb);
|
|
62
44
|
}, delay);
|
|
63
45
|
}
|
|
64
|
-
return
|
|
46
|
+
return cb(err);
|
|
65
47
|
}
|
|
66
48
|
_fs.default.close(fd, function() {
|
|
67
|
-
return
|
|
49
|
+
return cb();
|
|
68
50
|
});
|
|
69
51
|
});
|
|
70
52
|
}
|
|
53
|
+
// Windows: NTFS metadata may not be committed yet, verify accessibility
|
|
54
|
+
// Node 0.10: the write stream's finish/close events may fire before the file is fully flushed to disk
|
|
55
|
+
// For symlinks (noFollow=true), use lstat to check the link itself exists
|
|
56
|
+
// For files/dirs/hardlinks, use open to verify the file is accessible
|
|
57
|
+
noFollow ? waitSymlink(0, callback) : waitOpen(0, callback);
|
|
71
58
|
}
|
|
72
59
|
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/waitForAccess.ts"],"sourcesContent":["import fs from 'fs';\n\nimport type { NoParamCallback } from './types.ts';\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/waitForAccess.ts"],"sourcesContent":["import fs from 'fs';\n\nimport type { NoParamCallback } from './types.ts';\n\n// Backward compatible: waitForAccess(path, callback) or waitForAccess(path, noFollow, callback)\nexport default function waitForAccess(fullPath: string, noFollow: boolean | NoParamCallback, callback?: NoParamCallback | number) {\n callback = typeof noFollow === 'function' ? noFollow : callback;\n noFollow = typeof noFollow === 'function' ? false : (noFollow as boolean);\n\n // Exponential backoff: 5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560ms\n // Total max wait: ~5 seconds\n function waitSymlink(attempts, cb) {\n fs.lstat(fullPath, (err) => {\n if (err) {\n if (err.code === 'ENOENT' && attempts < 10) {\n const delay = Math.min(5 * 2 ** attempts, 2560);\n return setTimeout(() => waitSymlink(attempts + 1, cb), delay);\n }\n return cb(err);\n }\n cb();\n });\n }\n function waitOpen(attempts, cb) {\n fs.open(fullPath, 'r', (err, fd) => {\n if (err) {\n if (err.code === 'ENOENT' && attempts < 10) {\n const delay = Math.min(5 * 2 ** attempts, 2560);\n return setTimeout(() => waitOpen(attempts + 1, cb), delay);\n }\n return cb(err);\n }\n fs.close(fd, () => cb());\n });\n }\n\n // Windows: NTFS metadata may not be committed yet, verify accessibility\n // Node 0.10: the write stream's finish/close events may fire before the file is fully flushed to disk\n // For symlinks (noFollow=true), use lstat to check the link itself exists\n // For files/dirs/hardlinks, use open to verify the file is accessible\n noFollow ? waitSymlink(0, callback) : waitOpen(0, callback);\n}\n"],"names":["waitForAccess","fullPath","noFollow","callback","waitSymlink","attempts","cb","fs","lstat","err","code","delay","Math","min","setTimeout","waitOpen","open","fd","close"],"mappings":";;;;+BAIA,gGAAgG;AAChG;;;eAAwBA;;;yDALT;;;;;;AAKA,SAASA,cAAcC,QAAgB,EAAEC,QAAmC,EAAEC,QAAmC;IAC9HA,WAAW,OAAOD,aAAa,aAAaA,WAAWC;IACvDD,WAAW,OAAOA,aAAa,aAAa,QAASA;IAErD,sEAAsE;IACtE,6BAA6B;IAC7B,SAASE,YAAYC,QAAQ,EAAEC,EAAE;QAC/BC,WAAE,CAACC,KAAK,CAACP,UAAU,SAACQ;YAClB,IAAIA,KAAK;gBACP,IAAIA,IAAIC,IAAI,KAAK,YAAYL,WAAW,IAAI;oBAC1C,IAAMM,QAAQC,KAAKC,GAAG,CAAC,aAAI,GAAKR,WAAU;oBAC1C,OAAOS,WAAW;+BAAMV,YAAYC,WAAW,GAAGC;uBAAKK;gBACzD;gBACA,OAAOL,GAAGG;YACZ;YACAH;QACF;IACF;IACA,SAASS,SAASV,QAAQ,EAAEC,EAAE;QAC5BC,WAAE,CAACS,IAAI,CAACf,UAAU,KAAK,SAACQ,KAAKQ;YAC3B,IAAIR,KAAK;gBACP,IAAIA,IAAIC,IAAI,KAAK,YAAYL,WAAW,IAAI;oBAC1C,IAAMM,QAAQC,KAAKC,GAAG,CAAC,aAAI,GAAKR,WAAU;oBAC1C,OAAOS,WAAW;+BAAMC,SAASV,WAAW,GAAGC;uBAAKK;gBACtD;gBACA,OAAOL,GAAGG;YACZ;YACAF,WAAE,CAACW,KAAK,CAACD,IAAI;uBAAMX;;QACrB;IACF;IAEA,wEAAwE;IACxE,sGAAsG;IACtG,0EAA0E;IAC1E,sEAAsE;IACtEJ,WAAWE,YAAY,GAAGD,YAAYY,SAAS,GAAGZ;AACpD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { NoParamCallback } from './types.js';
|
|
2
|
-
export default function waitForAccess(fullPath: string,
|
|
2
|
+
export default function waitForAccess(fullPath: string, noFollow: boolean | NoParamCallback, callback?: NoParamCallback | number): void;
|
|
@@ -1,49 +1,37 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
const isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);
|
|
3
2
|
// Backward compatible: waitForAccess(path, callback) or waitForAccess(path, noFollow, callback)
|
|
4
|
-
export default function waitForAccess(fullPath,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
noFollow = false;
|
|
11
|
-
callback = noFollowOrCallback;
|
|
12
|
-
attempts = callbackOrAttempts || 0;
|
|
13
|
-
} else {
|
|
14
|
-
// New signature: waitForAccess(path, noFollow, callback, attempts?)
|
|
15
|
-
noFollow = noFollowOrCallback;
|
|
16
|
-
callback = callbackOrAttempts;
|
|
17
|
-
}
|
|
18
|
-
// POSIX: finish event is reliable after decompression stream fixes
|
|
19
|
-
// Avoid Zalgo: ensure callback is always async for consistent API
|
|
20
|
-
if (!isWindows) return process.nextTick(callback);
|
|
21
|
-
// Windows: NTFS metadata may not be committed yet, verify accessibility
|
|
22
|
-
// For symlinks (noFollow=true), use lstat to check the link itself exists
|
|
23
|
-
// For files/dirs/hardlinks, use open to verify the file is accessible
|
|
24
|
-
if (noFollow) {
|
|
3
|
+
export default function waitForAccess(fullPath, noFollow, callback) {
|
|
4
|
+
callback = typeof noFollow === 'function' ? noFollow : callback;
|
|
5
|
+
noFollow = typeof noFollow === 'function' ? false : noFollow;
|
|
6
|
+
// Exponential backoff: 5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560ms
|
|
7
|
+
// Total max wait: ~5 seconds
|
|
8
|
+
function waitSymlink(attempts, cb) {
|
|
25
9
|
fs.lstat(fullPath, (err)=>{
|
|
26
10
|
if (err) {
|
|
27
11
|
if (err.code === 'ENOENT' && attempts < 10) {
|
|
28
12
|
const delay = Math.min(5 * 2 ** attempts, 2560);
|
|
29
|
-
return setTimeout(()=>
|
|
13
|
+
return setTimeout(()=>waitSymlink(attempts + 1, cb), delay);
|
|
30
14
|
}
|
|
31
|
-
return
|
|
15
|
+
return cb(err);
|
|
32
16
|
}
|
|
33
|
-
|
|
17
|
+
cb();
|
|
34
18
|
});
|
|
35
|
-
}
|
|
19
|
+
}
|
|
20
|
+
function waitOpen(attempts, cb) {
|
|
36
21
|
fs.open(fullPath, 'r', (err, fd)=>{
|
|
37
22
|
if (err) {
|
|
38
23
|
if (err.code === 'ENOENT' && attempts < 10) {
|
|
39
|
-
// Exponential backoff: 5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560ms
|
|
40
|
-
// Total max wait: ~5 seconds
|
|
41
24
|
const delay = Math.min(5 * 2 ** attempts, 2560);
|
|
42
|
-
return setTimeout(()=>
|
|
25
|
+
return setTimeout(()=>waitOpen(attempts + 1, cb), delay);
|
|
43
26
|
}
|
|
44
|
-
return
|
|
27
|
+
return cb(err);
|
|
45
28
|
}
|
|
46
|
-
fs.close(fd, ()=>
|
|
29
|
+
fs.close(fd, ()=>cb());
|
|
47
30
|
});
|
|
48
31
|
}
|
|
32
|
+
// Windows: NTFS metadata may not be committed yet, verify accessibility
|
|
33
|
+
// Node 0.10: the write stream's finish/close events may fire before the file is fully flushed to disk
|
|
34
|
+
// For symlinks (noFollow=true), use lstat to check the link itself exists
|
|
35
|
+
// For files/dirs/hardlinks, use open to verify the file is accessible
|
|
36
|
+
noFollow ? waitSymlink(0, callback) : waitOpen(0, callback);
|
|
49
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/waitForAccess.ts"],"sourcesContent":["import fs from 'fs';\n\nimport type { NoParamCallback } from './types.ts';\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/waitForAccess.ts"],"sourcesContent":["import fs from 'fs';\n\nimport type { NoParamCallback } from './types.ts';\n\n// Backward compatible: waitForAccess(path, callback) or waitForAccess(path, noFollow, callback)\nexport default function waitForAccess(fullPath: string, noFollow: boolean | NoParamCallback, callback?: NoParamCallback | number) {\n callback = typeof noFollow === 'function' ? noFollow : callback;\n noFollow = typeof noFollow === 'function' ? false : (noFollow as boolean);\n\n // Exponential backoff: 5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560ms\n // Total max wait: ~5 seconds\n function waitSymlink(attempts, cb) {\n fs.lstat(fullPath, (err) => {\n if (err) {\n if (err.code === 'ENOENT' && attempts < 10) {\n const delay = Math.min(5 * 2 ** attempts, 2560);\n return setTimeout(() => waitSymlink(attempts + 1, cb), delay);\n }\n return cb(err);\n }\n cb();\n });\n }\n function waitOpen(attempts, cb) {\n fs.open(fullPath, 'r', (err, fd) => {\n if (err) {\n if (err.code === 'ENOENT' && attempts < 10) {\n const delay = Math.min(5 * 2 ** attempts, 2560);\n return setTimeout(() => waitOpen(attempts + 1, cb), delay);\n }\n return cb(err);\n }\n fs.close(fd, () => cb());\n });\n }\n\n // Windows: NTFS metadata may not be committed yet, verify accessibility\n // Node 0.10: the write stream's finish/close events may fire before the file is fully flushed to disk\n // For symlinks (noFollow=true), use lstat to check the link itself exists\n // For files/dirs/hardlinks, use open to verify the file is accessible\n noFollow ? waitSymlink(0, callback) : waitOpen(0, callback);\n}\n"],"names":["fs","waitForAccess","fullPath","noFollow","callback","waitSymlink","attempts","cb","lstat","err","code","delay","Math","min","setTimeout","waitOpen","open","fd","close"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AAIpB,gGAAgG;AAChG,eAAe,SAASC,cAAcC,QAAgB,EAAEC,QAAmC,EAAEC,QAAmC;IAC9HA,WAAW,OAAOD,aAAa,aAAaA,WAAWC;IACvDD,WAAW,OAAOA,aAAa,aAAa,QAASA;IAErD,sEAAsE;IACtE,6BAA6B;IAC7B,SAASE,YAAYC,QAAQ,EAAEC,EAAE;QAC/BP,GAAGQ,KAAK,CAACN,UAAU,CAACO;YAClB,IAAIA,KAAK;gBACP,IAAIA,IAAIC,IAAI,KAAK,YAAYJ,WAAW,IAAI;oBAC1C,MAAMK,QAAQC,KAAKC,GAAG,CAAC,IAAI,KAAKP,UAAU;oBAC1C,OAAOQ,WAAW,IAAMT,YAAYC,WAAW,GAAGC,KAAKI;gBACzD;gBACA,OAAOJ,GAAGE;YACZ;YACAF;QACF;IACF;IACA,SAASQ,SAAST,QAAQ,EAAEC,EAAE;QAC5BP,GAAGgB,IAAI,CAACd,UAAU,KAAK,CAACO,KAAKQ;YAC3B,IAAIR,KAAK;gBACP,IAAIA,IAAIC,IAAI,KAAK,YAAYJ,WAAW,IAAI;oBAC1C,MAAMK,QAAQC,KAAKC,GAAG,CAAC,IAAI,KAAKP,UAAU;oBAC1C,OAAOQ,WAAW,IAAMC,SAAST,WAAW,GAAGC,KAAKI;gBACtD;gBACA,OAAOJ,GAAGE;YACZ;YACAT,GAAGkB,KAAK,CAACD,IAAI,IAAMV;QACrB;IACF;IAEA,wEAAwE;IACxE,sGAAsG;IACtG,0EAA0E;IAC1E,sEAAsE;IACtEJ,WAAWE,YAAY,GAAGD,YAAYW,SAAS,GAAGX;AACpD"}
|