tar-iterator 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,10 @@ function _assert_this_initialized(self) {
18
18
  }
19
19
  return self;
20
20
  }
21
+ function _call_super(_this, derived, args) {
22
+ derived = _get_prototype_of(derived);
23
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
24
+ }
21
25
  function _class_call_check(instance, Constructor) {
22
26
  if (!(instance instanceof Constructor)) {
23
27
  throw new TypeError("Cannot call a class as a function");
@@ -79,37 +83,22 @@ function _type_of(obj) {
79
83
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
80
84
  }
81
85
  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
86
  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
- };
87
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
88
+ } catch (_) {}
89
+ return (_is_native_reflect_construct = function() {
90
+ return !!result;
91
+ })();
104
92
  }
105
93
  var TarFileEntry = /*#__PURE__*/ function(FileEntry) {
106
94
  "use strict";
107
95
  _inherits(TarFileEntry, FileEntry);
108
- var _super = _create_super(TarFileEntry);
109
96
  function TarFileEntry(attributes, stream, lock) {
110
97
  _class_call_check(this, TarFileEntry);
111
98
  var _this;
112
- _this = _super.call(this, attributes);
99
+ _this = _call_super(this, TarFileEntry, [
100
+ attributes
101
+ ]);
113
102
  _this.stream = stream;
114
103
  _this.lock = lock;
115
104
  _this.lock.retain();
@@ -119,12 +108,12 @@ var TarFileEntry = /*#__PURE__*/ function(FileEntry) {
119
108
  {
120
109
  key: "create",
121
110
  value: function create(dest, options, callback) {
122
- if (typeof options === "function") {
111
+ if (typeof options === 'function') {
123
112
  callback = options;
124
113
  options = null;
125
114
  }
126
115
  var self = this;
127
- if (typeof callback === "function") {
116
+ if (typeof callback === 'function') {
128
117
  options = options || {};
129
118
  return _extractbaseiterator.FileEntry.prototype.create.call(this, dest, options, function createCallback(err) {
130
119
  callback(err);
@@ -144,7 +133,7 @@ var TarFileEntry = /*#__PURE__*/ function(FileEntry) {
144
133
  {
145
134
  key: "_writeFile",
146
135
  value: function _writeFile(fullPath, _options, callback) {
147
- if (!this.stream) return callback(new Error("Zip FileEntry missing stream. Check for calling create multiple times"));
136
+ if (!this.stream) return callback(new Error('Zip FileEntry missing stream. Check for calling create multiple times'));
148
137
  var stream = this.stream;
149
138
  this.stream = null;
150
139
  try {
@@ -1 +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":["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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 '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,6BAAN;;cAAMA;aAAAA,aACPC,UAAU,EAAEC,MAAM,EAAEC,IAAI;gCADjBH;;gBAEjB,kBAFiBA;YAEXC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iB,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"}
@@ -22,6 +22,10 @@ function _assert_this_initialized(self) {
22
22
  }
23
23
  return self;
24
24
  }
25
+ function _call_super(_this, derived, args) {
26
+ derived = _get_prototype_of(derived);
27
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
28
+ }
25
29
  function _class_call_check(instance, Constructor) {
26
30
  if (!(instance instanceof Constructor)) {
27
31
  throw new TypeError("Cannot call a class as a function");
@@ -83,50 +87,35 @@ function _type_of(obj) {
83
87
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
84
88
  }
85
89
  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
90
  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
- };
91
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
92
+ } catch (_) {}
93
+ return (_is_native_reflect_construct = function() {
94
+ return !!result;
95
+ })();
108
96
  }
109
97
  var TarIterator = /*#__PURE__*/ function(BaseIterator) {
110
98
  "use strict";
111
99
  _inherits(TarIterator, BaseIterator);
112
- var _super = _create_super(TarIterator);
113
100
  function TarIterator(source, options) {
114
101
  _class_call_check(this, TarIterator);
115
102
  var _this;
116
103
  var setup = function setup() {
117
104
  cancelled = true;
118
105
  };
119
- _this = _super.call(this, options);
106
+ _this = _call_super(this, TarIterator, [
107
+ options
108
+ ]);
120
109
  _this.lock = new _Lock.default();
121
- _this.lock.iterator = _assert_this_initialized(_this);
110
+ _this.lock.iterator = _this;
122
111
  var queue = (0, _queuecb.default)(1);
123
112
  var cancelled = false;
124
113
  _this.processing.push(setup);
125
114
  _this.extract = _tarstreamcompat.default.extract();
126
115
  queue.defer(function(callback) {
127
116
  var cleanup = function cleanup() {
128
- source.removeListener("error", onError);
129
- source.removeListener("data", onData);
117
+ source.removeListener('error', onError);
118
+ source.removeListener('data', onData);
130
119
  };
131
120
  var onError = function onError(err) {
132
121
  data = err;
@@ -139,13 +128,13 @@ var TarIterator = /*#__PURE__*/ function(BaseIterator) {
139
128
  callback();
140
129
  };
141
130
  try {
142
- if (typeof source === "string") source = _fs.default.createReadStream(source);
131
+ if (typeof source === 'string') source = _fs.default.createReadStream(source);
143
132
  } catch (err) {
144
133
  callback(err);
145
134
  }
146
135
  var data = null;
147
- source.on("error", onError);
148
- source.on("data", onData);
136
+ source.on('error', onError);
137
+ source.on('data', onData);
149
138
  (0, _endofstream.default)(source.pipe(_this.extract), function(err) {
150
139
  if (data) return;
151
140
  cleanup();
@@ -1 +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":["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;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AGA;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"}
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,4BAAN;;cAAMA;aAAAA,YACPC,MAAM,EAAEC,OAAO;gCADRF;;YAQRG,QAAT,SAASA;YACPC,YAAY;QACd;gBARA,kBAFiBJ;YAEXE;;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"}
@@ -48,12 +48,12 @@ function _object_spread(target) {
48
48
  }
49
49
  function nextEntry(next, iterator, callback) {
50
50
  var extract = iterator.extract;
51
- if (!extract) return callback(new Error("Extract missing"));
51
+ if (!extract) return callback(new Error('Extract missing'));
52
52
  var _callback = callback;
53
53
  callback = (0, _once.default)(function callback(err, entry, next) {
54
- extract.removeListener("entry", onEntry);
55
- extract.removeListener("error", onError);
56
- extract.removeListener("finish", onEnd);
54
+ extract.removeListener('entry', onEntry);
55
+ extract.removeListener('error', onError);
56
+ extract.removeListener('finish', onEnd);
57
57
  // keep processing
58
58
  if (entry) iterator.stack.push(nextEntry.bind(null, next));
59
59
  // use null to indicate iteration is complete
@@ -67,26 +67,26 @@ function nextEntry(next, iterator, callback) {
67
67
  attributes.path = (0, _lodashcompact.default)(header.name.split(_path.default.sep)).join(_path.default.sep);
68
68
  attributes.mtime = new Date(attributes.mtime);
69
69
  switch(attributes.type){
70
- case "directory":
70
+ case 'directory':
71
71
  stream.resume(); // drain stream
72
72
  return callback(null, new _extractbaseiterator.DirectoryEntry(attributes), next);
73
- case "symlink":
73
+ case 'symlink':
74
74
  stream.resume(); // drain stream
75
75
  attributes.linkpath = header.linkname;
76
76
  return callback(null, new _extractbaseiterator.SymbolicLinkEntry(attributes), next);
77
- case "link":
77
+ case 'link':
78
78
  stream.resume(); // drain stream
79
79
  attributes.linkpath = header.linkname;
80
80
  return callback(null, new _extractbaseiterator.LinkEntry(attributes), next);
81
- case "file":
81
+ case 'file':
82
82
  return callback(null, new _FileEntry.default(attributes, stream, iterator.lock), next);
83
83
  }
84
84
  stream.resume(); // drain stream
85
85
  return callback(new Error("Unrecognized entry type: ".concat(attributes.type)), null, next);
86
86
  };
87
- extract.on("entry", onEntry);
88
- extract.on("error", onError);
89
- extract.on("finish", onEnd);
87
+ extract.on('entry', onEntry);
88
+ extract.on('error', onError);
89
+ extract.on('finish', onEnd);
90
90
  if (next) next();
91
91
  }
92
92
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
@@ -1 +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,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AASpB;IACpBP,QAAQ2B,EAAE,CAAC,UAAUnB;IACrB,IAAIX,MAAMA;AACZ"}
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","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AAK;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,EAAE,GAAG,MAAMzB;IAClF;IAEAG,QAAQ2B,EAAE,CAAC,SAASrB;IACpBN,QAAQ2B,EAAE,CAAC,SAASpB;IACpBP,QAAQ2B,EAAE,CAAC,UAAUnB;IACrB,IAAIX,MAAMA;AACZ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tar-iterator",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
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",
@@ -63,25 +63,25 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "end-of-stream": "^1.4.4",
66
- "extract-base-iterator": "^1.1.1",
66
+ "extract-base-iterator": "^1.1.2",
67
67
  "fs-access-compat": "^1.0.3",
68
68
  "lifecycle": "^1.0.4",
69
69
  "lodash.compact": "^3.0.1",
70
70
  "mkpath": "^1.0.0",
71
71
  "once": "^1.4.0",
72
72
  "queue-cb": "^1.2.1",
73
- "rimraf": "^2.7.1",
73
+ "rimraf2": "^2.7.1",
74
74
  "tar-stream-compat": "2.1.5"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@biomejs/biome": "^1.9.4",
78
78
  "@types/mocha": "^10.0.10",
79
- "@types/node": "^22.9.2",
79
+ "@types/node": "^22.10.1",
80
80
  "cr": "^0.1.0",
81
81
  "depcheck": "^1.4.7",
82
82
  "fs-iterator": "^5.1.0",
83
83
  "fs-stats-spys": "^1.0.2",
84
- "ts-dev-stack": "^0.15.8",
84
+ "ts-dev-stack": "^0.16.2",
85
85
  "unbzip2-stream": "^1.4.3"
86
86
  },
87
87
  "engines": {