@gmod/cram 4.0.9 → 5.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/README.md +6 -6
- package/dist/craiIndex.d.ts +1 -1
- package/dist/craiIndex.js +7 -7
- package/dist/craiIndex.js.map +1 -1
- package/dist/cram-bundle.js +1 -2
- package/dist/cramFile/codecs/_base.d.ts +3 -3
- package/dist/cramFile/codecs/beta.d.ts +5 -5
- package/dist/cramFile/codecs/beta.js +7 -7
- package/dist/cramFile/codecs/beta.js.map +1 -1
- package/dist/cramFile/codecs/byteArrayLength.d.ts +5 -5
- package/dist/cramFile/codecs/byteArrayLength.js +4 -4
- package/dist/cramFile/codecs/byteArrayLength.js.map +1 -1
- package/dist/cramFile/codecs/byteArrayStop.d.ts +5 -5
- package/dist/cramFile/codecs/byteArrayStop.js +7 -7
- package/dist/cramFile/codecs/byteArrayStop.js.map +1 -1
- package/dist/cramFile/codecs/dataSeriesTypes.d.ts +1 -1
- package/dist/cramFile/codecs/external.d.ts +5 -5
- package/dist/cramFile/codecs/external.js +12 -11
- package/dist/cramFile/codecs/external.js.map +1 -1
- package/dist/cramFile/codecs/gamma.d.ts +5 -5
- package/dist/cramFile/codecs/gamma.js +8 -8
- package/dist/cramFile/codecs/gamma.js.map +1 -1
- package/dist/cramFile/codecs/huffman.d.ts +6 -6
- package/dist/cramFile/codecs/huffman.js +9 -9
- package/dist/cramFile/codecs/huffman.js.map +1 -1
- package/dist/cramFile/codecs/index.d.ts +3 -3
- package/dist/cramFile/codecs/index.js +16 -16
- package/dist/cramFile/codecs/index.js.map +1 -1
- package/dist/cramFile/codecs/subexp.d.ts +5 -5
- package/dist/cramFile/codecs/subexp.js +9 -9
- package/dist/cramFile/codecs/subexp.js.map +1 -1
- package/dist/cramFile/container/compressionScheme.d.ts +4 -4
- package/dist/cramFile/container/compressionScheme.js +5 -5
- package/dist/cramFile/container/compressionScheme.js.map +1 -1
- package/dist/cramFile/container/index.d.ts +8 -8
- package/dist/cramFile/container/index.js +15 -16
- package/dist/cramFile/container/index.js.map +1 -1
- package/dist/cramFile/file.d.ts +3 -3
- package/dist/cramFile/file.js +29 -38
- package/dist/cramFile/file.js.map +1 -1
- package/dist/cramFile/index.d.ts +2 -2
- package/dist/cramFile/index.js +4 -4
- package/dist/cramFile/index.js.map +1 -1
- package/dist/cramFile/record.d.ts +2 -2
- package/dist/cramFile/record.js +17 -17
- package/dist/cramFile/record.js.map +1 -1
- package/dist/cramFile/sectionParsers.d.ts +3 -3
- package/dist/cramFile/sectionParsers.js +56 -56
- package/dist/cramFile/sectionParsers.js.map +1 -1
- package/dist/cramFile/slice/decodeRecord.d.ts +6 -6
- package/dist/cramFile/slice/decodeRecord.js +17 -17
- package/dist/cramFile/slice/decodeRecord.js.map +1 -1
- package/dist/cramFile/slice/index.d.ts +5 -5
- package/dist/cramFile/slice/index.js +46 -52
- package/dist/cramFile/slice/index.js.map +1 -1
- package/dist/htscodecs/arith_gen.d.ts +1 -1
- package/dist/htscodecs/arith_gen.js +17 -17
- package/dist/htscodecs/arith_gen.js.map +1 -1
- package/dist/htscodecs/fqzcomp.js +10 -10
- package/dist/htscodecs/fqzcomp.js.map +1 -1
- package/dist/htscodecs/index.js +6 -6
- package/dist/htscodecs/index.js.map +1 -1
- package/dist/htscodecs/rans.js +2 -2
- package/dist/htscodecs/rans.js.map +1 -1
- package/dist/htscodecs/rans4x16.js +7 -7
- package/dist/htscodecs/rans4x16.js.map +1 -1
- package/dist/htscodecs/tok3.js +9 -9
- package/dist/htscodecs/tok3.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/indexedCramFile.d.ts +4 -4
- package/dist/indexedCramFile.js +5 -5
- package/dist/indexedCramFile.js.map +1 -1
- package/dist/{io/index.js → io.js} +1 -1
- package/dist/io.js.map +1 -0
- package/dist/rans/d04.js +28 -28
- package/dist/rans/d04.js.map +1 -1
- package/dist/rans/d14.js +16 -16
- package/dist/rans/d14.js.map +1 -1
- package/dist/rans/decoding.js +8 -8
- package/dist/rans/decoding.js.map +1 -1
- package/dist/rans/frequencies.js +15 -15
- package/dist/rans/frequencies.js.map +1 -1
- package/dist/rans/index.js +17 -17
- package/dist/rans/index.js.map +1 -1
- package/dist/seek-bzip/bitreader.d.ts +27 -0
- package/dist/seek-bzip/bitreader.js +101 -0
- package/dist/seek-bzip/bitreader.js.map +1 -0
- package/dist/seek-bzip/crc32.d.ts +0 -0
- package/dist/seek-bzip/crc32.js +113 -0
- package/dist/seek-bzip/crc32.js.map +1 -0
- package/dist/seek-bzip/index.d.ts +9 -0
- package/dist/seek-bzip/index.js +585 -0
- package/dist/seek-bzip/index.js.map +1 -0
- package/dist/seek-bzip/stream.d.ts +1 -0
- package/dist/seek-bzip/stream.js +41 -0
- package/dist/seek-bzip/stream.js.map +1 -0
- package/dist/seek-bzip/toHex.d.ts +1 -0
- package/dist/seek-bzip/toHex.js +36 -0
- package/dist/seek-bzip/toHex.js.map +1 -0
- package/esm/craiIndex.d.ts +1 -1
- package/esm/craiIndex.js +3 -3
- package/esm/craiIndex.js.map +1 -1
- package/esm/cramFile/codecs/_base.d.ts +3 -3
- package/esm/cramFile/codecs/beta.d.ts +5 -5
- package/esm/cramFile/codecs/beta.js +4 -4
- package/esm/cramFile/codecs/beta.js.map +1 -1
- package/esm/cramFile/codecs/byteArrayLength.d.ts +5 -5
- package/esm/cramFile/codecs/byteArrayLength.js +2 -2
- package/esm/cramFile/codecs/byteArrayLength.js.map +1 -1
- package/esm/cramFile/codecs/byteArrayStop.d.ts +5 -5
- package/esm/cramFile/codecs/byteArrayStop.js +4 -4
- package/esm/cramFile/codecs/byteArrayStop.js.map +1 -1
- package/esm/cramFile/codecs/dataSeriesTypes.d.ts +1 -1
- package/esm/cramFile/codecs/external.d.ts +5 -5
- package/esm/cramFile/codecs/external.js +8 -7
- package/esm/cramFile/codecs/external.js.map +1 -1
- package/esm/cramFile/codecs/gamma.d.ts +5 -5
- package/esm/cramFile/codecs/gamma.js +4 -4
- package/esm/cramFile/codecs/gamma.js.map +1 -1
- package/esm/cramFile/codecs/huffman.d.ts +6 -6
- package/esm/cramFile/codecs/huffman.js +5 -5
- package/esm/cramFile/codecs/huffman.js.map +1 -1
- package/esm/cramFile/codecs/index.d.ts +3 -3
- package/esm/cramFile/codecs/index.js +8 -8
- package/esm/cramFile/codecs/index.js.map +1 -1
- package/esm/cramFile/codecs/subexp.d.ts +5 -5
- package/esm/cramFile/codecs/subexp.js +4 -4
- package/esm/cramFile/codecs/subexp.js.map +1 -1
- package/esm/cramFile/container/compressionScheme.d.ts +4 -4
- package/esm/cramFile/container/compressionScheme.js +2 -2
- package/esm/cramFile/container/compressionScheme.js.map +1 -1
- package/esm/cramFile/container/index.d.ts +8 -8
- package/esm/cramFile/container/index.js +5 -6
- package/esm/cramFile/container/index.js.map +1 -1
- package/esm/cramFile/file.d.ts +3 -3
- package/esm/cramFile/file.js +12 -21
- package/esm/cramFile/file.js.map +1 -1
- package/esm/cramFile/index.d.ts +2 -2
- package/esm/cramFile/index.js +2 -2
- package/esm/cramFile/index.js.map +1 -1
- package/esm/cramFile/record.d.ts +2 -2
- package/esm/cramFile/record.js +1 -1
- package/esm/cramFile/record.js.map +1 -1
- package/esm/cramFile/sectionParsers.d.ts +3 -3
- package/esm/cramFile/sectionParsers.js +1 -1
- package/esm/cramFile/sectionParsers.js.map +1 -1
- package/esm/cramFile/slice/decodeRecord.d.ts +6 -6
- package/esm/cramFile/slice/decodeRecord.js +3 -3
- package/esm/cramFile/slice/decodeRecord.js.map +1 -1
- package/esm/cramFile/slice/index.d.ts +5 -5
- package/esm/cramFile/slice/index.js +18 -24
- package/esm/cramFile/slice/index.js.map +1 -1
- package/esm/htscodecs/arith_gen.d.ts +1 -1
- package/esm/htscodecs/arith_gen.js +5 -5
- package/esm/htscodecs/arith_gen.js.map +1 -1
- package/esm/htscodecs/fqzcomp.js +3 -3
- package/esm/htscodecs/fqzcomp.js.map +1 -1
- package/esm/htscodecs/index.js +5 -5
- package/esm/htscodecs/index.js.map +1 -1
- package/esm/htscodecs/rans.js +1 -1
- package/esm/htscodecs/rans.js.map +1 -1
- package/esm/htscodecs/rans4x16.js +1 -1
- package/esm/htscodecs/rans4x16.js.map +1 -1
- package/esm/htscodecs/tok3.js +4 -4
- package/esm/htscodecs/tok3.js.map +1 -1
- package/esm/index.d.ts +3 -3
- package/esm/index.js +3 -3
- package/esm/index.js.map +1 -1
- package/esm/indexedCramFile.d.ts +4 -4
- package/esm/indexedCramFile.js +2 -2
- package/esm/indexedCramFile.js.map +1 -1
- package/esm/{io/index.js → io.js} +1 -1
- package/esm/io.js.map +1 -0
- package/esm/rans/d04.js +3 -3
- package/esm/rans/d04.js.map +1 -1
- package/esm/rans/d14.js +2 -2
- package/esm/rans/d14.js.map +1 -1
- package/esm/rans/decoding.js +2 -2
- package/esm/rans/decoding.js.map +1 -1
- package/esm/rans/frequencies.js +3 -3
- package/esm/rans/frequencies.js.map +1 -1
- package/esm/rans/index.js +5 -5
- package/esm/rans/index.js.map +1 -1
- package/esm/seek-bzip/bitreader.d.ts +27 -0
- package/esm/seek-bzip/bitreader.js +98 -0
- package/esm/seek-bzip/bitreader.js.map +1 -0
- package/esm/seek-bzip/crc32.d.ts +0 -0
- package/esm/seek-bzip/crc32.js +113 -0
- package/esm/seek-bzip/crc32.js.map +1 -0
- package/esm/seek-bzip/index.d.ts +9 -0
- package/esm/seek-bzip/index.js +579 -0
- package/esm/seek-bzip/index.js.map +1 -0
- package/esm/seek-bzip/stream.d.ts +1 -0
- package/esm/seek-bzip/stream.js +41 -0
- package/esm/seek-bzip/stream.js.map +1 -0
- package/esm/seek-bzip/toHex.d.ts +1 -0
- package/esm/seek-bzip/toHex.js +33 -0
- package/esm/seek-bzip/toHex.js.map +1 -0
- package/package.json +15 -10
- package/src/craiIndex.ts +4 -4
- package/src/cramFile/codecs/_base.ts +3 -3
- package/src/cramFile/codecs/beta.ts +8 -8
- package/src/cramFile/codecs/byteArrayLength.ts +6 -6
- package/src/cramFile/codecs/byteArrayStop.ts +8 -8
- package/src/cramFile/codecs/dataSeriesTypes.ts +1 -1
- package/src/cramFile/codecs/external.ts +15 -12
- package/src/cramFile/codecs/gamma.ts +8 -8
- package/src/cramFile/codecs/huffman.ts +8 -8
- package/src/cramFile/codecs/index.ts +11 -11
- package/src/cramFile/codecs/subexp.ts +8 -8
- package/src/cramFile/container/compressionScheme.ts +6 -6
- package/src/cramFile/container/index.ts +6 -7
- package/src/cramFile/file.ts +13 -24
- package/src/cramFile/index.ts +2 -2
- package/src/cramFile/record.ts +3 -3
- package/src/cramFile/sectionParsers.ts +4 -4
- package/src/cramFile/slice/decodeRecord.ts +8 -8
- package/src/cramFile/slice/index.ts +23 -29
- package/src/htscodecs/arith_gen.ts +6 -6
- package/src/htscodecs/fqzcomp.ts +3 -3
- package/src/htscodecs/index.ts +5 -5
- package/src/htscodecs/rans.ts +1 -1
- package/src/htscodecs/rans4x16.ts +1 -1
- package/src/htscodecs/tok3.ts +4 -4
- package/src/index.ts +3 -3
- package/src/indexedCramFile.ts +5 -5
- package/src/rans/d04.ts +3 -3
- package/src/rans/d14.ts +2 -2
- package/src/rans/decoding.ts +2 -2
- package/src/rans/frequencies.ts +3 -3
- package/src/rans/index.ts +5 -5
- package/src/seek-bzip/README.md +6 -0
- package/src/seek-bzip/bitreader.ts +113 -0
- package/src/seek-bzip/crc32.ts +116 -0
- package/src/seek-bzip/index.ts +615 -0
- package/src/seek-bzip/stream.ts +42 -0
- package/src/seek-bzip/toHex.ts +33 -0
- package/dist/cram-bundle.js.LICENSE.txt +0 -12
- package/dist/io/index.js.map +0 -1
- package/esm/io/index.js.map +0 -1
- package/src/cramFile/declare.d.ts +0 -1
- /package/dist/{io/index.d.ts → io.d.ts} +0 -0
- /package/esm/{io/index.d.ts → io.d.ts} +0 -0
- /package/src/{io/index.ts → io.ts} +0 -0
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
/*
|
|
4
|
+
seek-bzip - a pure-javascript module for seeking within bzip2 data
|
|
5
|
+
|
|
6
|
+
Copyright (C) 2013 C. Scott Ananian
|
|
7
|
+
Copyright (C) 2012 Eli Skeggs
|
|
8
|
+
Copyright (C) 2011 Kevin Kwok
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
11
|
+
a copy of this software and associated documentation files (the
|
|
12
|
+
"Software"), to deal in the Software without restriction, including
|
|
13
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
14
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
15
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
16
|
+
the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be
|
|
19
|
+
included in all copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
22
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
23
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
24
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
25
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
26
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
27
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Adapted from node-bzip, copyright 2012 Eli Skeggs.
|
|
30
|
+
Adapted from bzip2.js, copyright 2011 Kevin Kwok (antimatter15@gmail.com).
|
|
31
|
+
|
|
32
|
+
Based on micro-bunzip by Rob Landley (rob@landley.net).
|
|
33
|
+
|
|
34
|
+
Based on bzip2 decompression code by Julian R Seward (jseward@acm.org),
|
|
35
|
+
which also acknowledges contributions by Mike Burrows, David Wheeler,
|
|
36
|
+
Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten,
|
|
37
|
+
Robert Sedgewick, and Jon L. Bentley.
|
|
38
|
+
*/
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.decode = decode;
|
|
44
|
+
const bitreader_1 = __importDefault(require("./bitreader"));
|
|
45
|
+
const crc32_1 = __importDefault(require("./crc32"));
|
|
46
|
+
const stream_1 = __importDefault(require("./stream"));
|
|
47
|
+
const MAX_HUFCODE_BITS = 20;
|
|
48
|
+
const MAX_SYMBOLS = 258;
|
|
49
|
+
const SYMBOL_RUNA = 0;
|
|
50
|
+
const SYMBOL_RUNB = 1;
|
|
51
|
+
const MIN_GROUPS = 2;
|
|
52
|
+
const MAX_GROUPS = 6;
|
|
53
|
+
const GROUP_SIZE = 50;
|
|
54
|
+
const WHOLEPI = '314159265359';
|
|
55
|
+
const SQRTPI = '177245385090';
|
|
56
|
+
const mtf = function (array, index) {
|
|
57
|
+
const src = array[index];
|
|
58
|
+
for (let i = index; i > 0; i--) {
|
|
59
|
+
array[i] = array[i - 1];
|
|
60
|
+
}
|
|
61
|
+
array[0] = src;
|
|
62
|
+
return src;
|
|
63
|
+
};
|
|
64
|
+
const Err = {
|
|
65
|
+
OK: 0,
|
|
66
|
+
LAST_BLOCK: -1,
|
|
67
|
+
NOT_BZIP_DATA: -2,
|
|
68
|
+
UNEXPECTED_INPUT_EOF: -3,
|
|
69
|
+
UNEXPECTED_OUTPUT_EOF: -4,
|
|
70
|
+
DATA_ERROR: -5,
|
|
71
|
+
OUT_OF_MEMORY: -6,
|
|
72
|
+
OBSOLETE_INPUT: -7,
|
|
73
|
+
END_OF_BLOCK: -8,
|
|
74
|
+
};
|
|
75
|
+
const ErrorMessages = {};
|
|
76
|
+
ErrorMessages[Err.LAST_BLOCK] = 'Bad file checksum';
|
|
77
|
+
ErrorMessages[Err.NOT_BZIP_DATA] = 'Not bzip data';
|
|
78
|
+
ErrorMessages[Err.UNEXPECTED_INPUT_EOF] = 'Unexpected input EOF';
|
|
79
|
+
ErrorMessages[Err.UNEXPECTED_OUTPUT_EOF] = 'Unexpected output EOF';
|
|
80
|
+
ErrorMessages[Err.DATA_ERROR] = 'Data error';
|
|
81
|
+
ErrorMessages[Err.OUT_OF_MEMORY] = 'Out of memory';
|
|
82
|
+
ErrorMessages[Err.OBSOLETE_INPUT] =
|
|
83
|
+
'Obsolete (pre 0.9.5) bzip format not supported.';
|
|
84
|
+
const _throw = function (status, optDetail) {
|
|
85
|
+
let msg = ErrorMessages[status] || 'unknown error';
|
|
86
|
+
if (optDetail) {
|
|
87
|
+
msg += ': ' + optDetail;
|
|
88
|
+
}
|
|
89
|
+
const e = new TypeError(msg);
|
|
90
|
+
e.errorCode = status;
|
|
91
|
+
throw e;
|
|
92
|
+
};
|
|
93
|
+
class Bunzip {
|
|
94
|
+
constructor(inputStream, outputStream) {
|
|
95
|
+
this.writePos = this.writeCurrent = this.writeCount = 0;
|
|
96
|
+
this._start_bunzip(inputStream, outputStream);
|
|
97
|
+
}
|
|
98
|
+
_init_block() {
|
|
99
|
+
const moreBlocks = this._get_next_block();
|
|
100
|
+
if (!moreBlocks) {
|
|
101
|
+
this.writeCount = -1;
|
|
102
|
+
return false; /* no more blocks */
|
|
103
|
+
}
|
|
104
|
+
this.blockCRC = new crc32_1.default();
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
/* XXX micro-bunzip uses (inputStream, inputBuffer, len) as arguments */
|
|
108
|
+
_start_bunzip(inputStream, outputStream) {
|
|
109
|
+
/* Ensure that file starts with "BZh['1'-'9']." */
|
|
110
|
+
const buf = new Uint8Array(4);
|
|
111
|
+
if (inputStream.read(buf, 0, 4) !== 4 ||
|
|
112
|
+
String.fromCharCode(buf[0], buf[1], buf[2]) !== 'BZh') {
|
|
113
|
+
_throw(Err.NOT_BZIP_DATA, 'bad magic');
|
|
114
|
+
}
|
|
115
|
+
const level = buf[3] - 0x30;
|
|
116
|
+
if (level < 1 || level > 9) {
|
|
117
|
+
_throw(Err.NOT_BZIP_DATA, 'level out of range');
|
|
118
|
+
}
|
|
119
|
+
this.reader = new bitreader_1.default(inputStream);
|
|
120
|
+
/* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
|
|
121
|
+
uncompressed data. Allocate intermediate buffer for block. */
|
|
122
|
+
this.dbufSize = 100000 * level;
|
|
123
|
+
this.nextoutput = 0;
|
|
124
|
+
this.outputStream = outputStream;
|
|
125
|
+
this.streamCRC = 0;
|
|
126
|
+
}
|
|
127
|
+
_get_next_block() {
|
|
128
|
+
let i, j, k;
|
|
129
|
+
const reader = this.reader;
|
|
130
|
+
// this is get_next_block() function from micro-bunzip:
|
|
131
|
+
/* Read in header signature and CRC, then validate signature.
|
|
132
|
+
(last block signature means CRC is for whole file, return now) */
|
|
133
|
+
const h = reader.pi();
|
|
134
|
+
if (h === SQRTPI) {
|
|
135
|
+
// last block
|
|
136
|
+
return false; /* no more blocks */
|
|
137
|
+
}
|
|
138
|
+
if (h !== WHOLEPI) {
|
|
139
|
+
_throw(Err.NOT_BZIP_DATA);
|
|
140
|
+
}
|
|
141
|
+
this.targetBlockCRC = reader.read(32) >>> 0; // (convert to unsigned)
|
|
142
|
+
this.streamCRC =
|
|
143
|
+
(this.targetBlockCRC ^
|
|
144
|
+
((this.streamCRC << 1) | (this.streamCRC >>> 31))) >>>
|
|
145
|
+
0;
|
|
146
|
+
/* We can add support for blockRandomised if anybody complains. There was
|
|
147
|
+
some code for this in busybox 1.0.0-pre3, but nobody ever noticed that
|
|
148
|
+
it didn't actually work. */
|
|
149
|
+
if (reader.read(1)) {
|
|
150
|
+
_throw(Err.OBSOLETE_INPUT);
|
|
151
|
+
}
|
|
152
|
+
const origPointer = reader.read(24);
|
|
153
|
+
if (origPointer > this.dbufSize) {
|
|
154
|
+
_throw(Err.DATA_ERROR, 'initial position out of bounds');
|
|
155
|
+
}
|
|
156
|
+
/* mapping table: if some byte values are never used (encoding things
|
|
157
|
+
like ascii text), the compression code removes the gaps to have fewer
|
|
158
|
+
symbols to deal with, and writes a sparse bitfield indicating which
|
|
159
|
+
values were present. We make a translation table to convert the symbols
|
|
160
|
+
back to the corresponding bytes. */
|
|
161
|
+
let t = reader.read(16);
|
|
162
|
+
let symToByte = new Uint8Array(256), symTotal = 0;
|
|
163
|
+
for (i = 0; i < 16; i++) {
|
|
164
|
+
if (t & (1 << (0xf - i))) {
|
|
165
|
+
const o = i * 16;
|
|
166
|
+
k = reader.read(16);
|
|
167
|
+
for (j = 0; j < 16; j++) {
|
|
168
|
+
if (k & (1 << (0xf - j))) {
|
|
169
|
+
symToByte[symTotal++] = o + j;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/* How many different huffman coding groups does this block use? */
|
|
175
|
+
const groupCount = reader.read(3);
|
|
176
|
+
if (groupCount < MIN_GROUPS || groupCount > MAX_GROUPS) {
|
|
177
|
+
_throw(Err.DATA_ERROR);
|
|
178
|
+
}
|
|
179
|
+
/* nSelectors: Every GROUP_SIZE many symbols we select a new huffman coding
|
|
180
|
+
group. Read in the group selector list, which is stored as MTF encoded
|
|
181
|
+
bit runs. (MTF=Move To Front, as each value is used it's moved to the
|
|
182
|
+
start of the list.) */
|
|
183
|
+
const nSelectors = reader.read(15);
|
|
184
|
+
if (nSelectors === 0) {
|
|
185
|
+
_throw(Err.DATA_ERROR);
|
|
186
|
+
}
|
|
187
|
+
const mtfSymbol = new Uint8Array(256);
|
|
188
|
+
for (i = 0; i < groupCount; i++) {
|
|
189
|
+
mtfSymbol[i] = i;
|
|
190
|
+
}
|
|
191
|
+
const selectors = new Uint8Array(nSelectors); // was 32768...
|
|
192
|
+
for (i = 0; i < nSelectors; i++) {
|
|
193
|
+
/* Get next value */
|
|
194
|
+
for (j = 0; reader.read(1); j++) {
|
|
195
|
+
if (j >= groupCount) {
|
|
196
|
+
_throw(Err.DATA_ERROR);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/* Decode MTF to get the next selector */
|
|
200
|
+
selectors[i] = mtf(mtfSymbol, j);
|
|
201
|
+
}
|
|
202
|
+
/* Read the huffman coding tables for each group, which code for symTotal
|
|
203
|
+
literal symbols, plus two run symbols (RUNA, RUNB) */
|
|
204
|
+
let symCount = symTotal + 2;
|
|
205
|
+
let groups = [], hufGroup;
|
|
206
|
+
for (j = 0; j < groupCount; j++) {
|
|
207
|
+
const length = new Uint8Array(symCount), temp = new Uint16Array(MAX_HUFCODE_BITS + 1);
|
|
208
|
+
/* Read huffman code lengths for each symbol. They're stored in
|
|
209
|
+
a way similar to mtf; record a starting value for the first symbol,
|
|
210
|
+
and an offset from the previous value for everys symbol after that. */
|
|
211
|
+
t = reader.read(5); // lengths
|
|
212
|
+
for (i = 0; i < symCount; i++) {
|
|
213
|
+
for (;;) {
|
|
214
|
+
if (t < 1 || t > MAX_HUFCODE_BITS) {
|
|
215
|
+
_throw(Err.DATA_ERROR);
|
|
216
|
+
}
|
|
217
|
+
/* If first bit is 0, stop. Else second bit indicates whether
|
|
218
|
+
to increment or decrement the value. */
|
|
219
|
+
if (!reader.read(1)) {
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
if (!reader.read(1)) {
|
|
223
|
+
t++;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
t--;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
length[i] = t;
|
|
230
|
+
}
|
|
231
|
+
/* Find largest and smallest lengths in this group */
|
|
232
|
+
var minLen, maxLen;
|
|
233
|
+
minLen = maxLen = length[0];
|
|
234
|
+
for (i = 1; i < symCount; i++) {
|
|
235
|
+
if (length[i] > maxLen) {
|
|
236
|
+
maxLen = length[i];
|
|
237
|
+
}
|
|
238
|
+
else if (length[i] < minLen) {
|
|
239
|
+
minLen = length[i];
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/* Calculate permute[], base[], and limit[] tables from length[].
|
|
243
|
+
*
|
|
244
|
+
* permute[] is the lookup table for converting huffman coded symbols
|
|
245
|
+
* into decoded symbols. base[] is the amount to subtract from the
|
|
246
|
+
* value of a huffman symbol of a given length when using permute[].
|
|
247
|
+
*
|
|
248
|
+
* limit[] indicates the largest numerical value a symbol with a given
|
|
249
|
+
* number of bits can have. This is how the huffman codes can vary in
|
|
250
|
+
* length: each code with a value>limit[length] needs another bit.
|
|
251
|
+
*/
|
|
252
|
+
hufGroup = {};
|
|
253
|
+
groups.push(hufGroup);
|
|
254
|
+
hufGroup.permute = new Uint16Array(MAX_SYMBOLS);
|
|
255
|
+
hufGroup.limit = new Uint32Array(MAX_HUFCODE_BITS + 2);
|
|
256
|
+
hufGroup.base = new Uint32Array(MAX_HUFCODE_BITS + 1);
|
|
257
|
+
hufGroup.minLen = minLen;
|
|
258
|
+
hufGroup.maxLen = maxLen;
|
|
259
|
+
/* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
|
|
260
|
+
let pp = 0;
|
|
261
|
+
for (i = minLen; i <= maxLen; i++) {
|
|
262
|
+
temp[i] = hufGroup.limit[i] = 0;
|
|
263
|
+
for (t = 0; t < symCount; t++) {
|
|
264
|
+
if (length[t] === i) {
|
|
265
|
+
hufGroup.permute[pp++] = t;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/* Count symbols coded for at each bit length */
|
|
270
|
+
for (i = 0; i < symCount; i++) {
|
|
271
|
+
temp[length[i]]++;
|
|
272
|
+
}
|
|
273
|
+
/* Calculate limit[] (the largest symbol-coding value at each bit
|
|
274
|
+
* length, which is (previous limit<<1)+symbols at this level), and
|
|
275
|
+
* base[] (number of symbols to ignore at each bit length, which is
|
|
276
|
+
* limit minus the cumulative count of symbols coded for already). */
|
|
277
|
+
pp = t = 0;
|
|
278
|
+
for (i = minLen; i < maxLen; i++) {
|
|
279
|
+
pp += temp[i];
|
|
280
|
+
/* We read the largest possible symbol size and then unget bits
|
|
281
|
+
after determining how many we need, and those extra bits could
|
|
282
|
+
be set to anything. (They're noise from future symbols.) At
|
|
283
|
+
each level we're really only interested in the first few bits,
|
|
284
|
+
so here we set all the trailing to-be-ignored bits to 1 so they
|
|
285
|
+
don't affect the value>limit[length] comparison. */
|
|
286
|
+
hufGroup.limit[i] = pp - 1;
|
|
287
|
+
pp <<= 1;
|
|
288
|
+
t += temp[i];
|
|
289
|
+
hufGroup.base[i + 1] = pp - t;
|
|
290
|
+
}
|
|
291
|
+
hufGroup.limit[maxLen + 1] =
|
|
292
|
+
Number.MAX_VALUE; /* Sentinal value for reading next sym. */
|
|
293
|
+
hufGroup.limit[maxLen] = pp + temp[maxLen] - 1;
|
|
294
|
+
hufGroup.base[minLen] = 0;
|
|
295
|
+
}
|
|
296
|
+
/* We've finished reading and digesting the block header. Now read this
|
|
297
|
+
block's huffman coded symbols from the file and undo the huffman coding
|
|
298
|
+
and run length encoding, saving the result into dbuf[dbufCount++]=uc */
|
|
299
|
+
/* Initialize symbol occurrence counters and symbol Move To Front table */
|
|
300
|
+
const byteCount = new Uint32Array(256);
|
|
301
|
+
for (i = 0; i < 256; i++) {
|
|
302
|
+
mtfSymbol[i] = i;
|
|
303
|
+
}
|
|
304
|
+
/* Loop through compressed symbols. */
|
|
305
|
+
let runPos = 0, dbufCount = 0, selector = 0, uc;
|
|
306
|
+
const dbuf = (this.dbuf = new Uint32Array(this.dbufSize));
|
|
307
|
+
symCount = 0;
|
|
308
|
+
for (;;) {
|
|
309
|
+
/* Determine which huffman coding group to use. */
|
|
310
|
+
if (!symCount--) {
|
|
311
|
+
symCount = GROUP_SIZE - 1;
|
|
312
|
+
if (selector >= nSelectors) {
|
|
313
|
+
_throw(Err.DATA_ERROR);
|
|
314
|
+
}
|
|
315
|
+
hufGroup = groups[selectors[selector++]];
|
|
316
|
+
}
|
|
317
|
+
/* Read next huffman-coded symbol. */
|
|
318
|
+
i = hufGroup.minLen;
|
|
319
|
+
j = reader.read(i);
|
|
320
|
+
for (;; i++) {
|
|
321
|
+
if (i > hufGroup.maxLen) {
|
|
322
|
+
_throw(Err.DATA_ERROR);
|
|
323
|
+
}
|
|
324
|
+
if (j <= hufGroup.limit[i]) {
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
j = (j << 1) | reader.read(1);
|
|
328
|
+
}
|
|
329
|
+
/* Huffman decode value to get nextSym (with bounds checking) */
|
|
330
|
+
j -= hufGroup.base[i];
|
|
331
|
+
if (j < 0 || j >= MAX_SYMBOLS) {
|
|
332
|
+
_throw(Err.DATA_ERROR);
|
|
333
|
+
}
|
|
334
|
+
const nextSym = hufGroup.permute[j];
|
|
335
|
+
/* We have now decoded the symbol, which indicates either a new literal
|
|
336
|
+
byte, or a repeated run of the most recent literal byte. First,
|
|
337
|
+
check if nextSym indicates a repeated run, and if so loop collecting
|
|
338
|
+
how many times to repeat the last literal. */
|
|
339
|
+
if (nextSym === SYMBOL_RUNA || nextSym === SYMBOL_RUNB) {
|
|
340
|
+
/* If this is the start of a new run, zero out counter */
|
|
341
|
+
if (!runPos) {
|
|
342
|
+
runPos = 1;
|
|
343
|
+
t = 0;
|
|
344
|
+
}
|
|
345
|
+
/* Neat trick that saves 1 symbol: instead of or-ing 0 or 1 at
|
|
346
|
+
each bit position, add 1 or 2 instead. For example,
|
|
347
|
+
1011 is 1<<0 + 1<<1 + 2<<2. 1010 is 2<<0 + 2<<1 + 1<<2.
|
|
348
|
+
You can make any bit pattern that way using 1 less symbol than
|
|
349
|
+
the basic or 0/1 method (except all bits 0, which would use no
|
|
350
|
+
symbols, but a run of length 0 doesn't mean anything in this
|
|
351
|
+
context). Thus space is saved. */
|
|
352
|
+
t += nextSym === SYMBOL_RUNA ? runPos : 2 * runPos;
|
|
353
|
+
runPos <<= 1;
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
/* When we hit the first non-run symbol after a run, we now know
|
|
357
|
+
how many times to repeat the last literal, so append that many
|
|
358
|
+
copies to our buffer of decoded symbols (dbuf) now. (The last
|
|
359
|
+
literal used is the one at the head of the mtfSymbol array.) */
|
|
360
|
+
if (runPos) {
|
|
361
|
+
runPos = 0;
|
|
362
|
+
if (dbufCount + t > this.dbufSize) {
|
|
363
|
+
_throw(Err.DATA_ERROR);
|
|
364
|
+
}
|
|
365
|
+
uc = symToByte[mtfSymbol[0]];
|
|
366
|
+
byteCount[uc] += t;
|
|
367
|
+
while (t--) {
|
|
368
|
+
dbuf[dbufCount++] = uc;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
/* Is this the terminating symbol? */
|
|
372
|
+
if (nextSym > symTotal) {
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
/* At this point, nextSym indicates a new literal character. Subtract
|
|
376
|
+
one to get the position in the MTF array at which this literal is
|
|
377
|
+
currently to be found. (Note that the result can't be -1 or 0,
|
|
378
|
+
because 0 and 1 are RUNA and RUNB. But another instance of the
|
|
379
|
+
first symbol in the mtf array, position 0, would have been handled
|
|
380
|
+
as part of a run above. Therefore 1 unused mtf position minus
|
|
381
|
+
2 non-literal nextSym values equals -1.) */
|
|
382
|
+
if (dbufCount >= this.dbufSize) {
|
|
383
|
+
_throw(Err.DATA_ERROR);
|
|
384
|
+
}
|
|
385
|
+
i = nextSym - 1;
|
|
386
|
+
uc = mtf(mtfSymbol, i);
|
|
387
|
+
uc = symToByte[uc];
|
|
388
|
+
/* We have our literal byte. Save it into dbuf. */
|
|
389
|
+
byteCount[uc]++;
|
|
390
|
+
dbuf[dbufCount++] = uc;
|
|
391
|
+
}
|
|
392
|
+
/* At this point, we've read all the huffman-coded symbols (and repeated
|
|
393
|
+
runs) for this block from the input stream, and decoded them into the
|
|
394
|
+
intermediate buffer. There are dbufCount many decoded bytes in dbuf[].
|
|
395
|
+
Now undo the Burrows-Wheeler transform on dbuf.
|
|
396
|
+
See http://dogma.net/markn/articles/bwt/bwt.htm
|
|
397
|
+
*/
|
|
398
|
+
if (origPointer < 0 || origPointer >= dbufCount) {
|
|
399
|
+
_throw(Err.DATA_ERROR);
|
|
400
|
+
}
|
|
401
|
+
/* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
|
|
402
|
+
j = 0;
|
|
403
|
+
for (i = 0; i < 256; i++) {
|
|
404
|
+
k = j + byteCount[i];
|
|
405
|
+
byteCount[i] = j;
|
|
406
|
+
j = k;
|
|
407
|
+
}
|
|
408
|
+
/* Figure out what order dbuf would be in if we sorted it. */
|
|
409
|
+
for (i = 0; i < dbufCount; i++) {
|
|
410
|
+
uc = dbuf[i] & 0xff;
|
|
411
|
+
dbuf[byteCount[uc]] |= i << 8;
|
|
412
|
+
byteCount[uc]++;
|
|
413
|
+
}
|
|
414
|
+
/* Decode first byte by hand to initialize "previous" byte. Note that it
|
|
415
|
+
doesn't get output, and if the first three characters are identical
|
|
416
|
+
it doesn't qualify as a run (hence writeRunCountdown=5). */
|
|
417
|
+
let pos = 0, current = 0, run = 0;
|
|
418
|
+
if (dbufCount) {
|
|
419
|
+
pos = dbuf[origPointer];
|
|
420
|
+
current = pos & 0xff;
|
|
421
|
+
pos >>= 8;
|
|
422
|
+
run = -1;
|
|
423
|
+
}
|
|
424
|
+
this.writePos = pos;
|
|
425
|
+
this.writeCurrent = current;
|
|
426
|
+
this.writeCount = dbufCount;
|
|
427
|
+
this.writeRun = run;
|
|
428
|
+
return true; /* more blocks to come */
|
|
429
|
+
}
|
|
430
|
+
/* Undo burrows-wheeler transform on intermediate buffer to produce output.
|
|
431
|
+
If start_bunzip was initialized with out_fd=-1, then up to len bytes of
|
|
432
|
+
data are written to outbuf. Return value is number of bytes written or
|
|
433
|
+
error (all errors are negative numbers). If out_fd!=-1, outbuf and len
|
|
434
|
+
are ignored, data is written to out_fd and return is RETVAL_OK or error.
|
|
435
|
+
*/
|
|
436
|
+
_read_bunzip(outputBuffer, len) {
|
|
437
|
+
let copies, previous, outbyte;
|
|
438
|
+
/* james@jamestaylor.org: writeCount goes to -1 when the buffer is fully
|
|
439
|
+
decoded, which results in this returning RETVAL_LAST_BLOCK, also
|
|
440
|
+
equal to -1... Confusing, I'm returning 0 here to indicate no
|
|
441
|
+
bytes written into the buffer */
|
|
442
|
+
if (this.writeCount < 0) {
|
|
443
|
+
return 0;
|
|
444
|
+
}
|
|
445
|
+
const gotcount = 0;
|
|
446
|
+
let dbuf = this.dbuf, pos = this.writePos, current = this.writeCurrent;
|
|
447
|
+
let dbufCount = this.writeCount, outputsize = this.outputsize;
|
|
448
|
+
let run = this.writeRun;
|
|
449
|
+
while (dbufCount) {
|
|
450
|
+
dbufCount--;
|
|
451
|
+
previous = current;
|
|
452
|
+
pos = dbuf[pos];
|
|
453
|
+
current = pos & 0xff;
|
|
454
|
+
pos >>= 8;
|
|
455
|
+
if (run++ === 3) {
|
|
456
|
+
copies = current;
|
|
457
|
+
outbyte = previous;
|
|
458
|
+
current = -1;
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
copies = 1;
|
|
462
|
+
outbyte = current;
|
|
463
|
+
}
|
|
464
|
+
this.blockCRC.updateCRCRun(outbyte, copies);
|
|
465
|
+
while (copies--) {
|
|
466
|
+
this.outputStream.writeByte(outbyte);
|
|
467
|
+
this.nextoutput++;
|
|
468
|
+
}
|
|
469
|
+
if (current != previous) {
|
|
470
|
+
run = 0;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
this.writeCount = dbufCount;
|
|
474
|
+
// check CRC
|
|
475
|
+
if (this.blockCRC.getCRC() !== this.targetBlockCRC) {
|
|
476
|
+
_throw(Err.DATA_ERROR, 'Bad block CRC ' +
|
|
477
|
+
'(got ' +
|
|
478
|
+
this.blockCRC.getCRC().toString(16) +
|
|
479
|
+
' expected ' +
|
|
480
|
+
this.targetBlockCRC.toString(16) +
|
|
481
|
+
')');
|
|
482
|
+
}
|
|
483
|
+
return this.nextoutput;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
const coerceInputStream = function (input) {
|
|
487
|
+
if ('readByte' in input) {
|
|
488
|
+
return input;
|
|
489
|
+
}
|
|
490
|
+
const inputStream = new stream_1.default();
|
|
491
|
+
inputStream.pos = 0;
|
|
492
|
+
inputStream.readByte = function () {
|
|
493
|
+
return input[this.pos++];
|
|
494
|
+
};
|
|
495
|
+
inputStream.seek = function (pos) {
|
|
496
|
+
this.pos = pos;
|
|
497
|
+
};
|
|
498
|
+
inputStream.eof = function () {
|
|
499
|
+
return this.pos >= input.length;
|
|
500
|
+
};
|
|
501
|
+
return inputStream;
|
|
502
|
+
};
|
|
503
|
+
const coerceOutputStream = function (output) {
|
|
504
|
+
const outputStream = new stream_1.default();
|
|
505
|
+
let resizeOk = true;
|
|
506
|
+
if (output) {
|
|
507
|
+
if (typeof output === 'number') {
|
|
508
|
+
outputStream.buffer = new Uint8Array(output);
|
|
509
|
+
resizeOk = false;
|
|
510
|
+
}
|
|
511
|
+
else if ('writeByte' in output) {
|
|
512
|
+
return output;
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
outputStream.buffer = output;
|
|
516
|
+
resizeOk = false;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
outputStream.buffer = new Uint8Array(16384);
|
|
521
|
+
}
|
|
522
|
+
outputStream.pos = 0;
|
|
523
|
+
outputStream.writeByte = function (_byte) {
|
|
524
|
+
if (resizeOk && this.pos >= this.buffer.length) {
|
|
525
|
+
const newBuffer = new Uint8Array(this.buffer.length * 2);
|
|
526
|
+
newBuffer.set(this.buffer);
|
|
527
|
+
this.buffer = newBuffer;
|
|
528
|
+
}
|
|
529
|
+
this.buffer[this.pos++] = _byte;
|
|
530
|
+
};
|
|
531
|
+
outputStream.getBuffer = function () {
|
|
532
|
+
// trim buffer
|
|
533
|
+
if (this.pos !== this.buffer.length) {
|
|
534
|
+
if (!resizeOk) {
|
|
535
|
+
throw new TypeError('outputsize does not match decoded input');
|
|
536
|
+
}
|
|
537
|
+
const newBuffer = new Uint8Array(this.pos);
|
|
538
|
+
newBuffer.set(this.buffer.slice(0, this.pos));
|
|
539
|
+
this.buffer = newBuffer;
|
|
540
|
+
}
|
|
541
|
+
return this.buffer;
|
|
542
|
+
};
|
|
543
|
+
outputStream._coerced = true;
|
|
544
|
+
return outputStream;
|
|
545
|
+
};
|
|
546
|
+
/* Static helper functions */
|
|
547
|
+
// 'input' can be a stream or a buffer
|
|
548
|
+
// 'output' can be a stream or a buffer or a number (buffer size)
|
|
549
|
+
function decode(input, output, multistream) {
|
|
550
|
+
// make a stream from a buffer, if necessary
|
|
551
|
+
const inputStream = coerceInputStream(input);
|
|
552
|
+
const outputStream = coerceOutputStream(output);
|
|
553
|
+
const bz = new Bunzip(inputStream, outputStream);
|
|
554
|
+
while (true) {
|
|
555
|
+
if ('eof' in inputStream && inputStream.eof()) {
|
|
556
|
+
break;
|
|
557
|
+
}
|
|
558
|
+
if (bz._init_block()) {
|
|
559
|
+
bz._read_bunzip();
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
const targetStreamCRC = bz.reader.read(32) >>> 0; // (convert to unsigned)
|
|
563
|
+
if (targetStreamCRC !== bz.streamCRC) {
|
|
564
|
+
_throw(Err.DATA_ERROR, 'Bad stream CRC ' +
|
|
565
|
+
'(got ' +
|
|
566
|
+
bz.streamCRC.toString(16) +
|
|
567
|
+
' expected ' +
|
|
568
|
+
targetStreamCRC.toString(16) +
|
|
569
|
+
')');
|
|
570
|
+
}
|
|
571
|
+
if (multistream && 'eof' in inputStream && !inputStream.eof()) {
|
|
572
|
+
// note that start_bunzip will also resync the bit reader to next byte
|
|
573
|
+
bz._start_bunzip(inputStream, outputStream);
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
if ('getBuffer' in outputStream) {
|
|
581
|
+
return outputStream.getBuffer();
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
exports.default = Bunzip;
|
|
585
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/seek-bzip/index.ts"],"names":[],"mappings":";AAAA,cAAc;AACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCE;;;;;AA4hBF,wBAoCC;AA9jBD,4DAAmC;AACnC,oDAA2B;AAC3B,sDAA6B;AAE7B,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAC3B,MAAM,WAAW,GAAG,GAAG,CAAA;AACvB,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,UAAU,GAAG,CAAC,CAAA;AACpB,MAAM,UAAU,GAAG,CAAC,CAAA;AACpB,MAAM,UAAU,GAAG,EAAE,CAAA;AAErB,MAAM,OAAO,GAAG,cAAc,CAAA;AAC9B,MAAM,MAAM,GAAG,cAAc,CAAA;AAE7B,MAAM,GAAG,GAAG,UAAU,KAAK,EAAE,KAAK;IAChC,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;IACxB,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACzB,CAAC;IACD,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;IACd,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,GAAG,GAAG;IACV,EAAE,EAAE,CAAC;IACL,UAAU,EAAE,CAAC,CAAC;IACd,aAAa,EAAE,CAAC,CAAC;IACjB,oBAAoB,EAAE,CAAC,CAAC;IACxB,qBAAqB,EAAE,CAAC,CAAC;IACzB,UAAU,EA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,QAAQ,CAAC,EAAE,CAAC;oBACzB,YAAY;oBACZ,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC5B,GAAG,CACN,CAAA;YACH,CAAC;YACD,IAAI,WAAW,IAAI,KAAK,IAAI,WAAW,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,CAAC;gBAC9D,sEAAsE;gBACtE,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;YAC7C,CAAC;iBAAM,CAAC;gBACN,MAAK;YACP,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,WAAW,IAAI,YAAY,EAAE,CAAC;QAChC,OAAO,YAAY,CAAC,SAAS,EAAE,CAAA;IACjC,CAAC;AACH,CAAC;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare const Stream: () => void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
/// * very simple input/output stream interface */
|
|
4
|
+
const Stream = function () { };
|
|
5
|
+
// input streams //////////////
|
|
6
|
+
/** Returns the next byte, or -1 for EOF. */
|
|
7
|
+
Stream.prototype.readByte = function () {
|
|
8
|
+
throw new Error('abstract method readByte() not implemented');
|
|
9
|
+
};
|
|
10
|
+
/** Attempts to fill the buffer; returns number of bytes read, or
|
|
11
|
+
* -1 for EOF. */
|
|
12
|
+
Stream.prototype.read = function (buffer, bufOffset, length) {
|
|
13
|
+
let bytesRead = 0;
|
|
14
|
+
while (bytesRead < length) {
|
|
15
|
+
const c = this.readByte();
|
|
16
|
+
if (c < 0) {
|
|
17
|
+
// EOF
|
|
18
|
+
return bytesRead === 0 ? -1 : bytesRead;
|
|
19
|
+
}
|
|
20
|
+
buffer[bufOffset++] = c;
|
|
21
|
+
bytesRead++;
|
|
22
|
+
}
|
|
23
|
+
return bytesRead;
|
|
24
|
+
};
|
|
25
|
+
Stream.prototype.seek = function (new_pos) {
|
|
26
|
+
throw new Error('abstract method seek() not implemented');
|
|
27
|
+
};
|
|
28
|
+
// output streams ///////////
|
|
29
|
+
Stream.prototype.writeByte = function (_byte) {
|
|
30
|
+
throw new Error('abstract method readByte() not implemented');
|
|
31
|
+
};
|
|
32
|
+
Stream.prototype.write = function (buffer, bufOffset, length) {
|
|
33
|
+
let i;
|
|
34
|
+
for (i = 0; i < length; i++) {
|
|
35
|
+
this.writeByte(buffer[bufOffset++]);
|
|
36
|
+
}
|
|
37
|
+
return length;
|
|
38
|
+
};
|
|
39
|
+
Stream.prototype.flush = function () { };
|
|
40
|
+
module.exports = Stream;
|
|
41
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/seek-bzip/stream.ts"],"names":[],"mappings":";AAAA,cAAc;AACd,kDAAkD;AAClD,MAAM,MAAM,GAAG,cAAa,CAAC,CAAA;AAE7B,+BAA+B;AAC/B,4CAA4C;AAC5C,MAAM,CAAC,SAAS,CAAC,QAAQ,GAAG;IAC1B,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA;AAC/D,CAAC,CAAA;AACD;kBACkB;AAClB,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,UAAU,MAAM,EAAE,SAAS,EAAE,MAAM;IACzD,IAAI,SAAS,GAAG,CAAC,CAAA;IACjB,OAAO,SAAS,GAAG,MAAM,EAAE,CAAC;QAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;QACzB,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACV,MAAM;YACN,OAAO,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QACzC,CAAC;QACD,MAAM,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,CAAA;QACvB,SAAS,EAAE,CAAA;IACb,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,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