tar-iterator 0.3.0 → 0.3.2
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 +36 -12
- 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.ts → FileEntry.d.mts} +1 -3
- package/dist/types/TarIterator.d.mts +6 -0
- package/dist/types/index.d.mts +3 -0
- 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 +16 -6
- package/dist/types/TarIterator.d.ts +0 -8
- package/dist/types/index.d.ts +0 -11
- package/dist/types/lib/Lock.d.ts +0 -2
- package/dist/types/lib/fifoRemove.d.ts +0 -2
- package/dist/types/lib/waitForAccess.d.ts +0 -2
- package/dist/types/nextEntry.d.ts +0 -2
package/dist/cjs/FileEntry.js
CHANGED
|
@@ -1,62 +1,177 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
this.stream = stream;
|
|
10
|
-
this.lock = lock;
|
|
11
|
-
this.lock.retain();
|
|
12
|
-
}
|
|
13
|
-
inherits(FileEntry, BaseIterator.FileEntry);
|
|
14
|
-
FileEntry.prototype.create = function create(dest, options, callback) {
|
|
15
|
-
if (typeof options === "function") {
|
|
16
|
-
callback = options;
|
|
17
|
-
options = null;
|
|
18
|
-
}
|
|
19
|
-
var self = this;
|
|
20
|
-
if (typeof callback === "function") {
|
|
21
|
-
options = options || {};
|
|
22
|
-
return BaseIterator.FileEntry.prototype.create.call(this, dest, options, function createCallback(err) {
|
|
23
|
-
callback(err);
|
|
24
|
-
if (self.lock) {
|
|
25
|
-
self.lock.release();
|
|
26
|
-
self.lock = null;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return TarFileEntry;
|
|
29
9
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
10
|
+
});
|
|
11
|
+
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
var _endofstream = /*#__PURE__*/ _interop_require_default(require("end-of-stream"));
|
|
13
|
+
var _extractbaseiterator = require("extract-base-iterator");
|
|
14
|
+
var _waitForAccess = /*#__PURE__*/ _interop_require_default(require("./lib/waitForAccess.js"));
|
|
15
|
+
function _assert_this_initialized(self) {
|
|
16
|
+
if (self === void 0) {
|
|
17
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
18
|
+
}
|
|
19
|
+
return self;
|
|
20
|
+
}
|
|
21
|
+
function _class_call_check(instance, Constructor) {
|
|
22
|
+
if (!(instance instanceof Constructor)) {
|
|
23
|
+
throw new TypeError("Cannot call a class as a function");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function _defineProperties(target, props) {
|
|
27
|
+
for(var i = 0; i < props.length; i++){
|
|
28
|
+
var descriptor = props[i];
|
|
29
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
30
|
+
descriptor.configurable = true;
|
|
31
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
32
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
36
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
37
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
38
|
+
return Constructor;
|
|
39
|
+
}
|
|
40
|
+
function _get_prototype_of(o) {
|
|
41
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
42
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
43
|
+
};
|
|
44
|
+
return _get_prototype_of(o);
|
|
45
|
+
}
|
|
46
|
+
function _inherits(subClass, superClass) {
|
|
47
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
48
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
49
|
+
}
|
|
50
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
51
|
+
constructor: {
|
|
52
|
+
value: subClass,
|
|
53
|
+
writable: true,
|
|
54
|
+
configurable: true
|
|
55
|
+
}
|
|
43
56
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
58
|
+
}
|
|
59
|
+
function _interop_require_default(obj) {
|
|
60
|
+
return obj && obj.__esModule ? obj : {
|
|
61
|
+
default: obj
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function _possible_constructor_return(self, call) {
|
|
65
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
66
|
+
return call;
|
|
67
|
+
}
|
|
68
|
+
return _assert_this_initialized(self);
|
|
69
|
+
}
|
|
70
|
+
function _set_prototype_of(o, p) {
|
|
71
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
72
|
+
o.__proto__ = p;
|
|
73
|
+
return o;
|
|
74
|
+
};
|
|
75
|
+
return _set_prototype_of(o, p);
|
|
76
|
+
}
|
|
77
|
+
function _type_of(obj) {
|
|
78
|
+
"@swc/helpers - typeof";
|
|
79
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
80
|
+
}
|
|
81
|
+
function _is_native_reflect_construct() {
|
|
82
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
83
|
+
if (Reflect.construct.sham) return false;
|
|
84
|
+
if (typeof Proxy === "function") return true;
|
|
85
|
+
try {
|
|
86
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
87
|
+
return true;
|
|
88
|
+
} catch (e) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function _create_super(Derived) {
|
|
93
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
94
|
+
return function _createSuperInternal() {
|
|
95
|
+
var Super = _get_prototype_of(Derived), result;
|
|
96
|
+
if (hasNativeReflectConstruct) {
|
|
97
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
98
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
99
|
+
} else {
|
|
100
|
+
result = Super.apply(this, arguments);
|
|
101
|
+
}
|
|
102
|
+
return _possible_constructor_return(this, result);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
var TarFileEntry = /*#__PURE__*/ function(FileEntry) {
|
|
106
|
+
"use strict";
|
|
107
|
+
_inherits(TarFileEntry, FileEntry);
|
|
108
|
+
var _super = _create_super(TarFileEntry);
|
|
109
|
+
function TarFileEntry(attributes, stream, lock) {
|
|
110
|
+
_class_call_check(this, TarFileEntry);
|
|
111
|
+
var _this;
|
|
112
|
+
_this = _super.call(this, attributes);
|
|
113
|
+
_this.stream = stream;
|
|
114
|
+
_this.lock = lock;
|
|
115
|
+
_this.lock.retain();
|
|
116
|
+
return _this;
|
|
117
|
+
}
|
|
118
|
+
_create_class(TarFileEntry, [
|
|
119
|
+
{
|
|
120
|
+
key: "create",
|
|
121
|
+
value: function create(dest, options, callback) {
|
|
122
|
+
if (typeof options === "function") {
|
|
123
|
+
callback = options;
|
|
124
|
+
options = null;
|
|
125
|
+
}
|
|
126
|
+
var self = this;
|
|
127
|
+
if (typeof callback === "function") {
|
|
128
|
+
options = options || {};
|
|
129
|
+
return _extractbaseiterator.FileEntry.prototype.create.call(this, dest, options, function createCallback(err) {
|
|
130
|
+
callback(err);
|
|
131
|
+
if (self.lock) {
|
|
132
|
+
self.lock.release();
|
|
133
|
+
self.lock = null;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return new Promise(function createPromise(resolve, reject) {
|
|
138
|
+
self.create(dest, options, function createCallback(err, done) {
|
|
139
|
+
err ? reject(err) : resolve(done);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
key: "_writeFile",
|
|
146
|
+
value: function _writeFile(fullPath, _options, callback) {
|
|
147
|
+
if (!this.stream) return callback(new Error("Zip FileEntry missing stream. Check for calling create multiple times"));
|
|
148
|
+
var stream = this.stream;
|
|
149
|
+
this.stream = null;
|
|
150
|
+
try {
|
|
151
|
+
var res = stream.pipe(_fs.default.createWriteStream(fullPath));
|
|
152
|
+
(0, _endofstream.default)(res, function(err) {
|
|
153
|
+
err ? callback(err) : (0, _waitForAccess.default)(fullPath, callback); // gunzip stream returns prematurely occassionally
|
|
154
|
+
});
|
|
155
|
+
} catch (err) {
|
|
156
|
+
callback(err);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
key: "destroy",
|
|
162
|
+
value: function destroy() {
|
|
163
|
+
_extractbaseiterator.FileEntry.prototype.destroy.call(this);
|
|
164
|
+
if (this.stream) {
|
|
165
|
+
this.stream.resume(); // drain stream
|
|
166
|
+
this.stream = null;
|
|
167
|
+
}
|
|
168
|
+
if (this.lock) {
|
|
169
|
+
this.lock.release();
|
|
170
|
+
this.lock = null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
]);
|
|
175
|
+
return TarFileEntry;
|
|
176
|
+
}(_extractbaseiterator.FileEntry);
|
|
177
|
+
/* 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":["FileEntry.
|
|
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":["TarFileEntry","attributes","stream","lock","retain","create","dest","options","callback","self","FileEntry","prototype","call","createCallback","err","release","Promise","createPromise","resolve","reject","done","_writeFile","fullPath","_options","Error","res","pipe","fs","createWriteStream","eos","waitForAccess","destroy","resume"],"mappings":";;;;;;;eAKqBA;;;yDALN;kEACC;mCACU;oEACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEX,IAAA,AAAMA,6BAAD,AAAL;;cAAMA;+BAAAA;aAAAA,aACPC,UAAU,EAAEC,MAAM,EAAEC,IAAI;gCADjBH;;kCAEXC;QACN,MAAKC,MAAM,GAAGA;QACd,MAAKC,IAAI,GAAGA;QACZ,MAAKA,IAAI,CAACC,MAAM;;;kBALCJ;;YAQnBK,KAAAA;mBAAAA,SAAAA,OAAOC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;gBAC5B,IAAI,OAAOD,YAAY,YAAY;oBACjCC,WAAWD;oBACXA,UAAU;gBACZ;gBAEA,IAAME,OAAO,IAAI;gBACjB,IAAI,OAAOD,aAAa,YAAY;oBAClCD,UAAUA,WAAW,CAAC;oBACtB,OAAOG,8BAAS,CAACC,SAAS,CAACN,MAAM,CAACO,IAAI,CAAC,IAAI,EAAEN,MAAMC,SAAS,SAASM,eAAeC,GAAG;wBACrFN,SAASM;wBACT,IAAIL,KAAKN,IAAI,EAAE;4BACbM,KAAKN,IAAI,CAACY,OAAO;4BACjBN,KAAKN,IAAI,GAAG;wBACd;oBACF;gBACF;gBAEA,OAAO,IAAIa,QAAQ,SAASC,cAAcC,OAAO,EAAEC,MAAM;oBACvDV,KAAKJ,MAAM,CAACC,MAAMC,SAAS,SAASM,eAAeC,GAAG,EAAEM,IAAI;wBAC1DN,MAAMK,OAAOL,OAAOI,QAAQE;oBAC9B;gBACF;YACF;;;YAEAC,KAAAA;mBAAAA,SAAAA,WAAWC,QAAQ,EAAEC,QAAQ,EAAEf,QAAQ;gBACrC,IAAI,CAAC,IAAI,CAACN,MAAM,EAAE,OAAOM,SAAS,IAAIgB,MAAM;gBAE5C,IAAMtB,SAAS,IAAI,CAACA,MAAM;gBAC1B,IAAI,CAACA,MAAM,GAAG;gBACd,IAAI;oBACF,IAAMuB,MAAMvB,OAAOwB,IAAI,CAACC,WAAE,CAACC,iBAAiB,CAACN;oBAC7CO,IAAAA,oBAAG,EAACJ,KAAK,SAACX;wBACRA,MAAMN,SAASM,OAAOgB,IAAAA,sBAAa,EAACR,UAAUd,WAAW,kDAAkD;oBAC7G;gBACF,EAAE,OAAOM,KAAK;oBACZN,SAASM;gBACX;YACF;;;YAEAiB,KAAAA;mBAAAA,SAAAA;gBACErB,8BAAS,CAACC,SAAS,CAACoB,OAAO,CAACnB,IAAI,CAAC,IAAI;gBACrC,IAAI,IAAI,CAACV,MAAM,EAAE;oBACf,IAAI,CAACA,MAAM,CAAC8B,MAAM,IAAI,eAAe;oBACrC,IAAI,CAAC9B,MAAM,GAAG;gBAChB;gBACA,IAAI,IAAI,CAACC,IAAI,EAAE;oBACb,IAAI,CAACA,IAAI,CAACY,OAAO;oBACjB,IAAI,CAACZ,IAAI,GAAG;gBACd;YACF;;;WA1DmBH;EAAqBU,8BAAS"}
|
package/dist/cjs/TarIterator.js
CHANGED
|
@@ -1,80 +1,180 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return TarIterator;
|
|
7
9
|
}
|
|
10
|
+
});
|
|
11
|
+
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
var _endofstream = /*#__PURE__*/ _interop_require_default(require("end-of-stream"));
|
|
13
|
+
var _extractbaseiterator = /*#__PURE__*/ _interop_require_default(require("extract-base-iterator"));
|
|
14
|
+
var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
|
|
15
|
+
var _tarstreamcompat = /*#__PURE__*/ _interop_require_default(require("tar-stream-compat"));
|
|
16
|
+
var _Lock = /*#__PURE__*/ _interop_require_default(require("./lib/Lock.js"));
|
|
17
|
+
var _fifoRemove = /*#__PURE__*/ _interop_require_default(require("./lib/fifoRemove.js"));
|
|
18
|
+
var _nextEntry = /*#__PURE__*/ _interop_require_default(require("./nextEntry.js"));
|
|
19
|
+
function _assert_this_initialized(self) {
|
|
20
|
+
if (self === void 0) {
|
|
21
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
22
|
+
}
|
|
23
|
+
return self;
|
|
8
24
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var eos = require("end-of-stream");
|
|
13
|
-
var Queue = require("queue-cb");
|
|
14
|
-
var BaseIterator = require("extract-base-iterator").default;
|
|
15
|
-
var nextEntry = require("./nextEntry");
|
|
16
|
-
var fifoRemove = require("./lib/fifoRemove");
|
|
17
|
-
var Lock = require("./lib/Lock");
|
|
18
|
-
function TarIterator(source, options) {
|
|
19
|
-
var _this = this;
|
|
20
|
-
if (!_instanceof(this, TarIterator)) return new TarIterator(source, options);
|
|
21
|
-
BaseIterator.call(this, options);
|
|
22
|
-
this.lock = new Lock();
|
|
23
|
-
this.lock.iterator = this;
|
|
24
|
-
var queue = Queue(1);
|
|
25
|
-
var cancelled = false;
|
|
26
|
-
function setup() {
|
|
27
|
-
cancelled = true;
|
|
25
|
+
function _class_call_check(instance, Constructor) {
|
|
26
|
+
if (!(instance instanceof Constructor)) {
|
|
27
|
+
throw new TypeError("Cannot call a class as a function");
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
err ? _this.end(err) : _this.push(nextEntry.bind(null, null));
|
|
29
|
+
}
|
|
30
|
+
function _defineProperties(target, props) {
|
|
31
|
+
for(var i = 0; i < props.length; i++){
|
|
32
|
+
var descriptor = props[i];
|
|
33
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
34
|
+
descriptor.configurable = true;
|
|
35
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
36
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
40
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
41
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
42
|
+
return Constructor;
|
|
43
|
+
}
|
|
44
|
+
function _get_prototype_of(o) {
|
|
45
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
46
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
47
|
+
};
|
|
48
|
+
return _get_prototype_of(o);
|
|
49
|
+
}
|
|
50
|
+
function _inherits(subClass, superClass) {
|
|
51
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
52
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
53
|
+
}
|
|
54
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
55
|
+
constructor: {
|
|
56
|
+
value: subClass,
|
|
57
|
+
writable: true,
|
|
58
|
+
configurable: true
|
|
59
|
+
}
|
|
61
60
|
});
|
|
61
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
function _interop_require_default(obj) {
|
|
64
|
+
return obj && obj.__esModule ? obj : {
|
|
65
|
+
default: obj
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function _possible_constructor_return(self, call) {
|
|
69
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
70
|
+
return call;
|
|
71
|
+
}
|
|
72
|
+
return _assert_this_initialized(self);
|
|
73
|
+
}
|
|
74
|
+
function _set_prototype_of(o, p) {
|
|
75
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
76
|
+
o.__proto__ = p;
|
|
77
|
+
return o;
|
|
78
|
+
};
|
|
79
|
+
return _set_prototype_of(o, p);
|
|
80
|
+
}
|
|
81
|
+
function _type_of(obj) {
|
|
82
|
+
"@swc/helpers - typeof";
|
|
83
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
84
|
+
}
|
|
85
|
+
function _is_native_reflect_construct() {
|
|
86
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
87
|
+
if (Reflect.construct.sham) return false;
|
|
88
|
+
if (typeof Proxy === "function") return true;
|
|
89
|
+
try {
|
|
90
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
91
|
+
return true;
|
|
92
|
+
} catch (e) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function _create_super(Derived) {
|
|
97
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
98
|
+
return function _createSuperInternal() {
|
|
99
|
+
var Super = _get_prototype_of(Derived), result;
|
|
100
|
+
if (hasNativeReflectConstruct) {
|
|
101
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
102
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
103
|
+
} else {
|
|
104
|
+
result = Super.apply(this, arguments);
|
|
105
|
+
}
|
|
106
|
+
return _possible_constructor_return(this, result);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
var TarIterator = /*#__PURE__*/ function(BaseIterator) {
|
|
110
|
+
"use strict";
|
|
111
|
+
_inherits(TarIterator, BaseIterator);
|
|
112
|
+
var _super = _create_super(TarIterator);
|
|
113
|
+
function TarIterator(source, options) {
|
|
114
|
+
_class_call_check(this, TarIterator);
|
|
115
|
+
var _this;
|
|
116
|
+
var setup = function setup() {
|
|
117
|
+
cancelled = true;
|
|
118
|
+
};
|
|
119
|
+
_this = _super.call(this, options);
|
|
120
|
+
_this.lock = new _Lock.default();
|
|
121
|
+
_this.lock.iterator = _assert_this_initialized(_this);
|
|
122
|
+
var queue = (0, _queuecb.default)(1);
|
|
123
|
+
var cancelled = false;
|
|
124
|
+
_this.processing.push(setup);
|
|
125
|
+
_this.extract = _tarstreamcompat.default.extract();
|
|
126
|
+
queue.defer(function(callback) {
|
|
127
|
+
var cleanup = function cleanup() {
|
|
128
|
+
source.removeListener("error", onError);
|
|
129
|
+
source.removeListener("data", onData);
|
|
130
|
+
};
|
|
131
|
+
var onError = function onError(err) {
|
|
132
|
+
data = err;
|
|
133
|
+
cleanup();
|
|
134
|
+
callback(err);
|
|
135
|
+
};
|
|
136
|
+
var onData = function onData() {
|
|
137
|
+
data = true;
|
|
138
|
+
cleanup();
|
|
139
|
+
callback();
|
|
140
|
+
};
|
|
141
|
+
try {
|
|
142
|
+
if (typeof source === "string") source = _fs.default.createReadStream(source);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
callback(err);
|
|
145
|
+
}
|
|
146
|
+
var data = null;
|
|
147
|
+
source.on("error", onError);
|
|
148
|
+
source.on("data", onData);
|
|
149
|
+
(0, _endofstream.default)(source.pipe(_this.extract), function(err) {
|
|
150
|
+
if (data) return;
|
|
151
|
+
cleanup();
|
|
152
|
+
callback(err);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
// start processing
|
|
156
|
+
queue.await(function(err) {
|
|
157
|
+
(0, _fifoRemove.default)(_this.processing, setup);
|
|
158
|
+
if (_this.done || cancelled) return; // done
|
|
159
|
+
err ? _this.end(err) : _this.push(_nextEntry.default.bind(null, null));
|
|
160
|
+
});
|
|
161
|
+
return _this;
|
|
71
162
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
163
|
+
_create_class(TarIterator, [
|
|
164
|
+
{
|
|
165
|
+
key: "end",
|
|
166
|
+
value: function end(err) {
|
|
167
|
+
if (this.lock) {
|
|
168
|
+
this.lock.err = err;
|
|
169
|
+
this.lock.release();
|
|
170
|
+
this.lock = null;
|
|
171
|
+
} else {
|
|
172
|
+
_extractbaseiterator.default.prototype.end.call(this, err); // call in lock release so end is properly handled
|
|
173
|
+
}
|
|
174
|
+
this.extract = null;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
]);
|
|
178
|
+
return TarIterator;
|
|
179
|
+
}(_extractbaseiterator.default);
|
|
180
|
+
/* 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":["TarIterator.
|
|
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":["TarIterator","source","options","setup","cancelled","lock","Lock","iterator","queue","Queue","processing","push","extract","tarStream","defer","callback","cleanup","removeListener","onError","onData","err","data","fs","createReadStream","on","eos","pipe","await","fifoRemove","done","end","nextEntry","bind","release","BaseIterator","prototype","call"],"mappings":";;;;;;;eAUqBA;;;yDAVN;kEACC;0EACS;8DACP;sEACI;2DAEL;iEACM;gEACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEP,IAAA,AAAMA,4BAAD,AAAL;;cAAMA;+BAAAA;aAAAA,YACPC,MAAM,EAAEC,OAAO;gCADRF;;YAQRG,QAAT,SAASA;YACPC,YAAY;QACd;kCARMF;QACN,MAAKG,IAAI,GAAG,IAAIC,aAAI;QACpB,MAAKD,IAAI,CAACE,QAAQ;QAElB,IAAMC,QAAQC,IAAAA,gBAAK,EAAC;QACpB,IAAIL,YAAY;QAIhB,MAAKM,UAAU,CAACC,IAAI,CAACR;QACrB,MAAKS,OAAO,GAAGC,wBAAS,CAACD,OAAO;QAEhCJ,MAAMM,KAAK,CAAC,SAACC;gBAQFC,UAAT,SAASA;gBACPf,OAAOgB,cAAc,CAAC,SAASC;gBAC/BjB,OAAOgB,cAAc,CAAC,QAAQE;YAChC;gBACSD,UAAT,SAASA,QAAQE,GAAG;gBAClBC,OAAOD;gBACPJ;gBACAD,SAASK;YACX;gBACSD,SAAT,SAASA;gBACPE,OAAO;gBACPL;gBACAD;YACF;YApBA,IAAI;gBACF,IAAI,OAAOd,WAAW,UAAUA,SAASqB,WAAE,CAACC,gBAAgB,CAACtB;YAC/D,EAAE,OAAOmB,KAAK;gBACZL,SAASK;YACX;YAEA,IAAIC,OAAO;YAgBXpB,OAAOuB,EAAE,CAAC,SAASN;YACnBjB,OAAOuB,EAAE,CAAC,QAAQL;YAClBM,IAAAA,oBAAG,EAACxB,OAAOyB,IAAI,CAAC,MAAKd,OAAO,GAAG,SAACQ;gBAC9B,IAAIC,MAAM;gBACVL;gBACAD,SAASK;YACX;QACF;QAEA,mBAAmB;QACnBZ,MAAMmB,KAAK,CAAC,SAACP;YACXQ,IAAAA,mBAAU,EAAC,MAAKlB,UAAU,EAAEP;YAC5B,IAAI,MAAK0B,IAAI,IAAIzB,WAAW,QAAQ,OAAO;YAC3CgB,MAAM,MAAKU,GAAG,CAACV,OAAO,MAAKT,IAAI,CAACoB,kBAAS,CAACC,IAAI,CAAC,MAAM;QACvD;;;kBAnDiBhC;;YAsDnB8B,KAAAA;mBAAAA,SAAAA,IAAIV,GAAG;gBACL,IAAI,IAAI,CAACf,IAAI,EAAE;oBACb,IAAI,CAACA,IAAI,CAACe,GAAG,GAAGA;oBAChB,IAAI,CAACf,IAAI,CAAC4B,OAAO;oBACjB,IAAI,CAAC5B,IAAI,GAAG;gBACd,OAAO;oBACL6B,4BAAY,CAACC,SAAS,CAACL,GAAG,CAACM,IAAI,CAAC,IAAI,EAAEhB,MAAM,kDAAkD;gBAChG;gBACA,IAAI,CAACR,OAAO,GAAG;YACjB;;;WA/DmBZ;EAAoBkC,4BAAY"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
DirectoryEntry: function() {
|
|
13
|
+
return _extractbaseiterator.DirectoryEntry;
|
|
14
|
+
},
|
|
15
|
+
FileEntry: function() {
|
|
16
|
+
return _FileEntry.default;
|
|
17
|
+
},
|
|
18
|
+
LinkEntry: function() {
|
|
19
|
+
return _extractbaseiterator.LinkEntry;
|
|
20
|
+
},
|
|
21
|
+
SymbolicLinkEntry: function() {
|
|
22
|
+
return _extractbaseiterator.SymbolicLinkEntry;
|
|
23
|
+
},
|
|
24
|
+
default: function() {
|
|
25
|
+
return _default;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
var _TarIterator = /*#__PURE__*/ _interop_require_default(require("./TarIterator.js"));
|
|
29
|
+
var _FileEntry = /*#__PURE__*/ _interop_require_default(require("./FileEntry.js"));
|
|
30
|
+
var _extractbaseiterator = require("extract-base-iterator");
|
|
31
|
+
function _interop_require_default(obj) {
|
|
32
|
+
return obj && obj.__esModule ? obj : {
|
|
33
|
+
default: obj
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
var _default = _TarIterator.default;
|
|
37
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { module.exports = exports.default; for (var key in exports) module.exports[key] = exports[key]; }
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.
|
|
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":["DirectoryEntry","FileEntry","LinkEntry","SymbolicLinkEntry","TarIterator"],"mappings":";;;;;;;;;;;IAGSA,cAAc;eAAdA,mCAAc;;IADHC,SAAS;eAATA,kBAAS;;IACJC,SAAS;eAATA,8BAAS;;IAAEC,iBAAiB;eAAjBA,sCAAiB;;IAFrD,OAA2B;eAA3B;;;kEADwB;gEAEa;mCACwB;;;;;;IAF7D,WAAeC,oBAAW"}
|