UNPKG

2.02 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.Zip = void 0;
4var tslib_1 = require("tslib");
5var RangeStream_1 = require("../stream/RangeStream");
6var Zip = (function () {
7 function Zip() {
8 }
9 Zip.prototype.entryStreamRangePromise = function (entryPath, begin, end) {
10 return tslib_1.__awaiter(this, void 0, void 0, function () {
11 var streamAndLength, err_1, b, e, stream, sal;
12 var _this = this;
13 return tslib_1.__generator(this, function (_a) {
14 switch (_a.label) {
15 case 0:
16 _a.trys.push([0, 2, , 3]);
17 return [4, this.entryStreamPromise(entryPath)];
18 case 1:
19 streamAndLength = _a.sent();
20 return [3, 3];
21 case 2:
22 err_1 = _a.sent();
23 console.log(err_1);
24 return [2, Promise.reject(err_1)];
25 case 3:
26 b = begin < 0 ? 0 : begin;
27 e = end < 0 ? (streamAndLength.length - 1) : end;
28 stream = new RangeStream_1.RangeStream(b, e, streamAndLength.length);
29 streamAndLength.stream.pipe(stream);
30 sal = {
31 length: streamAndLength.length,
32 reset: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
33 return tslib_1.__generator(this, function (_a) {
34 return [2, this.entryStreamRangePromise(entryPath, begin, end)];
35 });
36 }); },
37 stream: stream,
38 };
39 return [2, sal];
40 }
41 });
42 });
43 };
44 return Zip;
45}());
46exports.Zip = Zip;
47//# sourceMappingURL=zip.js.map
\No newline at end of file