tar-iterator 0.3.1 → 1.0.0
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/FileEntry.js +174 -59
- package/dist/cjs/FileEntry.js.map +1 -1
- package/dist/cjs/TarIterator.js +173 -73
- package/dist/cjs/TarIterator.js.map +1 -1
- package/dist/cjs/index.js +25 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/Lock.js +20 -11
- package/dist/cjs/lib/Lock.js.map +1 -1
- package/dist/cjs/lib/fifoRemove.js +12 -8
- package/dist/cjs/lib/fifoRemove.js.map +1 -1
- package/dist/cjs/lib/waitForAccess.js +17 -9
- package/dist/cjs/lib/waitForAccess.js.map +1 -1
- package/dist/cjs/nextEntry.js +55 -23
- package/dist/cjs/nextEntry.js.map +1 -1
- package/dist/esm/FileEntry.mjs +59 -0
- package/dist/esm/FileEntry.mjs.map +1 -0
- package/dist/esm/TarIterator.mjs +68 -0
- package/dist/esm/TarIterator.mjs.map +1 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/lib/Lock.mjs +13 -0
- package/dist/esm/lib/Lock.mjs.map +1 -0
- package/dist/esm/lib/fifoRemove.mjs +9 -0
- package/dist/esm/lib/fifoRemove.mjs.map +1 -0
- package/dist/esm/lib/waitForAccess.mjs +7 -0
- package/dist/esm/lib/waitForAccess.mjs.map +1 -0
- package/dist/esm/nextEntry.mjs +50 -0
- package/dist/esm/nextEntry.mjs.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/types/{FileEntry.d.cts → FileEntry.d.mts} +1 -3
- package/dist/types/TarIterator.d.mts +6 -0
- package/dist/types/index.d.mts +2 -1
- package/dist/types/lib/Lock.d.mts +2 -0
- package/dist/types/lib/fifoRemove.d.mts +1 -0
- package/dist/types/lib/waitForAccess.d.mts +1 -0
- package/dist/types/nextEntry.d.mts +1 -0
- package/package.json +15 -5
- package/dist/types/TarIterator.d.cts +0 -8
- package/dist/types/lib/Lock.d.cts +0 -2
- package/dist/types/lib/fifoRemove.d.cts +0 -2
- package/dist/types/lib/waitForAccess.d.cts +0 -2
- package/dist/types/nextEntry.d.cts +0 -2
package/dist/cjs/lib/Lock.js
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _extractbaseiterator = /*#__PURE__*/ _interop_require_default(require("extract-base-iterator"));
|
|
12
|
+
var _lifecycle = /*#__PURE__*/ _interop_require_default(require("lifecycle"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
var _default = _lifecycle.default.RefCountable.extend({
|
|
5
19
|
constructor: function constructor() {
|
|
6
|
-
|
|
20
|
+
_lifecycle.default.RefCountable.prototype.constructor.call(this);
|
|
7
21
|
},
|
|
8
22
|
__destroy: function __destroy() {
|
|
9
23
|
if (this.iterator) {
|
|
10
|
-
|
|
24
|
+
_extractbaseiterator.default.prototype.end.call(this.iterator, this.err || null);
|
|
11
25
|
this.iterator = null;
|
|
12
26
|
}
|
|
13
27
|
}
|
|
14
28
|
});
|
|
15
|
-
|
|
16
|
-
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
17
|
-
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
18
|
-
for (var key in exports) exports.default[key] = exports[key];
|
|
19
|
-
module.exports = exports.default;
|
|
20
|
-
}
|
|
29
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { module.exports = exports.default; for (var key in exports) module.exports[key] = exports[key]; }
|
package/dist/cjs/lib/Lock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Lock.
|
|
1
|
+
{"version":3,"sources":["Lock.mjs"],"sourcesContent":["import BaseIterator from 'extract-base-iterator';\nimport LC from 'lifecycle';\n\nexport default LC.RefCountable.extend({\n constructor: function () {\n LC.RefCountable.prototype.constructor.call(this);\n },\n __destroy: function () {\n if (this.iterator) {\n BaseIterator.prototype.end.call(this.iterator, this.err || null);\n this.iterator = null;\n }\n },\n});\n"],"names":["LC","RefCountable","extend","constructor","prototype","call","__destroy","iterator","BaseIterator","end","err"],"mappings":";;;;+BAGA;;;eAAA;;;0EAHyB;gEACV;;;;;;IAEf,WAAeA,kBAAE,CAACC,YAAY,CAACC,MAAM,CAAC;IACpCC,aAAa,SAAbA;QACEH,kBAAE,CAACC,YAAY,CAACG,SAAS,CAACD,WAAW,CAACE,IAAI,CAAC,IAAI;IACjD;IACAC,WAAW,SAAXA;QACE,IAAI,IAAI,CAACC,QAAQ,EAAE;YACjBC,4BAAY,CAACJ,SAAS,CAACK,GAAG,CAACJ,IAAI,CAAC,IAAI,CAACE,QAAQ,EAAE,IAAI,CAACG,GAAG,IAAI;YAC3D,IAAI,CAACH,QAAQ,GAAG;QAClB;IACF;AACF"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return fifoRemove;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function fifoRemove(fifo, value) {
|
|
3
12
|
for(var node = fifo.node; node; node = fifo.next(node)){
|
|
4
13
|
if (node.value === value) {
|
|
5
14
|
fifo.remove(node);
|
|
@@ -7,10 +16,5 @@ module.exports = function fifoRemove(fifo, value) {
|
|
|
7
16
|
}
|
|
8
17
|
}
|
|
9
18
|
return false;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
13
|
-
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
14
|
-
for (var key in exports) exports.default[key] = exports[key];
|
|
15
|
-
module.exports = exports.default;
|
|
16
|
-
}
|
|
19
|
+
}
|
|
20
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { module.exports = exports.default; for (var key in exports) module.exports[key] = exports[key]; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["fifoRemove.
|
|
1
|
+
{"version":3,"sources":["fifoRemove.mjs"],"sourcesContent":["export default function fifoRemove(fifo, value) {\n for (let node = fifo.node; node; node = fifo.next(node)) {\n if (node.value === value) {\n fifo.remove(node);\n return true;\n }\n }\n return false;\n}\n"],"names":["fifoRemove","fifo","value","node","next","remove"],"mappings":";;;;+BAAA;;;eAAwBA;;;AAAT,SAASA,WAAWC,IAAI,EAAEC,KAAK;IAC5C,IAAK,IAAIC,OAAOF,KAAKE,IAAI,EAAEA,MAAMA,OAAOF,KAAKG,IAAI,CAACD,MAAO;QACvD,IAAIA,KAAKD,KAAK,KAAKA,OAAO;YACxBD,KAAKI,MAAM,CAACF;YACZ,OAAO;QACT;IACF;IACA,OAAO;AACT"}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return waitForAccess;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _fsaccesscompat = /*#__PURE__*/ _interop_require_default(require("fs-access-compat"));
|
|
12
|
+
function _interop_require_default(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
3
17
|
function waitForAccess(fullPath, callback) {
|
|
4
|
-
|
|
18
|
+
(0, _fsaccesscompat.default)(fullPath, function(err) {
|
|
5
19
|
if (err) return waitForAccess(fullPath, callback);
|
|
6
20
|
callback();
|
|
7
21
|
});
|
|
8
22
|
}
|
|
9
|
-
module.exports =
|
|
10
|
-
|
|
11
|
-
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
12
|
-
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
13
|
-
for (var key in exports) exports.default[key] = exports[key];
|
|
14
|
-
module.exports = exports.default;
|
|
15
|
-
}
|
|
23
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { module.exports = exports.default; for (var key in exports) module.exports[key] = exports[key]; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["waitForAccess.
|
|
1
|
+
{"version":3,"sources":["waitForAccess.mjs"],"sourcesContent":["import access from 'fs-access-compat';\n\nexport default function waitForAccess(fullPath, callback) {\n access(fullPath, (err) => {\n if (err) return waitForAccess(fullPath, callback);\n callback();\n });\n}\n"],"names":["waitForAccess","fullPath","callback","access","err"],"mappings":";;;;+BAEA;;;eAAwBA;;;qEAFL;;;;;;AAEJ,SAASA,cAAcC,QAAQ,EAAEC,QAAQ;IACtDC,IAAAA,uBAAM,EAACF,UAAU,SAACG;QAChB,IAAIA,KAAK,OAAOJ,cAAcC,UAAUC;QACxCA;IACF;AACF"}
|
package/dist/cjs/nextEntry.js
CHANGED
|
@@ -1,18 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return nextEntry;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
+
var _lodashcompact = /*#__PURE__*/ _interop_require_default(require("lodash.compact"));
|
|
13
|
+
var _once = /*#__PURE__*/ _interop_require_default(require("once"));
|
|
14
|
+
var _extractbaseiterator = require("extract-base-iterator");
|
|
15
|
+
var _FileEntry = /*#__PURE__*/ _interop_require_default(require("./FileEntry.js"));
|
|
16
|
+
function _define_property(obj, key, value) {
|
|
17
|
+
if (key in obj) {
|
|
18
|
+
Object.defineProperty(obj, key, {
|
|
19
|
+
value: value,
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
obj[key] = value;
|
|
26
|
+
}
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
29
|
+
function _interop_require_default(obj) {
|
|
30
|
+
return obj && obj.__esModule ? obj : {
|
|
31
|
+
default: obj
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function _object_spread(target) {
|
|
35
|
+
for(var i = 1; i < arguments.length; i++){
|
|
36
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
37
|
+
var ownKeys = Object.keys(source);
|
|
38
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
39
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
40
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
ownKeys.forEach(function(key) {
|
|
44
|
+
_define_property(target, key, source[key]);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return target;
|
|
48
|
+
}
|
|
11
49
|
function nextEntry(next, iterator, callback) {
|
|
12
50
|
var extract = iterator.extract;
|
|
13
51
|
if (!extract) return callback(new Error("Extract missing"));
|
|
14
52
|
var _callback = callback;
|
|
15
|
-
callback =
|
|
53
|
+
callback = (0, _once.default)(function callback(err, entry, next) {
|
|
16
54
|
extract.removeListener("entry", onEntry);
|
|
17
55
|
extract.removeListener("error", onError);
|
|
18
56
|
extract.removeListener("finish", onEnd);
|
|
@@ -25,23 +63,23 @@ function nextEntry(next, iterator, callback) {
|
|
|
25
63
|
var onEnd = callback.bind(null, null);
|
|
26
64
|
var onEntry = function onEntry(header, stream, next) {
|
|
27
65
|
if (iterator.done) return callback(null, null, next);
|
|
28
|
-
var attributes =
|
|
29
|
-
attributes.path =
|
|
66
|
+
var attributes = _object_spread({}, header);
|
|
67
|
+
attributes.path = (0, _lodashcompact.default)(header.name.split(_path.default.sep)).join(_path.default.sep);
|
|
30
68
|
attributes.mtime = new Date(attributes.mtime);
|
|
31
69
|
switch(attributes.type){
|
|
32
70
|
case "directory":
|
|
33
71
|
stream.resume(); // drain stream
|
|
34
|
-
return callback(null, new DirectoryEntry(attributes), next);
|
|
72
|
+
return callback(null, new _extractbaseiterator.DirectoryEntry(attributes), next);
|
|
35
73
|
case "symlink":
|
|
36
74
|
stream.resume(); // drain stream
|
|
37
75
|
attributes.linkpath = header.linkname;
|
|
38
|
-
return callback(null, new SymbolicLinkEntry(attributes), next);
|
|
76
|
+
return callback(null, new _extractbaseiterator.SymbolicLinkEntry(attributes), next);
|
|
39
77
|
case "link":
|
|
40
78
|
stream.resume(); // drain stream
|
|
41
79
|
attributes.linkpath = header.linkname;
|
|
42
|
-
return callback(null, new LinkEntry(attributes), next);
|
|
80
|
+
return callback(null, new _extractbaseiterator.LinkEntry(attributes), next);
|
|
43
81
|
case "file":
|
|
44
|
-
return callback(null, new
|
|
82
|
+
return callback(null, new _FileEntry.default(attributes, stream, iterator.lock), next);
|
|
45
83
|
}
|
|
46
84
|
stream.resume(); // drain stream
|
|
47
85
|
return callback(new Error("Unrecognized entry type: ".concat(attributes.type)), null, next);
|
|
@@ -51,10 +89,4 @@ function nextEntry(next, iterator, callback) {
|
|
|
51
89
|
extract.on("finish", onEnd);
|
|
52
90
|
if (next) next();
|
|
53
91
|
}
|
|
54
|
-
module.exports =
|
|
55
|
-
|
|
56
|
-
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
57
|
-
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
58
|
-
for (var key in exports) exports.default[key] = exports[key];
|
|
59
|
-
module.exports = exports.default;
|
|
60
|
-
}
|
|
92
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { module.exports = exports.default; for (var key in exports) module.exports[key] = exports[key]; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["nextEntry.
|
|
1
|
+
{"version":3,"sources":["nextEntry.mjs"],"sourcesContent":["import path from 'path';\nimport compact from 'lodash.compact';\nimport once from 'once';\n\nimport { DirectoryEntry, LinkEntry, SymbolicLinkEntry } from 'extract-base-iterator';\nimport FileEntry from './FileEntry.mjs';\n\nexport default function nextEntry(next, iterator, callback) {\n const extract = iterator.extract;\n if (!extract) return callback(new Error('Extract missing'));\n\n const _callback = callback;\n callback = once(function callback(err, entry, next) {\n extract.removeListener('entry', onEntry);\n extract.removeListener('error', onError);\n extract.removeListener('finish', onEnd);\n\n // keep processing\n if (entry) iterator.stack.push(nextEntry.bind(null, next));\n\n // use null to indicate iteration is complete\n _callback(err, err || !entry ? null : entry);\n });\n\n const onError = callback;\n const onEnd = callback.bind(null, null);\n const onEntry = function onEntry(header, stream, next) {\n if (iterator.done) return callback(null, null, next);\n\n const attributes = { ...header };\n attributes.path = compact(header.name.split(path.sep)).join(path.sep);\n attributes.mtime = new Date(attributes.mtime);\n\n switch (attributes.type) {\n case 'directory':\n stream.resume(); // drain stream\n return callback(null, new DirectoryEntry(attributes), next);\n case 'symlink':\n stream.resume(); // drain stream\n attributes.linkpath = header.linkname;\n return callback(null, new SymbolicLinkEntry(attributes), next);\n case 'link':\n stream.resume(); // drain stream\n attributes.linkpath = header.linkname;\n return callback(null, new LinkEntry(attributes), next);\n case 'file':\n return callback(null, new FileEntry(attributes, stream, iterator.lock), next);\n }\n\n stream.resume(); // drain stream\n return callback(new Error(`Unrecognized entry type: ${attributes.type}`), null, next);\n };\n\n extract.on('entry', onEntry);\n extract.on('error', onError);\n extract.on('finish', onEnd);\n if (next) next();\n}\n"],"names":["nextEntry","next","iterator","callback","extract","Error","_callback","once","err","entry","removeListener","onEntry","onError","onEnd","stack","push","bind","header","stream","done","attributes","path","compact","name","split","sep","join","mtime","Date","type","resume","DirectoryEntry","linkpath","linkname","SymbolicLinkEntry","LinkEntry","FileEntry","lock","on"],"mappings":";;;;+BAOA;;;eAAwBA;;;2DAPP;oEACG;2DACH;mCAE4C;gEACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEP,SAASA,UAAUC,IAAI,EAAEC,QAAQ,EAAEC,QAAQ;IACxD,IAAMC,UAAUF,SAASE,OAAO;IAChC,IAAI,CAACA,SAAS,OAAOD,SAAS,IAAIE,MAAM;IAExC,IAAMC,YAAYH;IAClBA,WAAWI,IAAAA,aAAI,EAAC,SAASJ,SAASK,GAAG,EAAEC,KAAK,EAAER,IAAI;QAChDG,QAAQM,cAAc,CAAC,SAASC;QAChCP,QAAQM,cAAc,CAAC,SAASE;QAChCR,QAAQM,cAAc,CAAC,UAAUG;QAEjC,kBAAkB;QAClB,IAAIJ,OAAOP,SAASY,KAAK,CAACC,IAAI,CAACf,UAAUgB,IAAI,CAAC,MAAMf;QAEpD,6CAA6C;QAC7CK,UAAUE,KAAKA,OAAO,CAACC,QAAQ,OAAOA;IACxC;IAEA,IAAMG,UAAUT;IAChB,IAAMU,QAAQV,SAASa,IAAI,CAAC,MAAM;IAClC,IAAML,UAAU,SAASA,QAA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4
|
+
import waitForAccess from './lib/waitForAccess.mjs';
|
|
5
|
+
let TarFileEntry = class TarFileEntry extends FileEntry {
|
|
6
|
+
create(dest, options, callback) {
|
|
7
|
+
if (typeof options === 'function') {
|
|
8
|
+
callback = options;
|
|
9
|
+
options = null;
|
|
10
|
+
}
|
|
11
|
+
const self = this;
|
|
12
|
+
if (typeof callback === 'function') {
|
|
13
|
+
options = options || {};
|
|
14
|
+
return FileEntry.prototype.create.call(this, dest, options, function createCallback(err) {
|
|
15
|
+
callback(err);
|
|
16
|
+
if (self.lock) {
|
|
17
|
+
self.lock.release();
|
|
18
|
+
self.lock = null;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return new Promise(function createPromise(resolve, reject) {
|
|
23
|
+
self.create(dest, options, function createCallback(err, done) {
|
|
24
|
+
err ? reject(err) : resolve(done);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
_writeFile(fullPath, _options, callback) {
|
|
29
|
+
if (!this.stream) return callback(new Error('Zip FileEntry missing stream. Check for calling create multiple times'));
|
|
30
|
+
const stream = this.stream;
|
|
31
|
+
this.stream = null;
|
|
32
|
+
try {
|
|
33
|
+
const res = stream.pipe(fs.createWriteStream(fullPath));
|
|
34
|
+
eos(res, (err)=>{
|
|
35
|
+
err ? callback(err) : waitForAccess(fullPath, callback); // gunzip stream returns prematurely occassionally
|
|
36
|
+
});
|
|
37
|
+
} catch (err) {
|
|
38
|
+
callback(err);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
destroy() {
|
|
42
|
+
FileEntry.prototype.destroy.call(this);
|
|
43
|
+
if (this.stream) {
|
|
44
|
+
this.stream.resume(); // drain stream
|
|
45
|
+
this.stream = null;
|
|
46
|
+
}
|
|
47
|
+
if (this.lock) {
|
|
48
|
+
this.lock.release();
|
|
49
|
+
this.lock = null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
constructor(attributes, stream, lock){
|
|
53
|
+
super(attributes);
|
|
54
|
+
this.stream = stream;
|
|
55
|
+
this.lock = lock;
|
|
56
|
+
this.lock.retain();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
export { TarFileEntry as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["FileEntry.mjs"],"sourcesContent":["import fs from 'fs';\nimport eos from 'end-of-stream';\nimport { FileEntry } from 'extract-base-iterator';\nimport waitForAccess from './lib/waitForAccess.mjs';\n\nexport default class TarFileEntry extends FileEntry {\n constructor(attributes, stream, lock) {\n super(attributes);\n this.stream = stream;\n this.lock = lock;\n this.lock.retain();\n }\n\n create(dest, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n\n const self = this;\n if (typeof callback === 'function') {\n options = options || {};\n return FileEntry.prototype.create.call(this, dest, options, function createCallback(err) {\n callback(err);\n if (self.lock) {\n self.lock.release();\n self.lock = null;\n }\n });\n }\n\n return new Promise(function createPromise(resolve, reject) {\n self.create(dest, options, function createCallback(err, done) {\n err ? reject(err) : resolve(done);\n });\n });\n }\n\n _writeFile(fullPath, _options, callback) {\n if (!this.stream) return callback(new Error('Zip FileEntry missing stream. Check for calling create multiple times'));\n\n const stream = this.stream;\n this.stream = null;\n try {\n const res = stream.pipe(fs.createWriteStream(fullPath));\n eos(res, (err) => {\n err ? callback(err) : waitForAccess(fullPath, callback); // gunzip stream returns prematurely occassionally\n });\n } catch (err) {\n callback(err);\n }\n }\n\n destroy() {\n FileEntry.prototype.destroy.call(this);\n if (this.stream) {\n this.stream.resume(); // drain stream\n this.stream = null;\n }\n if (this.lock) {\n this.lock.release();\n this.lock = null;\n }\n }\n}\n"],"names":["fs","eos","FileEntry","waitForAccess","TarFileEntry","create","dest","options","callback","self","prototype","call","createCallback","err","lock","release","Promise","createPromise","resolve","reject","done","_writeFile","fullPath","_options","stream","Error","res","pipe","createWriteStream","destroy","resume","constructor","attributes","retain"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;A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I;QACrC,IAAI,IAAI,CAACa,MAAM,EAAE;YACf,IAAI,CAACA,MAAM,CAACM,MAAM,IAAI,eAAe;YACrC,IAAI,CAACN,MAAM,GAAG;QAChB;QACA,IAAI,IAAI,CAACV,IAAI,EAAE;YACb,IAAI,CAACA,IAAI,CAACC,OAAO;YACjB,IAAI,CAACD,IAAI,GAAG;QACd;IACF;IAzDAiB,YAAYC,UAAU,EAAER,MAAM,EAAEV,IAAI,CAAE;QACpC,KAAK,CAACkB;QACN,IAAI,CAACR,MAAM,GAAGA;QACd,IAAI,CAACV,IAAI,GAAGA;QACZ,IAAI,CAACA,IAAI,CAACmB,MAAM;IAClB;AAqDF;AA3DA,SAAqB7B,0BA2DpB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import eos from 'end-of-stream';
|
|
3
|
+
import BaseIterator from 'extract-base-iterator';
|
|
4
|
+
import Queue from 'queue-cb';
|
|
5
|
+
import tarStream from 'tar-stream-compat';
|
|
6
|
+
import Lock from './lib/Lock.mjs';
|
|
7
|
+
import fifoRemove from './lib/fifoRemove.mjs';
|
|
8
|
+
import nextEntry from './nextEntry.mjs';
|
|
9
|
+
let TarIterator = class TarIterator extends BaseIterator {
|
|
10
|
+
end(err) {
|
|
11
|
+
if (this.lock) {
|
|
12
|
+
this.lock.err = err;
|
|
13
|
+
this.lock.release();
|
|
14
|
+
this.lock = null;
|
|
15
|
+
} else {
|
|
16
|
+
BaseIterator.prototype.end.call(this, err); // call in lock release so end is properly handled
|
|
17
|
+
}
|
|
18
|
+
this.extract = null;
|
|
19
|
+
}
|
|
20
|
+
constructor(source, options){
|
|
21
|
+
super(options);
|
|
22
|
+
this.lock = new Lock();
|
|
23
|
+
this.lock.iterator = this;
|
|
24
|
+
const queue = Queue(1);
|
|
25
|
+
let cancelled = false;
|
|
26
|
+
function setup() {
|
|
27
|
+
cancelled = true;
|
|
28
|
+
}
|
|
29
|
+
this.processing.push(setup);
|
|
30
|
+
this.extract = tarStream.extract();
|
|
31
|
+
queue.defer((callback)=>{
|
|
32
|
+
try {
|
|
33
|
+
if (typeof source === 'string') source = fs.createReadStream(source);
|
|
34
|
+
} catch (err) {
|
|
35
|
+
callback(err);
|
|
36
|
+
}
|
|
37
|
+
let data = null;
|
|
38
|
+
function cleanup() {
|
|
39
|
+
source.removeListener('error', onError);
|
|
40
|
+
source.removeListener('data', onData);
|
|
41
|
+
}
|
|
42
|
+
function onError(err) {
|
|
43
|
+
data = err;
|
|
44
|
+
cleanup();
|
|
45
|
+
callback(err);
|
|
46
|
+
}
|
|
47
|
+
function onData() {
|
|
48
|
+
data = true;
|
|
49
|
+
cleanup();
|
|
50
|
+
callback();
|
|
51
|
+
}
|
|
52
|
+
source.on('error', onError);
|
|
53
|
+
source.on('data', onData);
|
|
54
|
+
eos(source.pipe(this.extract), (err)=>{
|
|
55
|
+
if (data) return;
|
|
56
|
+
cleanup();
|
|
57
|
+
callback(err);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
// start processing
|
|
61
|
+
queue.await((err)=>{
|
|
62
|
+
fifoRemove(this.processing, setup);
|
|
63
|
+
if (this.done || cancelled) return; // done
|
|
64
|
+
err ? this.end(err) : this.push(nextEntry.bind(null, null));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export { TarIterator as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["TarIterator.mjs"],"sourcesContent":["import fs from 'fs';\nimport eos from 'end-of-stream';\nimport BaseIterator from 'extract-base-iterator';\nimport Queue from 'queue-cb';\nimport tarStream from 'tar-stream-compat';\n\nimport Lock from './lib/Lock.mjs';\nimport fifoRemove from './lib/fifoRemove.mjs';\nimport nextEntry from './nextEntry.mjs';\n\nexport default class TarIterator extends BaseIterator {\n constructor(source, options) {\n super(options);\n this.lock = new Lock();\n this.lock.iterator = this;\n\n const queue = Queue(1);\n let cancelled = false;\n function setup() {\n cancelled = true;\n }\n this.processing.push(setup);\n this.extract = tarStream.extract();\n\n queue.defer((callback) => {\n try {\n if (typeof source === 'string') source = fs.createReadStream(source);\n } catch (err) {\n callback(err);\n }\n\n let data = null;\n function cleanup() {\n source.removeListener('error', onError);\n source.removeListener('data', onData);\n }\n function onError(err) {\n data = err;\n cleanup();\n callback(err);\n }\n function onData() {\n data = true;\n cleanup();\n callback();\n }\n\n source.on('error', onError);\n source.on('data', onData);\n eos(source.pipe(this.extract), (err) => {\n if (data) return;\n cleanup();\n callback(err);\n });\n });\n\n // start processing\n queue.await((err) => {\n fifoRemove(this.processing, setup);\n if (this.done || cancelled) return; // done\n err ? this.end(err) : this.push(nextEntry.bind(null, null));\n });\n }\n\n end(err) {\n if (this.lock) {\n this.lock.err = err;\n this.lock.release();\n this.lock = null;\n } else {\n BaseIterator.prototype.end.call(this, err); // call in lock release so end is properly handled\n }\n this.extract = null;\n }\n}\n"],"names":["fs","eos","BaseIterator","Queue","tarStream","Lock","fifoRemove","nextEntry","TarIterator","end","err","lock","release","prototype","call","extract","constructor","source","options","iterator","queue","cancelled","setup","processing","push","defer","callback","createReadStream","data","cleanup","removeListener","onError","onData","on","pipe","await","done","bind"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,SAAS,gBAAgB;AAChC,OAAOC,kBAAkB,wBAAwB;AACjD,OAAOC,WAAW,WAAW;AAC7B,OAAOC,eAAe,oBAAoB;AAE1C,OAAOC,UAAU,iBAAiB;AAClC,OAAOC,gBAAgB,uBAAuB;AAC9C,OAAOC,eAAe,kBAAkB;AAEzB,IAAA,AAAMC,cAAN,MAAMA,oBAAoBN;IAsDvCO,IAAIC,GAAG,EAAE;QACP,IAAI,IAAI,CAACC,IAAI,EAAE;YACb,IAAI,CAACA,IAAI,CAACD,GAAG,GAAGA;YAChB,IAAI,CAACC,IAAI,CAACC,OAAO;YACjB,IAAI,CAACD,IAAI,GAAG;QACd,OAAO;YACLT,aAAaW,SAAS,CAACJ,GAAG,CAACK,IAAI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yBAgEpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.mjs"],"sourcesContent":["import TarIterator from './TarIterator.mjs';\nexport default TarIterator;\nexport { default as FileEntry } from './FileEntry.mjs';\nexport { DirectoryEntry, LinkEntry, SymbolicLinkEntry } from 'extract-base-iterator';\n"],"names":["TarIterator","default","FileEntry","DirectoryEntry","LinkEntry","SymbolicLinkEntry"],"mappings":"AAAA,OAAOA,iBAAiB,oBAAoB;AAC5C,eAAeA,YAAY;AAC3B,SAASC,WAAWC,SAAS,QAAQ,kBAAkB;AACvD,SAASC,cAAc,EAAEC,SAAS,EAAEC,iBAAiB,QAAQ,wBAAwB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseIterator from 'extract-base-iterator';
|
|
2
|
+
import LC from 'lifecycle';
|
|
3
|
+
export default LC.RefCountable.extend({
|
|
4
|
+
constructor: function() {
|
|
5
|
+
LC.RefCountable.prototype.constructor.call(this);
|
|
6
|
+
},
|
|
7
|
+
__destroy: function() {
|
|
8
|
+
if (this.iterator) {
|
|
9
|
+
BaseIterator.prototype.end.call(this.iterator, this.err || null);
|
|
10
|
+
this.iterator = null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Lock.mjs"],"sourcesContent":["import BaseIterator from 'extract-base-iterator';\nimport LC from 'lifecycle';\n\nexport default LC.RefCountable.extend({\n constructor: function () {\n LC.RefCountable.prototype.constructor.call(this);\n },\n __destroy: function () {\n if (this.iterator) {\n BaseIterator.prototype.end.call(this.iterator, this.err || null);\n this.iterator = null;\n }\n },\n});\n"],"names":["BaseIterator","LC","RefCountable","extend","constructor","prototype","call","__destroy","iterator","end","err"],"mappings":"AAAA,OAAOA,kBAAkB,wBAAwB;AACjD,OAAOC,QAAQ,YAAY;AAE3B,eAAeA,GAAGC,YAAY,CAACC,MAAM,CAAC;IACpCC,aAAa;QACXH,GAAGC,YAAY,CAACG,SAAS,CAACD,WAAW,CAACE,IAAI,CAAC,IAAI;IACjD;IACAC,WAAW;QACT,IAAI,IAAI,CAACC,QAAQ,EAAE;YACjBR,aAAaK,SAAS,CAACI,GAAG,CAACH,IAAI,CAAC,IAAI,CAACE,QAAQ,EAAE,IAAI,CAACE,GAAG,IAAI;YAC3D,IAAI,CAACF,QAAQ,GAAG;QAClB;IACF;AACF,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["fifoRemove.mjs"],"sourcesContent":["export default function fifoRemove(fifo, value) {\n for (let node = fifo.node; node; node = fifo.next(node)) {\n if (node.value === value) {\n fifo.remove(node);\n return true;\n }\n }\n return false;\n}\n"],"names":["fifoRemove","fifo","value","node","next","remove"],"mappings":"AAAA,eAAe,SAASA,WAAWC,IAAI,EAAEC,KAAK;IAC5C,IAAK,IAAIC,OAAOF,KAAKE,IAAI,EAAEA,MAAMA,OAAOF,KAAKG,IAAI,CAACD,MAAO;QACvD,IAAIA,KAAKD,KAAK,KAAKA,OAAO;YACxBD,KAAKI,MAAM,CAACF;YACZ,OAAO;QACT;IACF;IACA,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["waitForAccess.mjs"],"sourcesContent":["import access from 'fs-access-compat';\n\nexport default function waitForAccess(fullPath, callback) {\n access(fullPath, (err) => {\n if (err) return waitForAccess(fullPath, callback);\n callback();\n });\n}\n"],"names":["access","waitForAccess","fullPath","callback","err"],"mappings":"AAAA,OAAOA,YAAY,mBAAmB;AAEtC,eAAe,SAASC,cAAcC,QAAQ,EAAEC,QAAQ;IACtDH,OAAOE,UAAU,CAACE;QAChB,IAAIA,KAAK,OAAOH,cAAcC,UAAUC;QACxCA;IACF;AACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import compact from 'lodash.compact';
|
|
3
|
+
import once from 'once';
|
|
4
|
+
import { DirectoryEntry, LinkEntry, SymbolicLinkEntry } from 'extract-base-iterator';
|
|
5
|
+
import FileEntry from './FileEntry.mjs';
|
|
6
|
+
export default function nextEntry(next, iterator, callback) {
|
|
7
|
+
const extract = iterator.extract;
|
|
8
|
+
if (!extract) return callback(new Error('Extract missing'));
|
|
9
|
+
const _callback = callback;
|
|
10
|
+
callback = once(function callback(err, entry, next) {
|
|
11
|
+
extract.removeListener('entry', onEntry);
|
|
12
|
+
extract.removeListener('error', onError);
|
|
13
|
+
extract.removeListener('finish', onEnd);
|
|
14
|
+
// keep processing
|
|
15
|
+
if (entry) iterator.stack.push(nextEntry.bind(null, next));
|
|
16
|
+
// use null to indicate iteration is complete
|
|
17
|
+
_callback(err, err || !entry ? null : entry);
|
|
18
|
+
});
|
|
19
|
+
const onError = callback;
|
|
20
|
+
const onEnd = callback.bind(null, null);
|
|
21
|
+
const onEntry = function onEntry(header, stream, next) {
|
|
22
|
+
if (iterator.done) return callback(null, null, next);
|
|
23
|
+
const attributes = {
|
|
24
|
+
...header
|
|
25
|
+
};
|
|
26
|
+
attributes.path = compact(header.name.split(path.sep)).join(path.sep);
|
|
27
|
+
attributes.mtime = new Date(attributes.mtime);
|
|
28
|
+
switch(attributes.type){
|
|
29
|
+
case 'directory':
|
|
30
|
+
stream.resume(); // drain stream
|
|
31
|
+
return callback(null, new DirectoryEntry(attributes), next);
|
|
32
|
+
case 'symlink':
|
|
33
|
+
stream.resume(); // drain stream
|
|
34
|
+
attributes.linkpath = header.linkname;
|
|
35
|
+
return callback(null, new SymbolicLinkEntry(attributes), next);
|
|
36
|
+
case 'link':
|
|
37
|
+
stream.resume(); // drain stream
|
|
38
|
+
attributes.linkpath = header.linkname;
|
|
39
|
+
return callback(null, new LinkEntry(attributes), next);
|
|
40
|
+
case 'file':
|
|
41
|
+
return callback(null, new FileEntry(attributes, stream, iterator.lock), next);
|
|
42
|
+
}
|
|
43
|
+
stream.resume(); // drain stream
|
|
44
|
+
return callback(new Error(`Unrecognized entry type: ${attributes.type}`), null, next);
|
|
45
|
+
};
|
|
46
|
+
extract.on('entry', onEntry);
|
|
47
|
+
extract.on('error', onError);
|
|
48
|
+
extract.on('finish', onEnd);
|
|
49
|
+
if (next) next();
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["nextEntry.mjs"],"sourcesContent":["import path from 'path';\nimport compact from 'lodash.compact';\nimport once from 'once';\n\nimport { DirectoryEntry, LinkEntry, SymbolicLinkEntry } from 'extract-base-iterator';\nimport FileEntry from './FileEntry.mjs';\n\nexport default function nextEntry(next, iterator, callback) {\n const extract = iterator.extract;\n if (!extract) return callback(new Error('Extract missing'));\n\n const _callback = callback;\n callback = once(function callback(err, entry, next) {\n extract.removeListener('entry', onEntry);\n extract.removeListener('error', onError);\n extract.removeListener('finish', onEnd);\n\n // keep processing\n if (entry) iterator.stack.push(nextEntry.bind(null, next));\n\n // use null to indicate iteration is complete\n _callback(err, err || !entry ? null : entry);\n });\n\n const onError = callback;\n const onEnd = callback.bind(null, null);\n const onEntry = function onEntry(header, stream, next) {\n if (iterator.done) return callback(null, null, next);\n\n const attributes = { ...header };\n attributes.path = compact(header.name.split(path.sep)).join(path.sep);\n attributes.mtime = new Date(attributes.mtime);\n\n switch (attributes.type) {\n case 'directory':\n stream.resume(); // drain stream\n return callback(null, new DirectoryEntry(attributes), next);\n case 'symlink':\n stream.resume(); // drain stream\n attributes.linkpath = header.linkname;\n return callback(null, new SymbolicLinkEntry(attributes), next);\n case 'link':\n stream.resume(); // drain stream\n attributes.linkpath = header.linkname;\n return callback(null, new LinkEntry(attributes), next);\n case 'file':\n return callback(null, new FileEntry(attributes, stream, iterator.lock), next);\n }\n\n stream.resume(); // drain stream\n return callback(new Error(`Unrecognized entry type: ${attributes.type}`), null, next);\n };\n\n extract.on('entry', onEntry);\n extract.on('error', onError);\n extract.on('finish', onEnd);\n if (next) next();\n}\n"],"names":["path","compact","once","DirectoryEntry","LinkEntry","SymbolicLinkEntry","FileEntry","nextEntry","next","iterator","callback","extract","Error","_callback","err","entry","removeListener","onEntry","onError","onEnd","stack","push","bind","header","stream","done","attributes","name","split","sep","join","mtime","Date","type","resume","linkpath","linkname","lock","on"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,aAAa,iBAAiB;AACrC,OAAOC,UAAU,OAAO;AAExB,SAASC,cAAc,EAAEC,SAAS,EAAEC,iBAAiB,QAAQ,wBAAwB;AACrF,OAAOC,eAAe,kBAAkB;AAExC,eAAe,SAASC,UAAUC,IAAI,EAAEC,QAAQ,EAAEC,QAAQ;IACxD,MAAMC,UAAUF,SAASE,OAAO;IAChC,IAAI,CAACA,SAAS,OAAOD,SAAS,IAAIE,MAAM;IAExC,MAAMC,YAAYH;IAClBA,WAAWR,KAAK,SAASQ,SAASI,GAAG,EAAEC,KAAK,EAAEP,IAAI;QAChDG,QAAQK,cAAc,CAAC,SAASC;QAChCN,QAAQK,cAAc,CAAC,SAASE;QAChCP,QAAQK,cAAc,CAAC,UAAUG;QAEjC,kBAAkB;QAClB,IAAIJ,OAAON,SAASW,KAAK,CAACC,IAAI,CAACd,UAAUe,IAAI,CAAC,MAAMd;QAEpD,6CAA6C;QAC7CK,UAAUC,KAAKA,OAAO,CAACC,QAAQ,OAAOA;IACxC;IAEA,MAAMG,UAAUR;IAChB,MAAMS,QAAQT,SAASY,IAAI,CAAC,MAAM;IAClC,MAAML,UAAU,SAASA,QAAQM,MAAM,EAAEC,MAAM,EAAEhB,IAAI;QACnD,IAAIC,SAASgB,IAAI,EAAE,OAAOf,SAAS,MAAM,MAAMF;QAE/C,MAAMkB,aAAa;YAAE,GAAGH,MAAM;QAAC;QAC/BG,WAAW1B,IAAI,GAAGC,QAAQsB,OAAOI,IAAI,CAACC,KAAK,CAAC5B,KAAK6B,GAAG,GAAGC,IAAI,CAAC9B,KAAK6B,GAAG;QACpEH,WAAWK,KAAK,GAAG,IAAIC,KAAKN,WAAWK,KAAK;QAE5C,OAAQL,WAAWO,IAAI;YACrB,KAAK;gBACHT,OAAOU,MAAM,IAAI,eAAe;gBAChC,OAAOxB,SAAS,MAAM,IAAIP,eAAeuB,aAAalB;YACxD,KAAK;gBACHgB,OAAOU,MAAM,IAAI,eAAe;gBAChCR,WAAWS,QAAQ,GAAGZ,OAAOa,QAAQ;gBACrC,OAAO1B,SAAS,MAAM,IAAIL,kBAAkBqB,aAAalB;YAC3D,KAAK;gBACHgB,OAAOU,MAAM,IAAI,eAAe;gBAChCR,WAAWS,QAAQ,GAAGZ,OAAOa,QAAQ;gBACrC,OAAO1B,SAAS,MAAM,IAAIN,UAAUsB,aAAalB;YACnD,KAAK;gBACH,OAAOE,SAAS,MAAM,IAAIJ,UAAUoB,YAAYF,QAAQf,SAAS4B,IAAI,GAAG7B;QAC5E;QAEAgB,OAAOU,MAAM,IAAI,eAAe;QAChC,OAAOxB,SAAS,IAAIE,MAAM,CAAC,yBAAyB,EAAEc,WAAWO,IAAI,CAAC,CAAC,GAAG,MAAMzB;IAClF;IAEAG,QAAQ2B,EAAE,CAAC,SAASrB;IACpBN,QAAQ2B,EAAE,CAAC,SAASpB;IACpBP,QAAQ2B,EAAE,CAAC,UAAUnB;IACrB,IAAIX,MAAMA;AACZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
package/dist/types/index.d.mts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function fifoRemove(fifo: any, value: any): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function waitForAccess(fullPath: any, callback: any): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function nextEntry(next: any, iterator: any, callback: any): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tar-iterator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Extract contents from tar archive type using an iterator API using streams or paths. Use stream interface and pipe transforms to add decompression algorithms",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"extract",
|
|
@@ -38,7 +38,17 @@
|
|
|
38
38
|
},
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"author": "Kevin Malakoff <kmalakoff@gmail.com> (https://github.com/kmalakoff)",
|
|
41
|
+
"type": "module",
|
|
42
|
+
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"import": "./dist/esm/index.mjs",
|
|
45
|
+
"require": "./dist/cjs/index.js",
|
|
46
|
+
"types": "./dist/types/index.d.ts"
|
|
47
|
+
},
|
|
48
|
+
"./*": "./*"
|
|
49
|
+
},
|
|
41
50
|
"main": "dist/cjs/index.js",
|
|
51
|
+
"module": "dist/esm/index.mjs",
|
|
42
52
|
"types": "dist/types/index.d.ts",
|
|
43
53
|
"files": [
|
|
44
54
|
"dist"
|
|
@@ -53,9 +63,8 @@
|
|
|
53
63
|
},
|
|
54
64
|
"dependencies": {
|
|
55
65
|
"end-of-stream": "^1.4.4",
|
|
56
|
-
"extract-base-iterator": "^0.
|
|
66
|
+
"extract-base-iterator": "^1.0.0",
|
|
57
67
|
"fs-access-compat": "^1.0.3",
|
|
58
|
-
"inherits": "^2.0.4",
|
|
59
68
|
"just-extend": "^6.2.0",
|
|
60
69
|
"lifecycle": "^1.0.4",
|
|
61
70
|
"lodash.compact": "^3.0.1",
|
|
@@ -73,7 +82,7 @@
|
|
|
73
82
|
"depcheck": "^1.4.7",
|
|
74
83
|
"fs-iterator": "^4.2.0",
|
|
75
84
|
"fs-stats-spys": "^1.0.2",
|
|
76
|
-
"ts-dev-stack": "^0.
|
|
85
|
+
"ts-dev-stack": "^0.14.0",
|
|
77
86
|
"unbzip2-stream": "^1.4.3"
|
|
78
87
|
},
|
|
79
88
|
"engines": {
|
|
@@ -82,7 +91,8 @@
|
|
|
82
91
|
"tsds": {
|
|
83
92
|
"source": "src/index.mjs",
|
|
84
93
|
"targets": [
|
|
85
|
-
"cjs"
|
|
94
|
+
"cjs",
|
|
95
|
+
"esm"
|
|
86
96
|
]
|
|
87
97
|
}
|
|
88
98
|
}
|