tar-iterator
Version:
Extract contents from tar archive type using an iterator API using streams or paths. Use stream interface and pipe transforms to add decompression algorithms
48 lines • 1.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return Lock;
}
});
var _extractbaseiterator = /*#__PURE__*/ _interop_require_default(require("extract-base-iterator"));
function _class_call_check(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
var Lock = /*#__PURE__*/ function() {
"use strict";
function Lock() {
_class_call_check(this, Lock);
this.count = 1;
// members
this.iterator = null;
this.err = null;
}
var _proto = Lock.prototype;
_proto.retain = function retain() {
this.count++;
};
_proto.release = function release() {
if (this.count <= 0) throw new Error('Lock count is corrupted');
this.count--;
if (this.count === 0) this.__destroy();
};
_proto.__destroy = function __destroy() {
if (this.iterator) {
_extractbaseiterator.default.prototype.end.call(this.iterator, this.err || null);
this.iterator = null;
}
};
return Lock;
}();
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }