extract-base-iterator 3.4.4 → 3.4.6
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/DirectoryEntry.js +25 -7
- package/dist/cjs/DirectoryEntry.js.map +1 -1
- package/dist/cjs/FileEntry.js +25 -7
- package/dist/cjs/FileEntry.js.map +1 -1
- package/dist/cjs/LinkEntry.js +33 -9
- package/dist/cjs/LinkEntry.js.map +1 -1
- package/dist/cjs/SymbolicLinkEntry.js +37 -10
- package/dist/cjs/SymbolicLinkEntry.js.map +1 -1
- package/dist/cjs/shared/compat.js +1 -0
- package/dist/cjs/shared/compat.js.map +1 -1
- package/dist/cjs/shared/streamToString.d.cts +1 -1
- package/dist/cjs/shared/streamToString.d.ts +1 -1
- package/dist/cjs/shared/streamToString.js +3 -6
- package/dist/cjs/shared/streamToString.js.map +1 -1
- package/dist/cjs/types.d.cts +1 -1
- package/dist/cjs/types.d.ts +1 -1
- package/dist/cjs/validateAttributes.js.map +1 -1
- package/dist/cjs/waitForAccess.js.map +1 -1
- package/dist/esm/DirectoryEntry.js +6 -6
- package/dist/esm/DirectoryEntry.js.map +1 -1
- package/dist/esm/FileEntry.js +6 -6
- package/dist/esm/FileEntry.js.map +1 -1
- package/dist/esm/LinkEntry.js +8 -8
- package/dist/esm/LinkEntry.js.map +1 -1
- package/dist/esm/SymbolicLinkEntry.js +10 -9
- package/dist/esm/SymbolicLinkEntry.js.map +1 -1
- package/dist/esm/shared/compat.js.map +1 -1
- package/dist/esm/shared/streamToString.d.ts +1 -1
- package/dist/esm/shared/streamToString.js +3 -6
- package/dist/esm/shared/streamToString.js.map +1 -1
- package/dist/esm/types.d.ts +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/validateAttributes.js.map +1 -1
- package/dist/esm/waitForAccess.js.map +1 -1
- package/package.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/waitForAccess.ts"],"sourcesContent":["import fs from 'graceful-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;;;iEALT;;;;;;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,
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/waitForAccess.ts"],"sourcesContent":["import fs from 'graceful-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: number, cb: NoParamCallback): void {\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: number, cb: NoParamCallback): void {\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 as NoParamCallback) : waitOpen(0, callback as NoParamCallback);\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;;;iEALT;;;;;;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,QAAgB,EAAEC,EAAmB;QACxDC,mBAAE,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,QAAgB,EAAEC,EAAmB;QACrDC,mBAAE,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,mBAAE,CAACW,KAAK,CAACD,IAAI;uBAAMX;;QACrB;IACF;IAEA,wEAAwE;IACxE,sGAAsG;IACtG,0EAA0E;IAC1E,sEAAsE;IACtEJ,WAAWE,YAAY,GAAGD,YAA+BY,SAAS,GAAGZ;AACvE"}
|
|
@@ -24,18 +24,18 @@ let DirectoryEntry = class DirectoryEntry {
|
|
|
24
24
|
const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));
|
|
25
25
|
// do not check for the existence of the directory but allow out-of-order calling
|
|
26
26
|
const queue = new Queue(1);
|
|
27
|
-
queue.defer(mkdirp
|
|
28
|
-
queue.defer(waitForAccess
|
|
29
|
-
queue.defer(chmod
|
|
30
|
-
queue.defer(chown
|
|
31
|
-
queue.defer(utimes
|
|
27
|
+
queue.defer((cb)=>mkdirp(fullPath, (err)=>cb(err)));
|
|
28
|
+
queue.defer((cb)=>waitForAccess(fullPath, cb));
|
|
29
|
+
queue.defer((cb)=>chmod(fullPath, this, options, (err)=>cb(err)));
|
|
30
|
+
queue.defer((cb)=>chown(fullPath, this, options, (err)=>cb(err)));
|
|
31
|
+
queue.defer((cb)=>utimes(fullPath, this, options, (err)=>cb(err)));
|
|
32
32
|
queue.await(callback);
|
|
33
33
|
} catch (err) {
|
|
34
34
|
callback(err);
|
|
35
35
|
}
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
return new Promise((resolve, reject)=>this.create(dest, options, (err
|
|
38
|
+
return new Promise((resolve, reject)=>this.create(dest, options, (err)=>err ? reject(err) : resolve(true)));
|
|
39
39
|
}
|
|
40
40
|
destroy() {}
|
|
41
41
|
constructor(attributes){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/DirectoryEntry.ts"],"sourcesContent":["import mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nimport type { Mode } from 'fs';\nimport type { DirectoryAttributes, ExtractOptions, NoParamCallback } from './types.ts';\n\nexport default class DirectoryEntry {\n mode
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/DirectoryEntry.ts"],"sourcesContent":["import mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nimport type { Mode } from 'fs';\nimport type { DirectoryAttributes, ExtractOptions, NoParamCallback } from './types.ts';\n\nexport default class DirectoryEntry {\n mode!: Mode;\n mtime!: number;\n path!: string;\n basename!: string;\n type!: string;\n\n constructor(attributes: DirectoryAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.type === undefined) this.type = 'directory';\n if (this.basename === undefined) this.basename = path.basename(this.path);\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));\n\n // do not check for the existence of the directory but allow out-of-order calling\n const queue = new Queue(1);\n queue.defer((cb) => mkdirp(fullPath, (err) => cb(err)));\n queue.defer((cb) => waitForAccess(fullPath, cb));\n queue.defer((cb) => chmod(fullPath, this, options as ExtractOptions, (err) => cb(err)));\n queue.defer((cb) => chown(fullPath, this, options as ExtractOptions, (err) => cb(err)));\n queue.defer((cb) => utimes(fullPath, this, options as ExtractOptions, (err) => cb(err)));\n queue.await(callback);\n } catch (err) {\n callback(err as Error);\n }\n return;\n }\n\n return new Promise((resolve, reject) => this.create(dest, options as ExtractOptions, (err?: Error | null) => (err ? reject(err) : resolve(true))));\n }\n\n destroy() {}\n}\n"],"names":["mkdirp","path","Queue","chmod","chown","utimes","objectAssign","safeJoinPath","stripPath","validateAttributes","waitForAccess","MANDATORY_ATTRIBUTES","DirectoryEntry","create","dest","options","callback","normalizedPath","normalize","fullPath","queue","defer","cb","err","await","Promise","resolve","reject","destroy","attributes","type","undefined","basename"],"mappings":"AAAA,OAAOA,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,YAAY,iBAAiB;AACpC,SAASC,YAAY,QAAQ,oBAAoB;AACjD,OAAOC,kBAAkB,2BAA2B;AACpD,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,wBAAwB,0BAA0B;AACzD,OAAOC,mBAAmB,qBAAqB;AAE/C,MAAMC,uBAAuB;IAAC;IAAQ;IAAS;CAAO;AAKvC,IAAA,AAAMC,iBAAN,MAAMA;IAiBnBC,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B,EAA2B;QACpHA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAE7D,IAAI,OAAOC,aAAa,YAAY;YAClC,IAAI;gBACF,MAAMC,iBAAiBhB,KAAKiB,SAAS,CAAC,IAAI,CAACjB,IAAI;gBAC/C,MAAMkB,WAAWZ,aAAaO,MAAMN,UAAUS,gBAAgBF;gBAE9D,iFAAiF;gBACjF,MAAMK,QAAQ,IAAIlB,MAAM;gBACxBkB,MAAMC,KAAK,CAAC,CAACC,KAAOtB,OAAOmB,UAAU,CAACI,MAAQD,GAAGC;gBACjDH,MAAMC,KAAK,CAAC,CAACC,KAAOZ,cAAcS,UAAUG;gBAC5CF,MAAMC,KAAK,CAAC,CAACC,KAAOnB,MAAMgB,UAAU,IAAI,EAAEJ,SAA2B,CAACQ,MAAQD,GAAGC;gBACjFH,MAAMC,KAAK,CAAC,CAACC,KAAOlB,MAAMe,UAAU,IAAI,EAAEJ,SAA2B,CAACQ,MAAQD,GAAGC;gBACjFH,MAAMC,KAAK,CAAC,CAACC,KAAOjB,OAAOc,UAAU,IAAI,EAAEJ,SAA2B,CAACQ,MAAQD,GAAGC;gBAClFH,MAAMI,KAAK,CAACR;YACd,EAAE,OAAOO,KAAK;gBACZP,SAASO;YACX;YACA;QACF;QAEA,OAAO,IAAIE,QAAQ,CAACC,SAASC,SAAW,IAAI,CAACd,MAAM,CAACC,MAAMC,SAA2B,CAACQ,MAAwBA,MAAMI,OAAOJ,OAAOG,QAAQ;IAC5I;IAEAE,UAAU,CAAC;IApCX,YAAYC,UAA+B,CAAE;QAC3CpB,mBAAmBoB,YAAYlB;QAC/BL,aAAa,IAAI,EAAEuB;QACnB,IAAI,IAAI,CAACC,IAAI,KAAKC,WAAW,IAAI,CAACD,IAAI,GAAG;QACzC,IAAI,IAAI,CAACE,QAAQ,KAAKD,WAAW,IAAI,CAACC,QAAQ,GAAG/B,KAAK+B,QAAQ,CAAC,IAAI,CAAC/B,IAAI;IAC1E;AAgCF;AA5CA,SAAqBW,4BA4CpB"}
|
package/dist/esm/FileEntry.js
CHANGED
|
@@ -48,19 +48,19 @@ let FileEntry = class FileEntry {
|
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
queue.defer(mkdirp
|
|
51
|
+
queue.defer((cb)=>mkdirp(path.dirname(fullPath), (err)=>cb(err)));
|
|
52
52
|
queue.defer(this._writeFile.bind(this, fullPath, options));
|
|
53
|
-
queue.defer(waitForAccess
|
|
54
|
-
queue.defer(chmod
|
|
55
|
-
queue.defer(chown
|
|
56
|
-
queue.defer(utimes
|
|
53
|
+
queue.defer((cb)=>waitForAccess(fullPath, cb));
|
|
54
|
+
queue.defer((cb)=>chmod(fullPath, this, options, (err)=>cb(err)));
|
|
55
|
+
queue.defer((cb)=>chown(fullPath, this, options, (err)=>cb(err)));
|
|
56
|
+
queue.defer((cb)=>utimes(fullPath, this, options, (err)=>cb(err)));
|
|
57
57
|
queue.await(callback);
|
|
58
58
|
} catch (err) {
|
|
59
59
|
callback(err);
|
|
60
60
|
}
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
return new Promise((resolve, reject)=>this.create(dest, options, (err
|
|
63
|
+
return new Promise((resolve, reject)=>this.create(dest, options, (err)=>err ? reject(err) : resolve(true)));
|
|
64
64
|
}
|
|
65
65
|
destroy() {}
|
|
66
66
|
constructor(attributes){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/FileEntry.ts"],"sourcesContent":["import { rm } from 'fs-remove-compat';\nimport fs from 'graceful-fs';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, FileAttributes, NoParamCallback, WriteFileFn } from './types.ts';\n\ninterface AbstractFileEntry {\n _writeFile: WriteFileFn;\n}\n\nexport default class FileEntry {\n mode
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/FileEntry.ts"],"sourcesContent":["import { rm } from 'fs-remove-compat';\nimport fs from 'graceful-fs';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, FileAttributes, NoParamCallback, WriteFileFn } from './types.ts';\n\ninterface AbstractFileEntry {\n _writeFile: WriteFileFn;\n}\n\nexport default class FileEntry {\n mode!: Mode;\n mtime!: number;\n path!: string;\n basename!: string;\n type!: string;\n\n constructor(attributes: FileAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'file';\n if ((this as unknown as AbstractFileEntry)._writeFile === undefined) throw new Error('File this missing _writeFile. Please implement this method in your subclass');\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n } else {\n // Check if file exists - throw EEXIST if it does\n queue.defer((callback) => {\n fs.stat(fullPath, (err) => {\n if (!err) {\n const existsErr = new Error(`EEXIST: file already exists, open '${fullPath}'`) as NodeJS.ErrnoException;\n existsErr.code = 'EEXIST';\n existsErr.path = fullPath;\n return callback(existsErr);\n }\n // ENOENT means file doesn't exist - that's what we want\n if (err.code === 'ENOENT') return callback();\n // Other errors should be reported\n callback(err);\n });\n });\n }\n queue.defer((cb) => mkdirp(path.dirname(fullPath), (err) => cb(err)));\n queue.defer((this as unknown as AbstractFileEntry)._writeFile.bind(this, fullPath, options));\n queue.defer((cb) => waitForAccess(fullPath, cb));\n queue.defer((cb) => chmod(fullPath, this, options as ExtractOptions, (err) => cb(err)));\n queue.defer((cb) => chown(fullPath, this, options as ExtractOptions, (err) => cb(err)));\n queue.defer((cb) => utimes(fullPath, this, options as ExtractOptions, (err) => cb(err)));\n queue.await(callback);\n } catch (err) {\n callback(err as Error);\n }\n return;\n }\n\n return new Promise((resolve, reject) => this.create(dest, options as ExtractOptions, (err?: Error | null) => (err ? reject(err) : resolve(true))));\n }\n\n destroy() {}\n}\n"],"names":["rm","fs","mkdirp","path","Queue","chmod","chown","utimes","objectAssign","safeJoinPath","stripPath","validateAttributes","waitForAccess","MANDATORY_ATTRIBUTES","FileEntry","create","dest","options","callback","normalizedPath","normalize","fullPath","queue","force","defer","err","code","stat","existsErr","Error","cb","dirname","_writeFile","bind","await","Promise","resolve","reject","destroy","attributes","basename","undefined","type"],"mappings":"AAAA,SAASA,EAAE,QAAQ,mBAAmB;AACtC,OAAOC,QAAQ,cAAc;AAC7B,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,YAAY,iBAAiB;AACpC,SAASC,YAAY,QAAQ,oBAAoB;AACjD,OAAOC,kBAAkB,2BAA2B;AACpD,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,wBAAwB,0BAA0B;AACzD,OAAOC,mBAAmB,qBAAqB;AAE/C,MAAMC,uBAAuB;IAAC;IAAQ;IAAS;CAAO;AASvC,IAAA,AAAMC,YAAN,MAAMA;IAkBnBC,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B,EAA2B;QACpHA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC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M,KAAOvB,OAAOc,UAAU,IAAI,EAAEJ,SAA2B,CAACQ,MAAQK,GAAGL;gBAClFH,MAAMY,KAAK,CAAChB;YACd,EAAE,OAAOO,KAAK;gBACZP,SAASO;YACX;YACA;QACF;QAEA,OAAO,IAAIU,QAAQ,CAACC,SAASC,SAAW,IAAI,CAACtB,MAAM,CAACC,MAAMC,SAA2B,CAACQ,MAAwBA,MAAMY,OAAOZ,OAAOW,QAAQ;IAC5I;IAEAE,UAAU,CAAC;IA5DX,YAAYC,UAA0B,CAAE;QACtC5B,mBAAmB4B,YAAY1B;QAC/BL,aAAa,IAAI,EAAE+B;QACnB,IAAI,IAAI,CAACC,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAGrC,KAAKqC,QAAQ,CAAC,IAAI,CAACrC,IAAI;QACxE,IAAI,IAAI,CAACuC,IAAI,KAAKD,WAAW,IAAI,CAACC,IAAI,GAAG;QACzC,IAAI,AAAC,IAAI,CAAkCV,UAAU,KAAKS,WAAW,MAAM,IAAIZ,MAAM;IACvF;AAuDF;AApEA,SAAqBf,uBAoEpB"}
|
package/dist/esm/LinkEntry.js
CHANGED
|
@@ -41,20 +41,20 @@ let LinkEntry = class LinkEntry {
|
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
queue.defer(mkdirp
|
|
45
|
-
queue.defer(waitForAccess
|
|
46
|
-
queue.defer(fs.link
|
|
47
|
-
queue.defer(waitForAccess
|
|
48
|
-
queue.defer(chmod
|
|
49
|
-
queue.defer(chown
|
|
50
|
-
queue.defer(utimes
|
|
44
|
+
queue.defer((cb)=>mkdirp(path.dirname(fullPath), (err)=>cb(err)));
|
|
45
|
+
queue.defer((cb)=>waitForAccess(linkFullPath, cb)); // ensure target file is accessible before linking
|
|
46
|
+
queue.defer((cb)=>fs.link(linkFullPath, fullPath, (err)=>cb(err)));
|
|
47
|
+
queue.defer((cb)=>waitForAccess(fullPath, cb));
|
|
48
|
+
queue.defer((cb)=>chmod(fullPath, this, options, (err)=>cb(err)));
|
|
49
|
+
queue.defer((cb)=>chown(fullPath, this, options, (err)=>cb(err)));
|
|
50
|
+
queue.defer((cb)=>utimes(fullPath, this, options, (err)=>cb(err)));
|
|
51
51
|
queue.await(callback);
|
|
52
52
|
} catch (err) {
|
|
53
53
|
callback(err);
|
|
54
54
|
}
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
return new Promise((resolve, reject)=>this.create(dest, options, (err
|
|
57
|
+
return new Promise((resolve, reject)=>this.create(dest, options, (err)=>err ? reject(err) : resolve(true)));
|
|
58
58
|
}
|
|
59
59
|
destroy() {}
|
|
60
60
|
constructor(attributes){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/LinkEntry.ts"],"sourcesContent":["import fs from 'fs';\nimport { rm } from 'fs-remove-compat';\nimport isAbsolute from 'is-absolute';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, LinkAttributes, NoParamCallback } from './types.ts';\n\nexport default class LinkEntry {\n mode
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/LinkEntry.ts"],"sourcesContent":["import fs from 'fs';\nimport { rm } from 'fs-remove-compat';\nimport isAbsolute from 'is-absolute';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport utimes from './fs/utimes.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, LinkAttributes, NoParamCallback } from './types.ts';\n\nexport default class LinkEntry {\n mode!: Mode;\n mtime!: number;\n path!: string;\n linkpath!: string;\n basename!: string;\n type!: string;\n\n constructor(attributes: LinkAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'link';\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));\n if (isAbsolute(this.linkpath)) {\n const err = new Error(`Absolute linkpath rejected: '${this.linkpath}'`) as NodeJS.ErrnoException;\n err.code = 'ETRAVERSAL';\n throw err;\n }\n const normalizedLinkpath = path.normalize(this.linkpath);\n const linkFullPath = safeJoinPath(dest, stripPath(normalizedLinkpath, options));\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n }\n queue.defer((cb) => mkdirp(path.dirname(fullPath), (err) => cb(err)));\n queue.defer((cb) => waitForAccess(linkFullPath, cb)); // ensure target file is accessible before linking\n queue.defer((cb) => fs.link(linkFullPath, fullPath, (err) => cb(err)));\n queue.defer((cb) => waitForAccess(fullPath, cb));\n queue.defer((cb) => chmod(fullPath, this, options as ExtractOptions, (err) => cb(err)));\n queue.defer((cb) => chown(fullPath, this, options as ExtractOptions, (err) => cb(err)));\n queue.defer((cb) => utimes(fullPath, this, options as ExtractOptions, (err) => cb(err)));\n queue.await(callback);\n } catch (err) {\n callback(err as Error);\n }\n return;\n }\n\n return new Promise((resolve, reject) => this.create(dest, options as ExtractOptions, (err?: Error | null) => (err ? reject(err) : resolve(true))));\n }\n\n destroy() {}\n}\n"],"names":["fs","rm","isAbsolute","mkdirp","path","Queue","chmod","chown","utimes","objectAssign","safeJoinPath","stripPath","validateAttributes","waitForAccess","MANDATORY_ATTRIBUTES","LinkEntry","create","dest","options","callback","normalizedPath","normalize","fullPath","linkpath","err","Error","code","normalizedLinkpath","linkFullPath","queue","force","defer","cb","dirname","link","await","Promise","resolve","reject","destroy","attributes","basename","undefined","type"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,SAASC,EAAE,QAAQ,mBAAmB;AACtC,OAAOC,gBAAgB,cAAc;AACrC,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,YAAY,iBAAiB;AACpC,SAASC,YAAY,QAAQ,oBAAoB;AACjD,OAAOC,kBAAkB,2BAA2B;AACpD,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,wBAAwB,0BAA0B;AACzD,OAAOC,mBAAmB,qBAAqB;AAE/C,MAAMC,uBAAuB;IAAC;IAAQ;IAAS;IAAQ;CAAW;AAKnD,IAAA,AAAMC,YAAN,MAAMA;IAkBnBC,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B,EAA2B;QACpHA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,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MAAME,KAAK,CAAC,CAACC,KAAOxB,OAAOc,UAAU,IAAI,EAAEJ,SAA2B,CAACM,MAAQQ,GAAGR;gBAClFK,MAAMM,KAAK,CAAChB;YACd,EAAE,OAAOK,KAAK;gBACZL,SAASK;YACX;YACA;QACF;QAEA,OAAO,IAAIY,QAAQ,CAACC,SAASC,SAAW,IAAI,CAACtB,MAAM,CAACC,MAAMC,SAA2B,CAACM,MAAwBA,MAAMc,OAAOd,OAAOa,QAAQ;IAC5I;IAEAE,UAAU,CAAC;IAnDX,YAAYC,UAA0B,CAAE;QACtC5B,mBAAmB4B,YAAY1B;QAC/BL,aAAa,IAAI,EAAE+B;QACnB,IAAI,IAAI,CAACC,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAGrC,KAAKqC,QAAQ,CAAC,IAAI,CAACrC,IAAI;QACxE,IAAI,IAAI,CAACuC,IAAI,KAAKD,WAAW,IAAI,CAACC,IAAI,GAAG;IAC3C;AA+CF;AA5DA,SAAqB5B,uBA4DpB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _process_env_OSTYPE;
|
|
1
2
|
import fs from 'fs';
|
|
2
3
|
import { rm } from 'fs-remove-compat';
|
|
3
4
|
import isAbsolute from 'is-absolute';
|
|
@@ -13,7 +14,7 @@ import safeJoinPath from './shared/safeJoinPath.js';
|
|
|
13
14
|
import stripPath from './shared/stripPath.js';
|
|
14
15
|
import validateAttributes from './validateAttributes.js';
|
|
15
16
|
import waitForAccess from './waitForAccess.js';
|
|
16
|
-
const isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);
|
|
17
|
+
const isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test((_process_env_OSTYPE = process.env.OSTYPE) !== null && _process_env_OSTYPE !== void 0 ? _process_env_OSTYPE : '');
|
|
17
18
|
const MANDATORY_ATTRIBUTES = [
|
|
18
19
|
'mode',
|
|
19
20
|
'mtime',
|
|
@@ -47,20 +48,20 @@ let SymbolicLinkEntry = class SymbolicLinkEntry {
|
|
|
47
48
|
});
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
|
-
queue.defer(mkdirp
|
|
51
|
-
if (isWindows) queue.defer(symlinkWin32
|
|
52
|
-
else queue.defer(fs.symlink
|
|
53
|
-
queue.defer(waitForAccess
|
|
54
|
-
queue.defer(chmod
|
|
55
|
-
queue.defer(chown
|
|
56
|
-
queue.defer(lutimes
|
|
51
|
+
queue.defer((cb)=>mkdirp(path.dirname(fullPath), (err)=>cb(err)));
|
|
52
|
+
if (isWindows) queue.defer((cb)=>symlinkWin32(linkFullPath, normalizedLinkpath, fullPath, (err)=>cb(err)));
|
|
53
|
+
else queue.defer((cb)=>fs.symlink(normalizedLinkpath, fullPath, (err)=>cb(err)));
|
|
54
|
+
queue.defer((cb)=>waitForAccess(fullPath, true, cb)); // noFollow=true for symlinks
|
|
55
|
+
queue.defer((cb)=>chmod(fullPath, this, options, (err)=>cb(err)));
|
|
56
|
+
queue.defer((cb)=>chown(fullPath, this, options, (err)=>cb(err)));
|
|
57
|
+
queue.defer((cb)=>lutimes(fullPath, this, options, (err)=>cb(err)));
|
|
57
58
|
queue.await(callback);
|
|
58
59
|
} catch (err) {
|
|
59
60
|
callback(err);
|
|
60
61
|
}
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
|
-
return new Promise((resolve, reject)=>this.create(dest, options, (err
|
|
64
|
+
return new Promise((resolve, reject)=>this.create(dest, options, (err)=>err ? reject(err) : resolve(true)));
|
|
64
65
|
}
|
|
65
66
|
destroy() {}
|
|
66
67
|
constructor(attributes){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/SymbolicLinkEntry.ts"],"sourcesContent":["import fs from 'fs';\nimport { rm } from 'fs-remove-compat';\nimport isAbsolute from 'is-absolute';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport lutimes from './fs/lutimes.ts';\nimport symlinkWin32 from './fs/symlinkWin32.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, LinkAttributes, NoParamCallback } from './types.ts';\n\nexport default class SymbolicLinkEntry {\n mode
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/SymbolicLinkEntry.ts"],"sourcesContent":["import fs from 'fs';\nimport { rm } from 'fs-remove-compat';\nimport isAbsolute from 'is-absolute';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport chmod from './fs/chmod.ts';\nimport chown from './fs/chown.ts';\nimport lutimes from './fs/lutimes.ts';\nimport symlinkWin32 from './fs/symlinkWin32.ts';\nimport { objectAssign } from './shared/index.ts';\nimport safeJoinPath from './shared/safeJoinPath.ts';\nimport stripPath from './shared/stripPath.ts';\nimport validateAttributes from './validateAttributes.ts';\nimport waitForAccess from './waitForAccess.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE ?? '');\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nimport type { Mode } from 'fs';\nimport type { ExtractOptions, LinkAttributes, NoParamCallback } from './types.ts';\n\nexport default class SymbolicLinkEntry {\n mode!: Mode;\n mtime!: number;\n path!: string;\n linkpath!: string;\n basename!: string;\n type!: string;\n\n constructor(attributes: LinkAttributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n objectAssign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'symlink';\n }\n\n create(dest: string, callback: NoParamCallback): void;\n create(dest: string, options: ExtractOptions, callback: NoParamCallback): void;\n create(dest: string, options?: ExtractOptions): Promise<boolean>;\n create(dest: string, options?: ExtractOptions | NoParamCallback, callback?: NoParamCallback): void | Promise<boolean> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as ExtractOptions);\n\n if (typeof callback === 'function') {\n try {\n const normalizedPath = path.normalize(this.path);\n const fullPath = safeJoinPath(dest, stripPath(normalizedPath, options));\n\n if (isAbsolute(this.linkpath)) {\n const err = new Error(`Absolute linkpath rejected: '${this.linkpath}'`) as NodeJS.ErrnoException;\n err.code = 'ETRAVERSAL';\n throw err;\n }\n // Resolve the symlink target against the symlink's own directory and verify it\n // stays within dest. safeJoinPath throws ETRAVERSAL if it escapes.\n const targetAbs = path.resolve(path.dirname(fullPath), this.linkpath);\n safeJoinPath(dest, path.relative(dest, targetAbs));\n const normalizedLinkpath = path.relative(path.dirname(fullPath), targetAbs);\n const linkFullPath = targetAbs;\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rm(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n }\n queue.defer((cb) => mkdirp(path.dirname(fullPath), (err) => cb(err)));\n if (isWindows) queue.defer((cb) => symlinkWin32(linkFullPath, normalizedLinkpath, fullPath, (err) => cb(err)));\n else queue.defer((cb) => fs.symlink(normalizedLinkpath, fullPath, (err) => cb(err)));\n queue.defer((cb) => waitForAccess(fullPath, true, cb)); // noFollow=true for symlinks\n queue.defer((cb) => chmod(fullPath, this, options as ExtractOptions, (err) => cb(err)));\n queue.defer((cb) => chown(fullPath, this, options as ExtractOptions, (err) => cb(err)));\n queue.defer((cb) => lutimes(fullPath, this, options as ExtractOptions, (err) => cb(err)));\n queue.await(callback);\n } catch (err) {\n callback(err as Error);\n }\n return;\n }\n\n return new Promise((resolve, reject) => this.create(dest, options as ExtractOptions, (err?: Error | null) => (err ? reject(err) : resolve(true))));\n }\n\n destroy() {}\n}\n"],"names":["process","fs","rm","isAbsolute","mkdirp","path","Queue","chmod","chown","lutimes","symlinkWin32","objectAssign","safeJoinPath","stripPath","validateAttributes","waitForAccess","isWindows","platform","test","env","OSTYPE","MANDATORY_ATTRIBUTES","SymbolicLinkEntry","create","dest","options","callback","normalizedPath","normalize","fullPath","linkpath","err","Error","code","targetAbs","resolve","dirname","relative","normalizedLinkpath","linkFullPath","queue","force","defer","cb","symlink","await","Promise","reject","destroy","attributes","basename","undefined","type"],"mappings":"IAgByEA;AAhBzE,OAAOC,QAAQ,KAAK;AACpB,SAASC,EAAE,QAAQ,mBAAmB;AACtC,OAAOC,gBAAgB,cAAc;AACrC,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,WAAW,gBAAgB;AAClC,OAAOC,aAAa,kBAAkB;AACtC,OAAOC,kBAAkB,uBAAuB;AAChD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,OAAOC,kBAAkB,2BAA2B;AACpD,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,wBAAwB,0BAA0B;AACzD,OAAOC,mBAAmB,qBAAqB;AAE/C,MAAMC,YAAYhB,QAAQiB,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,EAAClB,sBAAAA,QAAQmB,GAAG,CAACC,MAAM,cAAlBpB,iCAAAA,sBAAsB;AAE/F,MAAMqB,uBAAuB;IAAC;IAAQ;IAAS;IAAQ;CAAW;AAKnD,IAAA,AAAMC,oBAAN,MAAMA;IAkBnBC,OAAOC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B,EAA2B;QACpHA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;QACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;QAE7D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C,CAACC,KAAOpC,MAAMsB,UAAU,IAAI,EAAEJ,SAA2B,CAACM,MAAQY,GAAGZ;gBACjFS,MAAME,KAAK,CAAC,CAACC,KAAOnC,MAAMqB,UAAU,IAAI,EAAEJ,SAA2B,CAACM,MAAQY,GAAGZ;gBACjFS,MAAME,KAAK,CAAC,CAACC,KAAOlC,QAAQoB,UAAU,IAAI,EAAEJ,SAA2B,CAACM,MAAQY,GAAGZ;gBACnFS,MAAMK,KAAK,CAACnB;YACd,EAAE,OAAOK,KAAK;gBACZL,SAASK;YACX;YACA;QACF;QAEA,OAAO,IAAIe,QAAQ,CAACX,SAASY,SAAW,IAAI,CAACxB,MAAM,CAACC,MAAMC,SAA2B,CAACM,MAAwBA,MAAMgB,OAAOhB,OAAOI,QAAQ;IAC5I;IAEAa,UAAU,CAAC;IAxDX,YAAYC,UAA0B,CAAE;QACtCnC,mBAAmBmC,YAAY5B;QAC/BV,aAAa,IAAI,EAAEsC;QACnB,IAAI,IAAI,CAACC,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAG7C,KAAK6C,QAAQ,CAAC,IAAI,CAAC7C,IAAI;QACxE,IAAI,IAAI,CAAC+C,IAAI,KAAKD,WAAW,IAAI,CAACC,IAAI,GAAG;IAC3C;AAoDF;AAjEA,SAAqB9B,+BAiEpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/compat.ts"],"sourcesContent":["/**\n * Buffer Compatibility Layer for Node.js 0.8+\n *\n * Provides buffer utilities that work across all Node.js versions\n * WITHOUT modifying global Buffer object.\n *\n * Version history:\n * - Node 0.8-4.4: Only has `new Buffer()`, no `Buffer.alloc/from`\n * - Node 4.5+: Has `Buffer.alloc/from`, deprecates `new Buffer()`\n * - Node 10+: Warns or errors on `new Buffer()`\n *\n * Solution: Feature detection with graceful fallback in both directions.\n */\n\n// ESM-compatible require - works in both CJS and ESM\nimport Module from 'module';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n// Feature detection (runs once at module load)\nconst hasBufferAlloc = typeof Buffer.alloc === 'function';\nconst hasBufferAllocUnsafe = typeof Buffer.allocUnsafe === 'function';\nconst hasBufferFrom = typeof Buffer.from === 'function' && Buffer.from !== Uint8Array.from;\n\n// Maximum buffer size that works across all Node.js versions\n// Node 0.8-4.x: kMaxLength = 0x3fffffff (~1073MB) but actual limit may be lower\n// Node 6-7.x: ~1073MB for Uint8Array\n// Node 8+: ~2GB for Buffer\n// Node 10+: 2^31-1 (~2147MB) for Buffer.allocUnsafe\n// Use 256MB as a conservative limit for buffer operations\n// Must leave room for pairwise combination (256MB * 2 = 512MB, 512MB * 2 = 1024MB, etc.)\nexport const MAX_SAFE_BUFFER_LENGTH = 256 * 1024 * 1024; // 256MB\n\n// Try to detect the actual kMaxLength for this Node version\n// If we can't detect it (older Node), assume conservative limit\nlet DETECTED_MAX_LENGTH: number | null = null;\n\nfunction getMaxBufferLength(): number {\n if (DETECTED_MAX_LENGTH !== null) return DETECTED_MAX_LENGTH;\n\n // kMaxLength may not exist at runtime on very old or very new Node\n // Modern Node (v8+) doesn't expose kMaxLength but allows large buffers\n const maxLen = (Buffer as { kMaxLength?: number }).kMaxLength;\n if (maxLen !== undefined) {\n DETECTED_MAX_LENGTH = maxLen;\n } else {\n // Node 0.8-4.x: use conservative limit\n // Node 8+: can allocate up to ~2GB (v8 array buffer limit)\n // Use the higher limit for modern Node\n const nodeVersion = parseInt(process.version.slice(1).split('.')[0], 10);\n if (nodeVersion >= 8) {\n DETECTED_MAX_LENGTH = Number.MAX_SAFE_INTEGER; // Effectively unlimited\n } else {\n DETECTED_MAX_LENGTH = 0x3fffffff; // ~1073MB for older Node\n }\n }\n\n return DETECTED_MAX_LENGTH;\n}\n\n/**\n * Check if a buffer size can be safely allocated on this Node version\n * Uses conservative limit to work across all versions\n */\nexport function canAllocateBufferSize(size: number): boolean {\n return size >= 0 && size <= MAX_SAFE_BUFFER_LENGTH;\n}\n\n/**\n * Create a single chunk of the specified size\n */\nfunction createChunk(size: number, zeroFill: boolean): Buffer {\n if (hasBufferAlloc) {\n return Buffer.alloc(size);\n }\n const buf = new Buffer(size);\n if (zeroFill) buf.fill(0);\n return buf;\n}\n\n/**\n * Combine an array of buffers into one by iterative concatenation\n * Stays under the actual kMaxLength for each Node version\n * Uses a \"fill and continue\" approach\n */\nfunction combineBuffersPairwise(buffers: Buffer[]): Buffer {\n const maxLength = getMaxBufferLength();\n\n // Calculate total size\n let totalSize = 0;\n for (let i = 0; i < buffers.length; i++) {\n totalSize += buffers[i].length;\n }\n\n // If total exceeds this Node version's limit, we cannot combine\n // LZMA1 requires a single contiguous Buffer input\n if (totalSize > maxLength) {\n throw new Error(`Cannot combine buffers: total size (${totalSize} bytes) exceeds Node.js buffer limit (${maxLength} bytes). LZMA1 archives with folders larger than ${Math.floor(maxLength / 1024 / 1024)}MB cannot be processed on this Node version.`);\n }\n\n // If everything fits in a single allocation, do it directly\n const result = createChunk(totalSize, false);\n let offset = 0;\n for (let i = 0; i < buffers.length; i++) {\n buffers[i].copy(result, offset);\n offset += buffers[i].length;\n }\n return result;\n}\n\n/**\n * Allocate a large buffer by allocating in chunks and combining them\n * Handles both zero-filled (safe) and uninitialized (unsafe) variants\n */\nfunction allocBufferLarge(size: number, zeroFill: boolean): Buffer {\n // For large sizes, allocate smaller chunks and combine them\n const numChunks = Math.ceil(size / MAX_SAFE_BUFFER_LENGTH);\n const chunks: Buffer[] = [];\n\n // Allocate individual chunks (each <= MAX_SAFE_BUFFER_LENGTH)\n for (let i = 0; i < numChunks; i++) {\n const chunkSize = Math.min(MAX_SAFE_BUFFER_LENGTH, size - i * MAX_SAFE_BUFFER_LENGTH);\n chunks.push(createChunk(chunkSize, zeroFill));\n }\n\n // Combine chunks iteratively using pairwise combination\n return combineBuffersPairwise(chunks);\n}\n\n/**\n * Allocate a zero-filled buffer (safe) - handles very large allocations\n * - Uses Buffer.alloc() on Node 4.5+\n * - Falls back to new Buffer() + fill on Node 0.8-4.4\n * - For sizes > MAX_SAFE_BUFFER_LENGTH, allocates in chunks and copies\n */\nexport function allocBuffer(size: number): Buffer {\n if (size === 0) {\n return new Buffer(0);\n }\n\n // Use native allocation for sizes within safe limits\n if (canAllocateBufferSize(size)) {\n if (hasBufferAlloc) {\n return Buffer.alloc(size);\n }\n // Legacy fallback: new Buffer() is uninitialized, must zero-fill\n const buf = new Buffer(size);\n buf.fill(0);\n return buf;\n }\n\n // For large sizes, allocate in chunks with zero-filling\n return allocBufferLarge(size, true);\n}\n\n/**\n * Allocate a buffer without initialization (unsafe but faster)\n * - Uses Buffer.allocUnsafe() on Node 4.5+\n * - Falls back to new Buffer() on Node 0.8-4.4\n * - For sizes > MAX_SAFE_BUFFER_LENGTH, allocates in chunks without zeroing\n *\n * WARNING: Buffer contents are uninitialized and may contain sensitive data.\n * Only use when you will immediately overwrite all bytes.\n */\nexport function allocBufferUnsafe(size: number): Buffer {\n if (size === 0) {\n return new Buffer(0);\n }\n\n // Use native allocation for sizes within safe limits\n if (canAllocateBufferSize(size)) {\n if (hasBufferAllocUnsafe) {\n return Buffer.allocUnsafe(size);\n }\n return new Buffer(size);\n }\n\n // For large sizes, allocate in chunks without zero-filling\n return allocBufferLarge(size, false);\n}\n\n/**\n * Create a buffer from string, array, or existing buffer\n * - Uses Buffer.from() on Node 4.5+\n * - Falls back to new Buffer() on Node 0.8-4.4\n * - Handles Uint8Array conversion for Node 0.8 (crypto output compatibility)\n */\nexport function bufferFrom(data: string | number[] | Buffer | Uint8Array, encoding?: BufferEncoding): Buffer {\n if (hasBufferFrom) {\n if (typeof data === 'string') {\n return Buffer.from(data, encoding);\n }\n return Buffer.from(data as number[] | Buffer);\n }\n // Node 0.8 compatibility - deprecated Buffer constructor\n // For Uint8Array, convert to array first (needed for crypto output in Node 0.8)\n if (data instanceof Uint8Array && !(data instanceof Buffer)) {\n const arr: number[] = [];\n for (let i = 0; i < data.length; i++) {\n arr.push(data[i]);\n }\n return new Buffer(arr);\n }\n return new Buffer(data as string & number[], encoding);\n}\n\n/**\n * Compare two buffers or buffer regions\n * - Uses Buffer.compare() on Node 5.10+ (with offset support)\n * - Falls back to manual comparison on Node 0.8-5.9\n */\nexport function bufferCompare(source: Buffer, target: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number {\n sourceStart = sourceStart || 0;\n sourceEnd = sourceEnd || source.length;\n targetStart = targetStart || 0;\n targetEnd = targetEnd || target.length;\n\n // Check if native compare with offset support exists (Node 5.10+)\n if (source.compare && source.compare.length >= 5) {\n return source.compare(target, targetStart, targetEnd, sourceStart, sourceEnd);\n }\n\n // Manual comparison for older Node versions\n const sourceLen = sourceEnd - sourceStart;\n const targetLen = targetEnd - targetStart;\n const len = Math.min(sourceLen, targetLen);\n\n for (let i = 0; i < len; i++) {\n const s = source[sourceStart + i];\n const t = target[targetStart + i];\n if (s !== t) return s < t ? -1 : 1;\n }\n\n return sourceLen - targetLen;\n}\n\n/**\n * Check if buffer region equals byte array\n * Useful for magic number detection without Buffer.from()\n */\nexport function bufferEquals(buf: Buffer, offset: number, expected: number[]): boolean {\n if (offset + expected.length > buf.length) return false;\n for (let i = 0; i < expected.length; i++) {\n if (buf[offset + i] !== expected[i]) return false;\n }\n return true;\n}\n\n/**\n * Copy buffer region to new buffer\n * Works on all Node versions\n */\nexport function bufferSliceCopy(buf: Buffer, start: number, end: number): Buffer {\n const result = allocBuffer(end - start);\n buf.copy(result, 0, start, end);\n return result;\n}\n\n/**\n * Read 64-bit unsigned integer (little-endian)\n * Uses two 32-bit reads since BigInt not available until Node 10.4\n *\n * WARNING: Only accurate for values < Number.MAX_SAFE_INTEGER (2^53 - 1)\n * This covers files up to ~9 PB which is practical for all real use cases.\n */\nexport function readUInt64LE(buf: Buffer, offset: number): number {\n const low = buf.readUInt32LE(offset);\n const high = buf.readUInt32LE(offset + 4);\n return high * 0x100000000 + low;\n}\n\n/**\n * Write 64-bit unsigned integer (little-endian)\n * Same precision limitation as readUInt64LE\n */\nexport function writeUInt64LE(buf: Buffer, value: number, offset: number): void {\n const low = value >>> 0;\n const high = (value / 0x100000000) >>> 0;\n buf.writeUInt32LE(low, offset);\n buf.writeUInt32LE(high, offset + 4);\n}\n\n/**\n * Concatenate buffers - compatible with Node 0.8+\n * Handles crypto output which may not be proper Buffer instances in old Node.\n * Also handles very large concatenations that would exceed buffer limits.\n *\n * NOTE: This function is primarily needed for AES decryption compatibility\n * in Node 0.8 where crypto output may not be proper Buffer instances.\n * Libraries not using crypto can use native Buffer.concat() directly.\n */\nexport function bufferConcat(list: (Buffer | Uint8Array)[], totalLength?: number): Buffer {\n // Calculate actual total length first\n let actualLength = 0;\n for (let i = 0; i < list.length; i++) {\n actualLength += list[i].length;\n }\n\n // Use specified totalLength or actual length\n const targetLength = totalLength !== undefined ? totalLength : actualLength;\n\n // Handle empty list\n if (list.length === 0) {\n return new Buffer(0);\n }\n\n // Handle very large concatenations that would exceed buffer limits\n // Use native Buffer.concat for smaller sizes (faster)\n if (targetLength <= MAX_SAFE_BUFFER_LENGTH) {\n // Check if all items are proper Buffers AND no truncation needed\n // (Node 0.8's Buffer.concat doesn't handle truncation well)\n let allBuffers = true;\n for (let j = 0; j < list.length; j++) {\n if (!(list[j] instanceof Buffer)) {\n allBuffers = false;\n break;\n }\n }\n if (allBuffers && targetLength >= actualLength) {\n return Buffer.concat(list as Buffer[], targetLength);\n }\n }\n\n // For large or complex concatenations, use chunked approach\n // This will use allocBuffer which handles large sizes via chunking\n const result = allocBuffer(targetLength);\n let offset = 0;\n\n for (let k = 0; k < list.length && offset < targetLength; k++) {\n const buf = list[k];\n const toCopy = Math.min(buf.length, targetLength - offset);\n\n if (buf instanceof Buffer) {\n buf.copy(result, offset, 0, toCopy);\n } else {\n // Uint8Array - need to copy byte by byte\n for (let l = 0; l < toCopy; l++) {\n result[offset + l] = buf[l];\n }\n }\n offset += toCopy;\n }\n\n return result;\n}\n\n/**\n * Node 0.8 compatible isNaN (Number.isNaN didn't exist until ES2015)\n * Uses self-comparison: NaN is the only value not equal to itself\n */\n// biome-ignore lint/suspicious/noShadowRestrictedNames: Legacy compatibility\nexport function isNaN(value: number): boolean {\n // biome-ignore lint/suspicious/noSelfCompare: NaN check pattern\n return value !== value;\n}\n\n/**\n * String.prototype.startsWith wrapper for Node.js 0.8+\n * - Uses native startsWith on Node 4.0+ / ES2015+\n * - Falls back to indexOf on Node 0.8-3.x\n */\nconst hasStartsWith = typeof String.prototype.startsWith === 'function';\nexport function stringStartsWith(str: string, search: string, position?: number): boolean {\n if (hasStartsWith) return str.startsWith(search, position);\n position = position || 0;\n return str.indexOf(search, position) === position;\n}\n\n/**\n * Decompress raw DEFLATE data (no zlib/gzip header)\n * - Uses native zlib.inflateRawSync() on Node 0.11.12+\n * - Falls back to pako for Node 0.8-0.10\n *\n * Version history:\n * - Node 0.8-0.10: No zlib sync methods, use pako\n * - Node 0.11.12+: zlib.inflateRawSync available\n */\n// Feature detection for native zlib sync methods (Node 0.11.12+)\nlet zlib: typeof import('zlib') | null = null;\ntry {\n zlib = _require('zlib');\n} catch (_e) {\n // zlib not available (shouldn't happen in Node.js)\n}\nconst hasNativeInflateRaw = zlib !== null && typeof zlib.inflateRawSync === 'function';\n\nexport function inflateRaw(input: Buffer): Buffer {\n if (hasNativeInflateRaw && zlib) {\n return zlib.inflateRawSync(input);\n }\n // Fallback to pako for Node 0.8-0.10\n const pako = _require('pako');\n return bufferFrom(pako.inflateRaw(input));\n}\n\n/**\n * Create a streaming raw DEFLATE decompressor (Transform stream)\n * Decompresses data incrementally to avoid holding full output in memory.\n *\n * - Uses native zlib.createInflateRaw() on Node 0.11.12+\n * - Falls back to pako-based Transform for Node 0.8-0.10\n *\n * @returns A Transform stream that decompresses raw DEFLATE data\n */\n// Check for native streaming inflate (Node 0.11.12+ has createInflateRaw)\n// biome-ignore lint/suspicious/noExplicitAny: createInflateRaw not in older TS definitions\nconst hasNativeStreamingInflate = zlib !== null && typeof (zlib as any).createInflateRaw === 'function';\n\nexport function createInflateRawStream(): NodeJS.ReadWriteStream {\n if (hasNativeStreamingInflate && zlib) {\n // Use native zlib streaming Transform\n // biome-ignore lint/suspicious/noExplicitAny: createInflateRaw not in older TS definitions\n return (zlib as any).createInflateRaw();\n }\n\n // Fallback to pako-based Transform for Node 0.8-0.10\n // Use readable-stream for Node 0.8 compatibility\n const Transform = _require('readable-stream').Transform;\n const pako = _require('pako');\n\n const inflate = new pako.Inflate({ raw: true, chunkSize: 16384 });\n const transform = new Transform();\n const pendingChunks: Buffer[] = [];\n let ended = false;\n\n // Pako calls onData synchronously during push()\n inflate.onData = (chunk: Uint8Array) => {\n pendingChunks.push(bufferFrom(chunk));\n };\n\n inflate.onEnd = (status: number) => {\n ended = true;\n if (status !== 0) {\n transform.emit('error', new Error(`Inflate error: ${inflate.msg || 'unknown'}`));\n }\n };\n\n transform._transform = function (chunk: Buffer, _encoding: string, callback: (err?: Error) => void) {\n try {\n inflate.push(chunk, false);\n // Push any pending decompressed chunks\n while (pendingChunks.length > 0) {\n this.push(pendingChunks.shift());\n }\n callback();\n } catch (err) {\n callback(err as Error);\n }\n };\n\n transform._flush = function (callback: (err?: Error) => void) {\n try {\n inflate.push(new Uint8Array(0), true); // Signal end\n // Push any remaining decompressed chunks\n while (pendingChunks.length > 0) {\n this.push(pendingChunks.shift());\n }\n if (ended && inflate.err) {\n callback(new Error(`Inflate error: ${inflate.msg || 'unknown'}`));\n } else {\n callback();\n }\n } catch (err) {\n callback(err as Error);\n }\n };\n\n return transform;\n}\n\n/**\n * Object.assign wrapper for Node.js 0.8+\n * - Uses native Object.assign on Node 4.0+\n * - Falls back to manual property copy on Node 0.8-3.x\n */\nconst hasObjectAssign = typeof Object.assign === 'function';\nconst _hasOwnProperty = Object.prototype.hasOwnProperty;\n\nexport function objectAssign<T, U>(target: T, source: U): T & U {\n if (hasObjectAssign) return Object.assign(target, source);\n\n for (const key in source) {\n if (_hasOwnProperty.call(source, key)) (target as Record<string, unknown>)[key] = source[key];\n }\n return target as T & U;\n}\n\n/**\n * Stream compatibility - Transform class\n * - Uses native stream.Transform on Node 0.10+\n * - Falls back to readable-stream for Node 0.8\n */\nconst major = +process.versions.node.split('.')[0];\nexport const Readable: typeof import('stream').Readable = major > 0 ? _require('stream').Readable : _require('readable-stream').Readable;\nexport const Writable: typeof import('stream').Writable = major > 0 ? _require('stream').Writable : _require('readable-stream').Writable;\nexport const Transform: typeof import('stream').Transform = major > 0 ? _require('stream').Transform : _require('readable-stream').Transform;\nexport const PassThrough: typeof import('stream').PassThrough = major > 0 ? _require('stream').PassThrough : _require('readable-stream').PassThrough;\n"],"names":["Module","_require","require","createRequire","url","hasBufferAlloc","Buffer","alloc","hasBufferAllocUnsafe","allocUnsafe","hasBufferFrom","from","Uint8Array","MAX_SAFE_BUFFER_LENGTH","DETECTED_MAX_LENGTH","getMaxBufferLength","maxLen","kMaxLength","undefined","nodeVersion","parseInt","process","version","slice","split","Number","MAX_SAFE_INTEGER","canAllocateBufferSize","size","createChunk","zeroFill","buf","fill","combineBuffersPairwise","buffers","maxLength","totalSize","i","length","Error","Math","floor","result","offset","copy","allocBufferLarge","numChunks","ceil","chunks","chunkSize","min","push","allocBuffer","allocBufferUnsafe","bufferFrom","data","encoding","arr","bufferCompare","source","target","targetStart","targetEnd","sourceStart","sourceEnd","compare","sourceLen","targetLen","len","s","t","bufferEquals","expected","bufferSliceCopy","start","end","readUInt64LE","low","readUInt32LE","high","writeUInt64LE","value","writeUInt32LE","bufferConcat","list","totalLength","actualLength","targetLength","allBuffers","j","concat","k","toCopy","l","isNaN","hasStartsWith","String","prototype","startsWith","stringStartsWith","str","search","position","indexOf","zlib","_e","hasNativeInflateRaw","inflateRawSync","inflateRaw","input","pako","hasNativeStreamingInflate","createInflateRaw","createInflateRawStream","Transform","inflate","Inflate","raw","transform","pendingChunks","ended","onData","chunk","onEnd","status","emit","msg","_transform","_encoding","callback","shift","err","_flush","hasObjectAssign","Object","assign","_hasOwnProperty","hasOwnProperty","objectAssign","key","call","major","versions","node","Readable","Writable","PassThrough"],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAED,qDAAqD;AACrD,OAAOA,YAAY,SAAS;AAE5B,MAAMC,WAAW,OAAOC,YAAY,cAAcF,OAAOG,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE1F,+CAA+C;AAC/C,MAAMG,iBAAiB,OAAOC,OAAOC,KAAK,KAAK;AAC/C,MAAMC,uBAAuB,OAAOF,OAAOG,WAAW,KAAK;AAC3D,MAAMC,gBAAgB,OAAOJ,OAAOK,IAAI,KAAK,cAAcL,OAAOK,IAAI,KAAKC,WAAWD,IAAI;AAE1F,6DAA6D;AAC7D,gFAAgF;AAChF,qCAAqC;AACrC,2BAA2B;AAC3B,oDAAoD;AACpD,0DAA0D;AAC1D,yFAAyF;AACzF,OAAO,MAAME,yBAAyB,MAAM,OAAO,KAAK,CAAC,QAAQ;AAEjE,4DAA4D;AAC5D,gEAAgE;AAChE,IAAIC,sBAAqC;AAEzC,SAASC;IACP,IAAID,wBAAwB,MAAM,OAAOA;IAEzC,mEAAmE;IACnE,uEAAuE;IACvE,MAAME,SAAS,AAACV,OAAmCW,UAAU;IAC7D,IAAID,WAAWE,WAAW;QACxBJ,sBAAsBE;IACxB,OAAO;QACL,uCAAuC;QACvC,2DAA2D;QAC3D,uCAAuC;QACvC,MAAMG,cAAcC,SAASC,QAAQC,OAAO,CAACC,KAAK,CAAC,GAAGC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE;QACrE,IAAIL,eAAe,GAAG;YACpBL,sBAAsBW,OAAOC,gBAAgB,EAAE,wBAAwB;QACzE,OAAO;YACLZ,sBAAsB,YAAY,yBAAyB;QAC7D;IACF;IAEA,OAAOA;AACT;AAEA;;;CAGC,GACD,OAAO,SAASa,sBAAsBC,IAAY;IAChD,OAAOA,QAAQ,KAAKA,QAAQf;AAC9B;AAEA;;CAEC,GACD,SAASgB,YAAYD,IAAY,EAAEE,QAAiB;IA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Node.js 0.8+\n *\n * Provides buffer utilities that work across all Node.js versions\n * WITHOUT modifying global Buffer object.\n *\n * Version history:\n * - Node 0.8-4.4: Only has `new Buffer()`, no `Buffer.alloc/from`\n * - Node 4.5+: Has `Buffer.alloc/from`, deprecates `new Buffer()`\n * - Node 10+: Warns or errors on `new Buffer()`\n *\n * Solution: Feature detection with graceful fallback in both directions.\n */\n\n// ESM-compatible require - works in both CJS and ESM\nimport Module from 'module';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n// Feature detection (runs once at module load)\nconst hasBufferAlloc = typeof Buffer.alloc === 'function';\nconst hasBufferAllocUnsafe = typeof Buffer.allocUnsafe === 'function';\nconst hasBufferFrom = typeof Buffer.from === 'function' && Buffer.from !== Uint8Array.from;\n\n// Maximum buffer size that works across all Node.js versions\n// Node 0.8-4.x: kMaxLength = 0x3fffffff (~1073MB) but actual limit may be lower\n// Node 6-7.x: ~1073MB for Uint8Array\n// Node 8+: ~2GB for Buffer\n// Node 10+: 2^31-1 (~2147MB) for Buffer.allocUnsafe\n// Use 256MB as a conservative limit for buffer operations\n// Must leave room for pairwise combination (256MB * 2 = 512MB, 512MB * 2 = 1024MB, etc.)\nexport const MAX_SAFE_BUFFER_LENGTH = 256 * 1024 * 1024; // 256MB\n\n// Try to detect the actual kMaxLength for this Node version\n// If we can't detect it (older Node), assume conservative limit\nlet DETECTED_MAX_LENGTH: number | null = null;\n\nfunction getMaxBufferLength(): number {\n if (DETECTED_MAX_LENGTH !== null) return DETECTED_MAX_LENGTH;\n\n // kMaxLength may not exist at runtime on very old or very new Node\n // Modern Node (v8+) doesn't expose kMaxLength but allows large buffers\n const maxLen = (Buffer as { kMaxLength?: number }).kMaxLength;\n if (maxLen !== undefined) {\n DETECTED_MAX_LENGTH = maxLen;\n } else {\n // Node 0.8-4.x: use conservative limit\n // Node 8+: can allocate up to ~2GB (v8 array buffer limit)\n // Use the higher limit for modern Node\n const nodeVersion = parseInt(process.version.slice(1).split('.')[0], 10);\n if (nodeVersion >= 8) {\n DETECTED_MAX_LENGTH = Number.MAX_SAFE_INTEGER; // Effectively unlimited\n } else {\n DETECTED_MAX_LENGTH = 0x3fffffff; // ~1073MB for older Node\n }\n }\n\n return DETECTED_MAX_LENGTH;\n}\n\n/**\n * Check if a buffer size can be safely allocated on this Node version\n * Uses conservative limit to work across all versions\n */\nexport function canAllocateBufferSize(size: number): boolean {\n return size >= 0 && size <= MAX_SAFE_BUFFER_LENGTH;\n}\n\n/**\n * Create a single chunk of the specified size\n */\nfunction createChunk(size: number, zeroFill: boolean): Buffer {\n if (hasBufferAlloc) {\n return Buffer.alloc(size);\n }\n const buf = new Buffer(size);\n if (zeroFill) buf.fill(0);\n return buf;\n}\n\n/**\n * Combine an array of buffers into one by iterative concatenation\n * Stays under the actual kMaxLength for each Node version\n * Uses a \"fill and continue\" approach\n */\nfunction combineBuffersPairwise(buffers: Buffer[]): Buffer {\n const maxLength = getMaxBufferLength();\n\n // Calculate total size\n let totalSize = 0;\n for (let i = 0; i < buffers.length; i++) {\n totalSize += buffers[i].length;\n }\n\n // If total exceeds this Node version's limit, we cannot combine\n // LZMA1 requires a single contiguous Buffer input\n if (totalSize > maxLength) {\n throw new Error(`Cannot combine buffers: total size (${totalSize} bytes) exceeds Node.js buffer limit (${maxLength} bytes). LZMA1 archives with folders larger than ${Math.floor(maxLength / 1024 / 1024)}MB cannot be processed on this Node version.`);\n }\n\n // If everything fits in a single allocation, do it directly\n const result = createChunk(totalSize, false);\n let offset = 0;\n for (let i = 0; i < buffers.length; i++) {\n buffers[i].copy(result, offset);\n offset += buffers[i].length;\n }\n return result;\n}\n\n/**\n * Allocate a large buffer by allocating in chunks and combining them\n * Handles both zero-filled (safe) and uninitialized (unsafe) variants\n */\nfunction allocBufferLarge(size: number, zeroFill: boolean): Buffer {\n // For large sizes, allocate smaller chunks and combine them\n const numChunks = Math.ceil(size / MAX_SAFE_BUFFER_LENGTH);\n const chunks: Buffer[] = [];\n\n // Allocate individual chunks (each <= MAX_SAFE_BUFFER_LENGTH)\n for (let i = 0; i < numChunks; i++) {\n const chunkSize = Math.min(MAX_SAFE_BUFFER_LENGTH, size - i * MAX_SAFE_BUFFER_LENGTH);\n chunks.push(createChunk(chunkSize, zeroFill));\n }\n\n // Combine chunks iteratively using pairwise combination\n return combineBuffersPairwise(chunks);\n}\n\n/**\n * Allocate a zero-filled buffer (safe) - handles very large allocations\n * - Uses Buffer.alloc() on Node 4.5+\n * - Falls back to new Buffer() + fill on Node 0.8-4.4\n * - For sizes > MAX_SAFE_BUFFER_LENGTH, allocates in chunks and copies\n */\nexport function allocBuffer(size: number): Buffer {\n if (size === 0) {\n return new Buffer(0);\n }\n\n // Use native allocation for sizes within safe limits\n if (canAllocateBufferSize(size)) {\n if (hasBufferAlloc) {\n return Buffer.alloc(size);\n }\n // Legacy fallback: new Buffer() is uninitialized, must zero-fill\n const buf = new Buffer(size);\n buf.fill(0);\n return buf;\n }\n\n // For large sizes, allocate in chunks with zero-filling\n return allocBufferLarge(size, true);\n}\n\n/**\n * Allocate a buffer without initialization (unsafe but faster)\n * - Uses Buffer.allocUnsafe() on Node 4.5+\n * - Falls back to new Buffer() on Node 0.8-4.4\n * - For sizes > MAX_SAFE_BUFFER_LENGTH, allocates in chunks without zeroing\n *\n * WARNING: Buffer contents are uninitialized and may contain sensitive data.\n * Only use when you will immediately overwrite all bytes.\n */\nexport function allocBufferUnsafe(size: number): Buffer {\n if (size === 0) {\n return new Buffer(0);\n }\n\n // Use native allocation for sizes within safe limits\n if (canAllocateBufferSize(size)) {\n if (hasBufferAllocUnsafe) {\n return Buffer.allocUnsafe(size);\n }\n return new Buffer(size);\n }\n\n // For large sizes, allocate in chunks without zero-filling\n return allocBufferLarge(size, false);\n}\n\n/**\n * Create a buffer from string, array, or existing buffer\n * - Uses Buffer.from() on Node 4.5+\n * - Falls back to new Buffer() on Node 0.8-4.4\n * - Handles Uint8Array conversion for Node 0.8 (crypto output compatibility)\n */\nexport function bufferFrom(data: string | number[] | Buffer | Uint8Array, encoding?: BufferEncoding): Buffer {\n if (hasBufferFrom) {\n if (typeof data === 'string') {\n return Buffer.from(data, encoding);\n }\n return Buffer.from(data as number[] | Buffer);\n }\n // Node 0.8 compatibility - deprecated Buffer constructor\n // For Uint8Array, convert to array first (needed for crypto output in Node 0.8)\n if (data instanceof Uint8Array && !(data instanceof Buffer)) {\n const arr: number[] = [];\n for (let i = 0; i < data.length; i++) {\n arr.push(data[i]);\n }\n return new Buffer(arr);\n }\n return new Buffer(data as string & number[], encoding);\n}\n\n/**\n * Compare two buffers or buffer regions\n * - Uses Buffer.compare() on Node 5.10+ (with offset support)\n * - Falls back to manual comparison on Node 0.8-5.9\n */\nexport function bufferCompare(source: Buffer, target: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number {\n sourceStart = sourceStart || 0;\n sourceEnd = sourceEnd || source.length;\n targetStart = targetStart || 0;\n targetEnd = targetEnd || target.length;\n\n // Check if native compare with offset support exists (Node 5.10+)\n if (source.compare && source.compare.length >= 5) {\n return source.compare(target, targetStart, targetEnd, sourceStart, sourceEnd);\n }\n\n // Manual comparison for older Node versions\n const sourceLen = sourceEnd - sourceStart;\n const targetLen = targetEnd - targetStart;\n const len = Math.min(sourceLen, targetLen);\n\n for (let i = 0; i < len; i++) {\n const s = source[sourceStart + i];\n const t = target[targetStart + i];\n if (s !== t) return s < t ? -1 : 1;\n }\n\n return sourceLen - targetLen;\n}\n\n/**\n * Check if buffer region equals byte array\n * Useful for magic number detection without Buffer.from()\n */\nexport function bufferEquals(buf: Buffer, offset: number, expected: number[]): boolean {\n if (offset + expected.length > buf.length) return false;\n for (let i = 0; i < expected.length; i++) {\n if (buf[offset + i] !== expected[i]) return false;\n }\n return true;\n}\n\n/**\n * Copy buffer region to new buffer\n * Works on all Node versions\n */\nexport function bufferSliceCopy(buf: Buffer, start: number, end: number): Buffer {\n const result = allocBuffer(end - start);\n buf.copy(result, 0, start, end);\n return result;\n}\n\n/**\n * Read 64-bit unsigned integer (little-endian)\n * Uses two 32-bit reads since BigInt not available until Node 10.4\n *\n * WARNING: Only accurate for values < Number.MAX_SAFE_INTEGER (2^53 - 1)\n * This covers files up to ~9 PB which is practical for all real use cases.\n */\nexport function readUInt64LE(buf: Buffer, offset: number): number {\n const low = buf.readUInt32LE(offset);\n const high = buf.readUInt32LE(offset + 4);\n return high * 0x100000000 + low;\n}\n\n/**\n * Write 64-bit unsigned integer (little-endian)\n * Same precision limitation as readUInt64LE\n */\nexport function writeUInt64LE(buf: Buffer, value: number, offset: number): void {\n const low = value >>> 0;\n const high = (value / 0x100000000) >>> 0;\n buf.writeUInt32LE(low, offset);\n buf.writeUInt32LE(high, offset + 4);\n}\n\n/**\n * Concatenate buffers - compatible with Node 0.8+\n * Handles crypto output which may not be proper Buffer instances in old Node.\n * Also handles very large concatenations that would exceed buffer limits.\n *\n * NOTE: This function is primarily needed for AES decryption compatibility\n * in Node 0.8 where crypto output may not be proper Buffer instances.\n * Libraries not using crypto can use native Buffer.concat() directly.\n */\nexport function bufferConcat(list: (Buffer | Uint8Array)[], totalLength?: number): Buffer {\n // Calculate actual total length first\n let actualLength = 0;\n for (let i = 0; i < list.length; i++) {\n actualLength += list[i].length;\n }\n\n // Use specified totalLength or actual length\n const targetLength = totalLength !== undefined ? totalLength : actualLength;\n\n // Handle empty list\n if (list.length === 0) {\n return new Buffer(0);\n }\n\n // Handle very large concatenations that would exceed buffer limits\n // Use native Buffer.concat for smaller sizes (faster)\n if (targetLength <= MAX_SAFE_BUFFER_LENGTH) {\n // Check if all items are proper Buffers AND no truncation needed\n // (Node 0.8's Buffer.concat doesn't handle truncation well)\n let allBuffers = true;\n for (let j = 0; j < list.length; j++) {\n if (!(list[j] instanceof Buffer)) {\n allBuffers = false;\n break;\n }\n }\n if (allBuffers && targetLength >= actualLength) {\n return Buffer.concat(list as Buffer[], targetLength);\n }\n }\n\n // For large or complex concatenations, use chunked approach\n // This will use allocBuffer which handles large sizes via chunking\n const result = allocBuffer(targetLength);\n let offset = 0;\n\n for (let k = 0; k < list.length && offset < targetLength; k++) {\n const buf = list[k];\n const toCopy = Math.min(buf.length, targetLength - offset);\n\n if (buf instanceof Buffer) {\n buf.copy(result, offset, 0, toCopy);\n } else {\n // Uint8Array - need to copy byte by byte\n for (let l = 0; l < toCopy; l++) {\n result[offset + l] = buf[l];\n }\n }\n offset += toCopy;\n }\n\n return result;\n}\n\n/**\n * Node 0.8 compatible isNaN (Number.isNaN didn't exist until ES2015)\n * Uses self-comparison: NaN is the only value not equal to itself\n */\n// biome-ignore lint/suspicious/noShadowRestrictedNames: Legacy compatibility\nexport function isNaN(value: number): boolean {\n // biome-ignore lint/suspicious/noSelfCompare: NaN check pattern\n return value !== value;\n}\n\n/**\n * String.prototype.startsWith wrapper for Node.js 0.8+\n * - Uses native startsWith on Node 4.0+ / ES2015+\n * - Falls back to indexOf on Node 0.8-3.x\n */\nconst hasStartsWith = typeof String.prototype.startsWith === 'function';\nexport function stringStartsWith(str: string, search: string, position?: number): boolean {\n if (hasStartsWith) return str.startsWith(search, position);\n position = position || 0;\n return str.indexOf(search, position) === position;\n}\n\n/**\n * Decompress raw DEFLATE data (no zlib/gzip header)\n * - Uses native zlib.inflateRawSync() on Node 0.11.12+\n * - Falls back to pako for Node 0.8-0.10\n *\n * Version history:\n * - Node 0.8-0.10: No zlib sync methods, use pako\n * - Node 0.11.12+: zlib.inflateRawSync available\n */\n// Feature detection for native zlib sync methods (Node 0.11.12+)\nlet zlib: typeof import('zlib') | null = null;\ntry {\n zlib = _require('zlib');\n} catch (_e) {\n // zlib not available (shouldn't happen in Node.js)\n}\nconst hasNativeInflateRaw = zlib !== null && typeof zlib.inflateRawSync === 'function';\n\nexport function inflateRaw(input: Buffer): Buffer {\n if (hasNativeInflateRaw && zlib) {\n return zlib.inflateRawSync(input);\n }\n // Fallback to pako for Node 0.8-0.10\n const pako = _require('pako');\n return bufferFrom(pako.inflateRaw(input));\n}\n\n/**\n * Create a streaming raw DEFLATE decompressor (Transform stream)\n * Decompresses data incrementally to avoid holding full output in memory.\n *\n * - Uses native zlib.createInflateRaw() on Node 0.11.12+\n * - Falls back to pako-based Transform for Node 0.8-0.10\n *\n * @returns A Transform stream that decompresses raw DEFLATE data\n */\n// Check for native streaming inflate (Node 0.11.12+ has createInflateRaw)\n// biome-ignore lint/suspicious/noExplicitAny: createInflateRaw not in older TS definitions\nconst hasNativeStreamingInflate = zlib !== null && typeof (zlib as any).createInflateRaw === 'function';\n\nexport function createInflateRawStream(): NodeJS.ReadWriteStream {\n if (hasNativeStreamingInflate && zlib) {\n // Use native zlib streaming Transform\n // biome-ignore lint/suspicious/noExplicitAny: createInflateRaw not in older TS definitions\n return (zlib as any).createInflateRaw();\n }\n\n // Fallback to pako-based Transform for Node 0.8-0.10\n // Use readable-stream for Node 0.8 compatibility\n const Transform = _require('readable-stream').Transform;\n const pako = _require('pako');\n\n const inflate = new pako.Inflate({ raw: true, chunkSize: 16384 });\n const transform = new Transform();\n const pendingChunks: Buffer[] = [];\n let ended = false;\n\n // Pako calls onData synchronously during push()\n inflate.onData = (chunk: Uint8Array) => {\n pendingChunks.push(bufferFrom(chunk));\n };\n\n inflate.onEnd = (status: number) => {\n ended = true;\n if (status !== 0) {\n transform.emit('error', new Error(`Inflate error: ${inflate.msg || 'unknown'}`));\n }\n };\n\n transform._transform = function (chunk: Buffer, _encoding: string, callback: (err?: Error | null) => void) {\n try {\n inflate.push(chunk, false);\n // Push any pending decompressed chunks\n while (pendingChunks.length > 0) {\n this.push(pendingChunks.shift());\n }\n callback();\n } catch (err) {\n callback(err as Error);\n }\n };\n\n transform._flush = function (callback: (err?: Error | null) => void) {\n try {\n inflate.push(new Uint8Array(0), true); // Signal end\n // Push any remaining decompressed chunks\n while (pendingChunks.length > 0) {\n this.push(pendingChunks.shift());\n }\n if (ended && inflate.err) {\n callback(new Error(`Inflate error: ${inflate.msg || 'unknown'}`));\n } else {\n callback();\n }\n } catch (err) {\n callback(err as Error);\n }\n };\n\n return transform;\n}\n\n/**\n * Object.assign wrapper for Node.js 0.8+\n * - Uses native Object.assign on Node 4.0+\n * - Falls back to manual property copy on Node 0.8-3.x\n */\nconst hasObjectAssign = typeof Object.assign === 'function';\nconst _hasOwnProperty = Object.prototype.hasOwnProperty;\n\nexport function objectAssign<T, U>(target: T, source: U): T & U {\n if (hasObjectAssign) return Object.assign(target as object, source) as T & U;\n\n for (const key in source) {\n if (_hasOwnProperty.call(source, key)) (target as Record<string, unknown>)[key] = source[key];\n }\n return target as T & U;\n}\n\n/**\n * Stream compatibility - Transform class\n * - Uses native stream.Transform on Node 0.10+\n * - Falls back to readable-stream for Node 0.8\n */\nconst major = +process.versions.node.split('.')[0];\nexport const Readable: typeof import('stream').Readable = major > 0 ? _require('stream').Readable : _require('readable-stream').Readable;\nexport const Writable: typeof import('stream').Writable = major > 0 ? _require('stream').Writable : _require('readable-stream').Writable;\nexport const Transform: typeof import('stream').Transform = major > 0 ? _require('stream').Transform : _require('readable-stream').Transform;\nexport const PassThrough: typeof import('stream').PassThrough = major > 0 ? _require('stream').PassThrough : _require('readable-stream').PassThrough;\n"],"names":["Module","_require","require","createRequire","url","hasBufferAlloc","Buffer","alloc","hasBufferAllocUnsafe","allocUnsafe","hasBufferFrom","from","Uint8Array","MAX_SAFE_BUFFER_LENGTH","DETECTED_MAX_LENGTH","getMaxBufferLength","maxLen","kMaxLength","undefined","nodeVersion","parseInt","process","version","slice","split","Number","MAX_SAFE_INTEGER","canAllocateBufferSize","size","createChunk","zeroFill","buf","fill","combineBuffersPairwise","buffers","maxLength","totalSize","i","length","Error","Math","floor","result","offset","copy","allocBufferLarge","numChunks","ceil","chunks","chunkSize","min","push","allocBuffer","allocBufferUnsafe","bufferFrom","data","encoding","arr","bufferCompare","source","target","targetStart","targetEnd","sourceStart","sourceEnd","compare","sourceLen","targetLen","len","s","t","bufferEquals","expected","bufferSliceCopy","start","end","readUInt64LE","low","readUInt32LE","high","writeUInt64LE","value","writeUInt32LE","bufferConcat","list","totalLength","actualLength","targetLength","allBuffers","j","concat","k","toCopy","l","isNaN","hasStartsWith","String","prototype","startsWith","stringStartsWith","str","search","position","indexOf","zlib","_e","hasNativeInflateRaw","inflateRawSync","inflateRaw","input","pako","hasNativeStreamingInflate","createInflateRaw","createInflateRawStream","Transform","inflate","Inflate","raw","transform","pendingChunks","ended","onData","chunk","onEnd","status","emit","msg","_transform","_encoding","callback","shift","err","_flush","hasObjectAssign","Object","assign","_hasOwnProperty","hasOwnProperty","objectAssign","key","call","major","versions","node","Readable","Writable","PassThrough"],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAED,qDAAqD;AACrD,OAAOA,YAAY,SAAS;AAE5B,MAAMC,WAAW,OAAOC,YAAY,cAAcF,OAAOG,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE1F,+CAA+C;AAC/C,MAAMG,iBAAiB,OAAOC,OAAOC,KAAK,KAAK;AAC/C,MAAMC,uBAAuB,OAAOF,OAAOG,WAAW,KAAK;AAC3D,MAAMC,gBAAgB,OAAOJ,OAAOK,IAAI,KAAK,cAAcL,OAAOK,IAAI,KAAKC,WAAWD,IAAI;AAE1F,6DAA6D;AAC7D,gFAAgF;AAChF,qCAAqC;AACrC,2BAA2B;AAC3B,oDAAoD;AACpD,0DAA0D;AAC1D,yFAAyF;AACzF,OAAO,MAAME,yBAAyB,MAAM,OAAO,KAAK,CAAC,QAAQ;AAEjE,4DAA4D;AAC5D,gEAAgE;AAChE,IAAIC,sBAAqC;AAEzC,SAASC;IACP,IAAID,wBAAwB,MAAM,OAAOA;IAEzC,mEAAmE;IACnE,uEAAuE;IACvE,MAAME,SAAS,AAACV,OAAmCW,UAAU;IAC7D,IAAID,WAAWE,WAAW;QACxBJ,sBAAsBE;IACxB,OAAO;QACL,uCAAuC;QACvC,2DAA2D;QAC3D,uCAAuC;QACvC,MAAMG,cAAcC,SAASC,QAAQC,OAAO,CAACC,KAAK,CAAC,GAAGC,KAAK,CAAC,IAAI,CAAC,EAAE,E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B,QAAQ,IAAI5I,SAAS,UAAUiH,SAAS,GAAGjH,SAAS,mBAAmBiH,SAAS,CAAC;AAC7I,OAAO,MAAMgC,cAAmDL,QAAQ,IAAI5I,SAAS,UAAUiJ,WAAW,GAAGjJ,SAAS,mBAAmBiJ,WAAW,CAAC"}
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Node 0.8+ compatible.
|
|
8
8
|
*/
|
|
9
|
-
export type StreamToStringCallback = (error?: Error, result?: string) => void;
|
|
9
|
+
export type StreamToStringCallback = (error?: Error | null, result?: string) => void;
|
|
10
10
|
export default function streamToString(stream: NodeJS.ReadableStream, callback: StreamToStringCallback): void;
|
|
@@ -23,12 +23,9 @@ export default function streamToString(stream, callback) {
|
|
|
23
23
|
'end',
|
|
24
24
|
'close'
|
|
25
25
|
], (err)=>{
|
|
26
|
-
if (err)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const content = Buffer.concat(chunks).toString('utf8');
|
|
30
|
-
callback(null, content);
|
|
31
|
-
}
|
|
26
|
+
if (err) return callback(err);
|
|
27
|
+
const content = Buffer.concat(chunks).toString('utf8');
|
|
28
|
+
callback(undefined, content);
|
|
32
29
|
});
|
|
33
30
|
// Ensure stream is flowing (in case it's paused)
|
|
34
31
|
if (typeof stream.resume === 'function') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/streamToString.ts"],"sourcesContent":["/**\n * Read entire stream content as string\n *\n * Handles both flowing streams and streams that have already\n * buffered data (using readable stream semantics).\n *\n * Node 0.8+ compatible.\n */\n\nimport oo from 'on-one';\nimport { bufferFrom } from './compat.ts';\n\nexport type StreamToStringCallback = (error?: Error, result?: string) => void;\n\nexport default function streamToString(stream: NodeJS.ReadableStream, callback: StreamToStringCallback): void {\n const chunks: Buffer[] = [];\n\n // Handle data from the stream\n stream.on('data', (chunk: Buffer | string) => {\n if (typeof chunk === 'string') {\n chunks.push(bufferFrom(chunk, 'utf8'));\n } else {\n chunks.push(chunk);\n }\n });\n\n // Handle stream end events using on-one for Node 0.8 compatibility\n oo(stream, ['error', 'end', 'close'], (err
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/streamToString.ts"],"sourcesContent":["/**\n * Read entire stream content as string\n *\n * Handles both flowing streams and streams that have already\n * buffered data (using readable stream semantics).\n *\n * Node 0.8+ compatible.\n */\n\nimport oo from 'on-one';\nimport { bufferFrom } from './compat.ts';\n\nexport type StreamToStringCallback = (error?: Error | null, result?: string) => void;\n\nexport default function streamToString(stream: NodeJS.ReadableStream, callback: StreamToStringCallback): void {\n const chunks: Buffer[] = [];\n\n // Handle data from the stream\n stream.on('data', (chunk: Buffer | string) => {\n if (typeof chunk === 'string') {\n chunks.push(bufferFrom(chunk, 'utf8'));\n } else {\n chunks.push(chunk);\n }\n });\n\n // Handle stream end events using on-one for Node 0.8 compatibility\n oo(stream, ['error', 'end', 'close'], (err: Error | null) => {\n if (err) return callback(err);\n const content = Buffer.concat(chunks).toString('utf8');\n callback(undefined, content);\n });\n\n // Ensure stream is flowing (in case it's paused)\n if (typeof (stream as NodeJS.ReadStream).resume === 'function') {\n (stream as NodeJS.ReadStream).resume();\n }\n}\n"],"names":["oo","bufferFrom","streamToString","stream","callback","chunks","on","chunk","push","err","content","Buffer","concat","toString","undefined","resume"],"mappings":"AAAA;;;;;;;CAOC,GAED,OAAOA,QAAQ,SAAS;AACxB,SAASC,UAAU,QAAQ,cAAc;AAIzC,eAAe,SAASC,eAAeC,MAA6B,EAAEC,QAAgC;IACpG,MAAMC,SAAmB,EAAE;IAE3B,8BAA8B;IAC9BF,OAAOG,EAAE,CAAC,QAAQ,CAACC;QACjB,IAAI,OAAOA,UAAU,UAAU;YAC7BF,OAAOG,IAAI,CAACP,WAAWM,OAAO;QAChC,OAAO;YACLF,OAAOG,IAAI,CAACD;QACd;IACF;IAEA,mEAAmE;IACnEP,GAAGG,QAAQ;QAAC;QAAS;QAAO;KAAQ,EAAE,CAACM;QACrC,IAAIA,KAAK,OAAOL,SAASK;QACzB,MAAMC,UAAUC,OAAOC,MAAM,CAACP,QAAQQ,QAAQ,CAAC;QAC/CT,SAASU,WAAWJ;IACtB;IAEA,iDAAiD;IACjD,IAAI,OAAO,AAACP,OAA6BY,MAAM,KAAK,YAAY;QAC7DZ,OAA6BY,MAAM;IACtC;AACF"}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface ExtractOptions extends StackOptions {
|
|
|
5
5
|
strip?: number;
|
|
6
6
|
now?: Date;
|
|
7
7
|
}
|
|
8
|
-
export type NoParamCallback = (error?: Error) => void;
|
|
8
|
+
export type NoParamCallback = (error?: Error | null) => void;
|
|
9
9
|
export type WriteFileFn = (path: string, options: object, callback: NoParamCallback) => void;
|
|
10
10
|
export interface FileAttributes {
|
|
11
11
|
mode: Mode;
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/types.ts"],"sourcesContent":["import type { Mode } from 'fs';\nimport type { StackOptions } from 'stack-base-iterator';\n\nexport interface ExtractOptions extends StackOptions {\n force?: boolean;\n strip?: number;\n now?: Date;\n}\n\nexport type NoParamCallback = (error?: Error) => void;\nexport type WriteFileFn = (path: string, options: object, callback: NoParamCallback) => void;\n\nexport interface FileAttributes {\n mode: Mode;\n mtime: number;\n path: string;\n}\n\nexport interface DirectoryAttributes {\n mode: Mode;\n mtime: number | Date;\n path: string;\n}\n\nexport interface LinkAttributes {\n mode: Mode;\n mtime: number;\n path: string;\n linkpath: string;\n}\n\nimport type { default as DirectoryEntry } from './DirectoryEntry.ts';\nimport type { default as FileEntry } from './FileEntry.ts';\nimport type { default as LinkEntry } from './LinkEntry.ts';\nimport type { default as SymbolicLinkEntry } from './SymbolicLinkEntry.ts';\n\nexport type Entry = DirectoryEntry | FileEntry | LinkEntry | SymbolicLinkEntry;\n\nexport interface AbstractEntry {\n mode: Mode;\n mtime: number;\n path: string;\n basename: string;\n type: string;\n linkpath?: string;\n uid?: number;\n gid?: number;\n}\n"],"names":[],"mappings":"AAsCA,WASC"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/types.ts"],"sourcesContent":["import type { Mode } from 'fs';\nimport type { StackOptions } from 'stack-base-iterator';\n\nexport interface ExtractOptions extends StackOptions {\n force?: boolean;\n strip?: number;\n now?: Date;\n}\n\nexport type NoParamCallback = (error?: Error | null) => void;\nexport type WriteFileFn = (path: string, options: object, callback: NoParamCallback) => void;\n\nexport interface FileAttributes {\n mode: Mode;\n mtime: number;\n path: string;\n}\n\nexport interface DirectoryAttributes {\n mode: Mode;\n mtime: number | Date;\n path: string;\n}\n\nexport interface LinkAttributes {\n mode: Mode;\n mtime: number;\n path: string;\n linkpath: string;\n}\n\nimport type { default as DirectoryEntry } from './DirectoryEntry.ts';\nimport type { default as FileEntry } from './FileEntry.ts';\nimport type { default as LinkEntry } from './LinkEntry.ts';\nimport type { default as SymbolicLinkEntry } from './SymbolicLinkEntry.ts';\n\nexport type Entry = DirectoryEntry | FileEntry | LinkEntry | SymbolicLinkEntry;\n\nexport interface AbstractEntry {\n mode: Mode;\n mtime: number;\n path: string;\n basename: string;\n type: string;\n linkpath?: string;\n uid?: number;\n gid?: number;\n}\n"],"names":[],"mappings":"AAsCA,WASC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/validateAttributes.ts"],"sourcesContent":["export default function validateAttributes(attributes: object, keys: string[]): void {\n for (let index = 0; index < keys.length; index++) {\n const key = keys[index];\n if (attributes[key] === undefined) throw new Error(`Missing attribute ${key}.Attributes ${JSON.stringify(attributes)}`);\n }\n}\n"],"names":["validateAttributes","attributes","keys","index","length","key","undefined","Error","JSON","stringify"],"mappings":"AAAA,eAAe,SAASA,mBAAmBC,UAAkB,EAAEC,IAAc;IAC3E,IAAK,IAAIC,QAAQ,GAAGA,QAAQD,KAAKE,MAAM,EAAED,QAAS;QAChD,MAAME,MAAMH,IAAI,CAACC,MAAM;QACvB,
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/validateAttributes.ts"],"sourcesContent":["export default function validateAttributes(attributes: object, keys: string[]): void {\n for (let index = 0; index < keys.length; index++) {\n const key = keys[index];\n if ((attributes as Record<string, unknown>)[key] === undefined) throw new Error(`Missing attribute ${key}.Attributes ${JSON.stringify(attributes)}`);\n }\n}\n"],"names":["validateAttributes","attributes","keys","index","length","key","undefined","Error","JSON","stringify"],"mappings":"AAAA,eAAe,SAASA,mBAAmBC,UAAkB,EAAEC,IAAc;IAC3E,IAAK,IAAIC,QAAQ,GAAGA,QAAQD,KAAKE,MAAM,EAAED,QAAS;QAChD,MAAME,MAAMH,IAAI,CAACC,MAAM;QACvB,IAAI,AAACF,UAAsC,CAACI,IAAI,KAAKC,WAAW,MAAM,IAAIC,MAAM,CAAC,kBAAkB,EAAEF,IAAI,YAAY,EAAEG,KAAKC,SAAS,CAACR,aAAa;IACrJ;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/waitForAccess.ts"],"sourcesContent":["import fs from 'graceful-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,cAAc;AAI7B,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,
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/waitForAccess.ts"],"sourcesContent":["import fs from 'graceful-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: number, cb: NoParamCallback): void {\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: number, cb: NoParamCallback): void {\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 as NoParamCallback) : waitOpen(0, callback as NoParamCallback);\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,cAAc;AAI7B,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,QAAgB,EAAEC,EAAmB;QACxDP,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,QAAgB,EAAEC,EAAmB;QACrDP,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,YAA+BW,SAAS,GAAGX;AACvE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "extract-base-iterator",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.6",
|
|
4
4
|
"description": "Base iterator for extract iterators like tar-iterator and zip-iterator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"extract",
|
|
@@ -54,6 +54,8 @@
|
|
|
54
54
|
"stack-base-iterator": "^3.0.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
+
"@types/graceful-fs": "^4.1.9",
|
|
58
|
+
"@types/is-absolute": "^1.0.2",
|
|
57
59
|
"@types/mocha": "*",
|
|
58
60
|
"@types/node": "*",
|
|
59
61
|
"cr": "^0.1.0",
|