@gmod/cram 1.6.3 → 1.7.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/CHANGELOG.md +9 -0
- package/dist/craiIndex.d.ts +19 -12
- package/dist/craiIndex.js +63 -123
- package/dist/craiIndex.js.map +1 -1
- package/dist/cram-bundle.js +2 -17
- package/dist/cram-bundle.js.LICENSE.txt +17 -0
- package/dist/cramFile/codecs/_base.d.ts +26 -5
- package/dist/cramFile/codecs/_base.js +3 -39
- package/dist/cramFile/codecs/_base.js.map +1 -1
- package/dist/cramFile/codecs/beta.d.ts +7 -3
- package/dist/cramFile/codecs/beta.js +13 -31
- package/dist/cramFile/codecs/beta.js.map +1 -1
- package/dist/cramFile/codecs/byteArrayLength.d.ts +13 -7
- package/dist/cramFile/codecs/byteArrayLength.js +22 -41
- package/dist/cramFile/codecs/byteArrayLength.js.map +1 -1
- package/dist/cramFile/codecs/byteArrayStop.d.ts +9 -5
- package/dist/cramFile/codecs/byteArrayStop.js +25 -46
- package/dist/cramFile/codecs/byteArrayStop.js.map +1 -1
- package/dist/cramFile/codecs/dataSeriesTypes.d.ts +4 -0
- package/dist/cramFile/codecs/dataSeriesTypes.js +3 -0
- package/dist/cramFile/codecs/dataSeriesTypes.js.map +1 -0
- package/dist/cramFile/codecs/external.d.ts +10 -6
- package/dist/cramFile/codecs/external.js +26 -44
- package/dist/cramFile/codecs/external.js.map +1 -1
- package/dist/cramFile/codecs/gamma.d.ts +7 -3
- package/dist/cramFile/codecs/gamma.js +16 -34
- package/dist/cramFile/codecs/gamma.js.map +1 -1
- package/dist/cramFile/codecs/getBits.d.ts +7 -0
- package/dist/cramFile/codecs/getBits.js +26 -0
- package/dist/cramFile/codecs/getBits.js.map +1 -0
- package/dist/cramFile/codecs/huffman.d.ts +17 -13
- package/dist/cramFile/codecs/huffman.js +76 -85
- package/dist/cramFile/codecs/huffman.js.map +1 -1
- package/dist/cramFile/codecs/index.d.ts +4 -2
- package/dist/cramFile/codecs/index.js +12 -13
- package/dist/cramFile/codecs/index.js.map +1 -1
- package/dist/cramFile/codecs/subexp.d.ts +7 -3
- package/dist/cramFile/codecs/subexp.js +19 -36
- package/dist/cramFile/codecs/subexp.js.map +1 -1
- package/dist/cramFile/constants.d.ts +35 -35
- package/dist/cramFile/constants.js +1 -1
- package/dist/cramFile/constants.js.map +1 -1
- package/dist/cramFile/container/compressionScheme.d.ts +57 -11
- package/dist/cramFile/container/compressionScheme.js +37 -32
- package/dist/cramFile/container/compressionScheme.js.map +1 -1
- package/dist/cramFile/container/index.d.ts +23 -9
- package/dist/cramFile/container/index.js +74 -144
- package/dist/cramFile/container/index.js.map +1 -1
- package/dist/cramFile/encoding.d.ts +78 -0
- package/dist/cramFile/encoding.js +3 -0
- package/dist/cramFile/encoding.js.map +1 -0
- package/dist/cramFile/file.d.ts +91 -41
- package/dist/cramFile/file.js +234 -368
- package/dist/cramFile/file.js.map +1 -1
- package/dist/cramFile/filehandle.d.ts +2 -0
- package/dist/cramFile/filehandle.js +3 -0
- package/dist/cramFile/filehandle.js.map +1 -0
- package/dist/cramFile/index.d.ts +1 -1
- package/dist/cramFile/index.js +1 -1
- package/dist/cramFile/index.js.map +1 -1
- package/dist/cramFile/record.d.ts +61 -17
- package/dist/cramFile/record.js +153 -77
- package/dist/cramFile/record.js.map +1 -1
- package/dist/cramFile/sectionParsers.d.ts +99 -8
- package/dist/cramFile/sectionParsers.js +70 -80
- package/dist/cramFile/sectionParsers.js.map +1 -1
- package/dist/cramFile/slice/decodeRecord.d.ts +30 -2
- package/dist/cramFile/slice/decodeRecord.js +148 -118
- package/dist/cramFile/slice/decodeRecord.js.map +1 -1
- package/dist/cramFile/slice/index.d.ts +21 -14
- package/dist/cramFile/slice/index.js +286 -381
- package/dist/cramFile/slice/index.js.map +1 -1
- package/dist/cramFile/util.d.ts +11 -5
- package/dist/cramFile/util.js +19 -97
- package/dist/cramFile/util.js.map +1 -1
- package/dist/errors.d.ts +5 -10
- package/dist/errors.js +11 -62
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/indexedCramFile.d.ts +37 -12
- package/dist/indexedCramFile.js +114 -154
- package/dist/indexedCramFile.js.map +1 -1
- package/dist/io/index.d.ts +5 -5
- package/dist/io/index.js +9 -9
- package/dist/io/index.js.map +1 -1
- package/dist/rans/constants.js +3 -3
- package/dist/rans/constants.js.map +1 -1
- package/dist/rans/d04.js +15 -15
- package/dist/rans/d04.js.map +1 -1
- package/dist/rans/d14.js +21 -21
- package/dist/rans/d14.js.map +1 -1
- package/dist/rans/decoding.js +27 -30
- package/dist/rans/decoding.js.map +1 -1
- package/dist/rans/frequencies.js +11 -11
- package/dist/rans/frequencies.js.map +1 -1
- package/dist/rans/index.js +46 -49
- package/dist/rans/index.js.map +1 -1
- package/dist/sam.d.ts +8 -1
- package/dist/sam.js +7 -7
- package/dist/sam.js.map +1 -1
- package/dist/typescript.d.ts +3 -0
- package/dist/typescript.js +11 -0
- package/dist/typescript.js.map +1 -0
- package/dist/unzip-pako.js +1 -1
- package/dist/unzip-pako.js.map +1 -1
- package/dist/unzip.js +1 -1
- package/dist/unzip.js.map +1 -1
- package/errors.js +11 -62
- package/esm/craiIndex.d.ts +19 -12
- package/esm/craiIndex.js +8 -24
- package/esm/craiIndex.js.map +1 -1
- package/esm/cramFile/codecs/_base.d.ts +26 -5
- package/esm/cramFile/codecs/_base.js +1 -35
- package/esm/cramFile/codecs/_base.js.map +1 -1
- package/esm/cramFile/codecs/beta.d.ts +7 -3
- package/esm/cramFile/codecs/beta.js +4 -3
- package/esm/cramFile/codecs/beta.js.map +1 -1
- package/esm/cramFile/codecs/byteArrayLength.d.ts +13 -7
- package/esm/cramFile/codecs/byteArrayLength.js +1 -1
- package/esm/cramFile/codecs/byteArrayLength.js.map +1 -1
- package/esm/cramFile/codecs/byteArrayStop.d.ts +9 -5
- package/esm/cramFile/codecs/byteArrayStop.js +7 -9
- package/esm/cramFile/codecs/byteArrayStop.js.map +1 -1
- package/esm/cramFile/codecs/dataSeriesTypes.d.ts +4 -0
- package/esm/cramFile/codecs/dataSeriesTypes.js +2 -0
- package/esm/cramFile/codecs/dataSeriesTypes.js.map +1 -0
- package/esm/cramFile/codecs/external.d.ts +10 -6
- package/esm/cramFile/codecs/external.js +4 -3
- package/esm/cramFile/codecs/external.js.map +1 -1
- package/esm/cramFile/codecs/gamma.d.ts +7 -3
- package/esm/cramFile/codecs/gamma.js +5 -4
- package/esm/cramFile/codecs/gamma.js.map +1 -1
- package/esm/cramFile/codecs/getBits.d.ts +7 -0
- package/esm/cramFile/codecs/getBits.js +21 -0
- package/esm/cramFile/codecs/getBits.js.map +1 -0
- package/esm/cramFile/codecs/huffman.d.ts +17 -13
- package/esm/cramFile/codecs/huffman.js +22 -9
- package/esm/cramFile/codecs/huffman.js.map +1 -1
- package/esm/cramFile/codecs/index.d.ts +4 -2
- package/esm/cramFile/codecs/index.js +1 -1
- package/esm/cramFile/codecs/index.js.map +1 -1
- package/esm/cramFile/codecs/subexp.d.ts +7 -3
- package/esm/cramFile/codecs/subexp.js +7 -5
- package/esm/cramFile/codecs/subexp.js.map +1 -1
- package/esm/cramFile/constants.d.ts +35 -35
- package/esm/cramFile/constants.js.map +1 -1
- package/esm/cramFile/container/compressionScheme.d.ts +57 -11
- package/esm/cramFile/container/compressionScheme.js +15 -8
- package/esm/cramFile/container/compressionScheme.js.map +1 -1
- package/esm/cramFile/container/index.d.ts +23 -9
- package/esm/cramFile/container/index.js +11 -9
- package/esm/cramFile/container/index.js.map +1 -1
- package/esm/cramFile/encoding.d.ts +78 -0
- package/esm/cramFile/encoding.js +2 -0
- package/esm/cramFile/encoding.js.map +1 -0
- package/esm/cramFile/file.d.ts +91 -41
- package/esm/cramFile/file.js +59 -47
- package/esm/cramFile/file.js.map +1 -1
- package/esm/cramFile/filehandle.d.ts +2 -0
- package/esm/cramFile/filehandle.js +2 -0
- package/esm/cramFile/filehandle.js.map +1 -0
- package/esm/cramFile/index.d.ts +1 -1
- package/esm/cramFile/index.js.map +1 -1
- package/esm/cramFile/record.d.ts +61 -17
- package/esm/cramFile/record.js +83 -5
- package/esm/cramFile/record.js.map +1 -1
- package/esm/cramFile/sectionParsers.d.ts +99 -8
- package/esm/cramFile/sectionParsers.js +7 -17
- package/esm/cramFile/sectionParsers.js.map +1 -1
- package/esm/cramFile/slice/decodeRecord.d.ts +30 -2
- package/esm/cramFile/slice/decodeRecord.js +102 -70
- package/esm/cramFile/slice/decodeRecord.js.map +1 -1
- package/esm/cramFile/slice/index.d.ts +21 -14
- package/esm/cramFile/slice/index.js +77 -38
- package/esm/cramFile/slice/index.js.map +1 -1
- package/esm/cramFile/util.d.ts +11 -5
- package/esm/cramFile/util.js +11 -82
- package/esm/cramFile/util.js.map +1 -1
- package/esm/errors.d.ts +5 -10
- package/esm/errors.js +0 -5
- package/esm/errors.js.map +1 -1
- package/esm/index.d.ts +3 -3
- package/esm/index.js.map +1 -1
- package/esm/indexedCramFile.d.ts +37 -12
- package/esm/indexedCramFile.js +19 -8
- package/esm/indexedCramFile.js.map +1 -1
- package/esm/io/index.d.ts +5 -5
- package/esm/io/index.js +3 -3
- package/esm/io/index.js.map +1 -1
- package/esm/sam.d.ts +8 -1
- package/esm/sam.js.map +1 -1
- package/esm/typescript.d.ts +3 -0
- package/esm/typescript.js +7 -0
- package/esm/typescript.js.map +1 -0
- package/package.json +18 -11
- package/src/{craiIndex.js → craiIndex.ts} +37 -31
- package/src/cramFile/codecs/_base.ts +45 -0
- package/src/cramFile/codecs/beta.ts +34 -0
- package/src/cramFile/codecs/{byteArrayLength.js → byteArrayLength.ts} +27 -5
- package/src/cramFile/codecs/{byteArrayStop.js → byteArrayStop.ts} +25 -12
- package/src/cramFile/codecs/dataSeriesTypes.ts +39 -0
- package/src/cramFile/codecs/{external.js → external.ts} +28 -12
- package/src/cramFile/codecs/gamma.ts +42 -0
- package/src/cramFile/codecs/getBits.ts +28 -0
- package/src/cramFile/codecs/{huffman.js → huffman.ts} +48 -15
- package/src/cramFile/codecs/{index.js → index.ts} +9 -3
- package/src/cramFile/codecs/subexp.ts +45 -0
- package/src/cramFile/{constants.js → constants.ts} +0 -0
- package/src/cramFile/container/{compressionScheme.js → compressionScheme.ts} +50 -18
- package/src/cramFile/container/{index.js → index.ts} +13 -13
- package/src/cramFile/encoding.ts +98 -0
- package/src/cramFile/{file.js → file.ts} +136 -62
- package/src/cramFile/filehandle.ts +3 -0
- package/src/cramFile/{index.js → index.ts} +0 -0
- package/src/cramFile/{record.js → record.ts} +185 -14
- package/src/cramFile/{sectionParsers.js → sectionParsers.ts} +148 -20
- package/src/cramFile/slice/{decodeRecord.js → decodeRecord.ts} +158 -105
- package/src/cramFile/slice/{index.js → index.ts} +138 -63
- package/src/cramFile/{util.js → util.ts} +28 -17
- package/src/{errors.js → errors.ts} +0 -5
- package/src/{index.js → index.ts} +0 -0
- package/src/{indexedCramFile.js → indexedCramFile.ts} +79 -19
- package/src/io/{index.js → index.ts} +10 -5
- package/src/{sam.js → sam.ts} +7 -2
- package/src/typescript.ts +17 -0
- package/src/typings/binary-parser.d.ts +44 -0
- package/src/typings/bzip2.d.ts +7 -0
- package/src/typings/htscodecs.d.ts +6 -0
- package/dist/io/bufferCache.d.ts +0 -12
- package/dist/io/bufferCache.js +0 -112
- package/dist/io/bufferCache.js.map +0 -1
- package/dist/io/localFile.d.ts +0 -10
- package/dist/io/localFile.js +0 -108
- package/dist/io/localFile.js.map +0 -1
- package/dist/io/remoteFile.d.ts +0 -16
- package/dist/io/remoteFile.js +0 -143
- package/dist/io/remoteFile.js.map +0 -1
- package/esm/io/bufferCache.d.ts +0 -12
- package/esm/io/bufferCache.js +0 -54
- package/esm/io/bufferCache.js.map +0 -1
- package/esm/io/localFile.d.ts +0 -10
- package/esm/io/localFile.js +0 -31
- package/esm/io/localFile.js.map +0 -1
- package/esm/io/remoteFile.d.ts +0 -16
- package/esm/io/remoteFile.js +0 -64
- package/esm/io/remoteFile.js.map +0 -1
- package/src/cramFile/codecs/_base.js +0 -49
- package/src/cramFile/codecs/beta.js +0 -23
- package/src/cramFile/codecs/gamma.js +0 -30
- package/src/cramFile/codecs/subexp.js +0 -32
- package/src/io/bufferCache.js +0 -66
- package/src/io/localFile.js +0 -35
- package/src/io/remoteFile.js +0 -71
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Determine if an object is a Buffer
|
|
3
|
+
*
|
|
4
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*!
|
|
9
|
+
* The buffer module from node.js, for the browser.
|
|
10
|
+
*
|
|
11
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
12
|
+
* @license MIT
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/*! https://mths.be/punycode v1.3.2 by @mathias */
|
|
16
|
+
|
|
17
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
@@ -1,6 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import CramSlice from '../slice';
|
|
2
|
+
import { CramFileBlock } from '../file';
|
|
3
|
+
import { DataType } from './dataSeriesTypes';
|
|
4
|
+
export declare type DataTypeMapping = {
|
|
5
|
+
byte: number;
|
|
6
|
+
int: number;
|
|
7
|
+
long: number;
|
|
8
|
+
byteArray: Uint8Array;
|
|
9
|
+
};
|
|
10
|
+
export declare type Cursor = {
|
|
11
|
+
bitPosition: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
12
|
+
bytePosition: number;
|
|
13
|
+
};
|
|
14
|
+
export declare type Cursors = {
|
|
15
|
+
lastAlignmentStart: number;
|
|
16
|
+
coreBlock: Cursor;
|
|
17
|
+
externalBlocks: {
|
|
18
|
+
map: Map<any, any>;
|
|
19
|
+
getCursor: (contentId: number) => Cursor;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export default abstract class CramCodec<TResult extends DataType = DataType, TParameters = unknown> {
|
|
23
|
+
parameters: TParameters;
|
|
24
|
+
dataType: DataType;
|
|
25
|
+
constructor(parameters: TParameters, dataType: TResult);
|
|
26
|
+
abstract decode(slice: CramSlice, coreDataBlock: CramFileBlock, blocksByContentId: Record<number, CramFileBlock>, cursors: Cursors): DataTypeMapping[TResult];
|
|
6
27
|
}
|
|
@@ -1,47 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var errors_1 = require("../../errors");
|
|
4
|
-
var validDataTypes = {
|
|
5
|
-
int: true,
|
|
6
|
-
byte: true,
|
|
7
|
-
long: true,
|
|
8
|
-
byteArray: true,
|
|
9
|
-
byteArrayBlock: true,
|
|
10
|
-
};
|
|
11
3
|
// codec base class
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (parameters === void 0) { parameters = {}; }
|
|
4
|
+
class CramCodec {
|
|
5
|
+
constructor(parameters, dataType) {
|
|
15
6
|
this.parameters = parameters;
|
|
16
7
|
this.dataType = dataType;
|
|
17
|
-
if (!dataType) {
|
|
18
|
-
throw new TypeError('must provide a data type to codec constructor');
|
|
19
|
-
}
|
|
20
|
-
if (!validDataTypes[dataType]) {
|
|
21
|
-
throw new TypeError("invalid data type ".concat(dataType));
|
|
22
|
-
}
|
|
23
8
|
}
|
|
24
|
-
|
|
25
|
-
// }
|
|
26
|
-
CramCodec.prototype._getBits = function (data, cursor, numBits) {
|
|
27
|
-
var val = 0;
|
|
28
|
-
if (cursor.bytePosition + (7 - cursor.bitPosition + numBits) / 8 >
|
|
29
|
-
data.length) {
|
|
30
|
-
throw new errors_1.CramBufferOverrunError('read error during decoding. the file seems to be truncated.');
|
|
31
|
-
}
|
|
32
|
-
for (var dlen = numBits; dlen; dlen -= 1) {
|
|
33
|
-
// get the next `dlen` bits in the input, put them in val
|
|
34
|
-
val <<= 1;
|
|
35
|
-
val |= (data[cursor.bytePosition] >> cursor.bitPosition) & 1;
|
|
36
|
-
cursor.bitPosition -= 1;
|
|
37
|
-
if (cursor.bitPosition < 0) {
|
|
38
|
-
cursor.bytePosition += 1;
|
|
39
|
-
}
|
|
40
|
-
cursor.bitPosition &= 7;
|
|
41
|
-
}
|
|
42
|
-
return val;
|
|
43
|
-
};
|
|
44
|
-
return CramCodec;
|
|
45
|
-
}());
|
|
9
|
+
}
|
|
46
10
|
exports.default = CramCodec;
|
|
47
11
|
//# sourceMappingURL=_base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_base.js","sourceRoot":"","sources":["../../../src/cramFile/codecs/_base.
|
|
1
|
+
{"version":3,"file":"_base.js","sourceRoot":"","sources":["../../../src/cramFile/codecs/_base.ts"],"names":[],"mappings":";;AAyBA,mBAAmB;AACnB,MAA8B,SAAS;IAOrC,YAAY,UAAuB,EAAE,QAAiB;QACpD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;CAQF;AAlBD,4BAkBC"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import CramCodec, { Cursors } from './_base';
|
|
2
|
+
import CramSlice from '../slice';
|
|
3
|
+
import { CramFileBlock } from '../file';
|
|
4
|
+
import { BetaEncoding } from '../encoding';
|
|
5
|
+
export default class BetaCodec extends CramCodec<'int', BetaEncoding['parameters']> {
|
|
6
|
+
constructor(parameters: BetaEncoding['parameters'], dataType: 'int');
|
|
7
|
+
decode(slice: CramSlice, coreDataBlock: CramFileBlock, blocksByContentId: Record<number, CramFileBlock>, cursors: Cursors): number;
|
|
3
8
|
}
|
|
4
|
-
import CramCodec from "./_base";
|
|
@@ -1,40 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
4
|
};
|
|
20
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
throw new errors_1.CramUnimplementedError("".concat(_this.dataType, " decoding not yet implemented by BETA codec"));
|
|
6
|
+
const errors_1 = require("../../errors");
|
|
7
|
+
const _base_1 = __importDefault(require("./_base"));
|
|
8
|
+
const getBits_1 = require("./getBits");
|
|
9
|
+
class BetaCodec extends _base_1.default {
|
|
10
|
+
constructor(parameters, dataType) {
|
|
11
|
+
super(parameters, dataType);
|
|
12
|
+
if (this.dataType !== 'int') {
|
|
13
|
+
throw new errors_1.CramUnimplementedError(`${this.dataType} decoding not yet implemented by BETA codec`);
|
|
30
14
|
}
|
|
31
|
-
return _this;
|
|
32
15
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
}(_base_1.default));
|
|
16
|
+
decode(slice, coreDataBlock, blocksByContentId, cursors) {
|
|
17
|
+
const fromBits = (0, getBits_1.getBits)(coreDataBlock.content, cursors.coreBlock, this.parameters.length);
|
|
18
|
+
return fromBits - this.parameters.offset;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
39
21
|
exports.default = BetaCodec;
|
|
40
22
|
//# sourceMappingURL=beta.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beta.js","sourceRoot":"","sources":["../../../src/cramFile/codecs/beta.
|
|
1
|
+
{"version":3,"file":"beta.js","sourceRoot":"","sources":["../../../src/cramFile/codecs/beta.ts"],"names":[],"mappings":";;;;;AAAA,yCAAqD;AACrD,oDAA4C;AAC5C,uCAAmC;AAKnC,MAAqB,SAAU,SAAQ,eAGtC;IACC,YAAY,UAAsC,EAAE,QAAe;QACjE,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QAC3B,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE;YAC3B,MAAM,IAAI,+BAAsB,CAC9B,GAAG,IAAI,CAAC,QAAQ,6CAA6C,CAC9D,CAAA;SACF;IACH,CAAC;IAED,MAAM,CACJ,KAAgB,EAChB,aAA4B,EAC5B,iBAAgD,EAChD,OAAgB;QAEhB,MAAM,QAAQ,GAAG,IAAA,iBAAO,EACtB,aAAa,CAAC,OAAO,EACrB,OAAO,CAAC,SAAS,EACjB,IAAI,CAAC,UAAU,CAAC,MAAM,CACvB,CAAA;QACD,OAAO,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAA;IAC1C,CAAC;CACF;AA1BD,4BA0BC"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import CramCodec, { Cursors } from './_base';
|
|
2
|
+
import { ByteArrayLengthEncoding, CramEncoding } from '../encoding';
|
|
3
|
+
import CramSlice from '../slice';
|
|
4
|
+
import { CramFileBlock } from '../file';
|
|
5
|
+
import { DataType } from './dataSeriesTypes';
|
|
6
|
+
declare type CramCodecFactory = <TData extends DataType = DataType>(encodingData: CramEncoding, dataType: TData | 'ignore') => CramCodec<TData>;
|
|
7
|
+
export default class ByteArrayStopCodec extends CramCodec<'byteArray', ByteArrayLengthEncoding['parameters']> {
|
|
8
|
+
private instantiateCodec;
|
|
9
|
+
constructor(parameters: ByteArrayLengthEncoding['parameters'], dataType: 'byteArray', instantiateCodec: CramCodecFactory);
|
|
10
|
+
decode(slice: CramSlice, coreDataBlock: CramFileBlock, blocksByContentId: Record<number, CramFileBlock>, cursors: Cursors): Uint8Array;
|
|
11
|
+
_getLengthCodec(): CramCodec<"int", unknown>;
|
|
12
|
+
_getDataCodec(): CramCodec<"byte", unknown>;
|
|
7
13
|
}
|
|
8
|
-
|
|
14
|
+
export {};
|
|
@@ -1,60 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
4
|
};
|
|
20
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var _this = _super.call(this, parameters, dataType) || this;
|
|
28
|
-
_this.instantiateCodec = instantiateCodec;
|
|
6
|
+
const util_1 = require("../util");
|
|
7
|
+
const _base_1 = __importDefault(require("./_base"));
|
|
8
|
+
class ByteArrayStopCodec extends _base_1.default {
|
|
9
|
+
constructor(parameters, dataType, instantiateCodec) {
|
|
10
|
+
super(parameters, dataType);
|
|
11
|
+
this.instantiateCodec = instantiateCodec;
|
|
29
12
|
if (dataType !== 'byteArray') {
|
|
30
|
-
throw new TypeError(
|
|
13
|
+
throw new TypeError(`byteArrayLength does not support data type ${dataType}`);
|
|
31
14
|
}
|
|
32
|
-
return _this;
|
|
33
15
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
for (
|
|
16
|
+
decode(slice, coreDataBlock, blocksByContentId, cursors) {
|
|
17
|
+
const lengthCodec = this._getLengthCodec();
|
|
18
|
+
const arrayLength = lengthCodec.decode(slice, coreDataBlock, blocksByContentId, cursors);
|
|
19
|
+
const dataCodec = this._getDataCodec();
|
|
20
|
+
const data = new Uint8Array(arrayLength);
|
|
21
|
+
for (let i = 0; i < arrayLength; i += 1) {
|
|
40
22
|
data[i] = dataCodec.decode(slice, coreDataBlock, blocksByContentId, cursors);
|
|
41
23
|
}
|
|
42
24
|
return data;
|
|
43
|
-
}
|
|
25
|
+
}
|
|
44
26
|
// memoize
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
_getLengthCodec() {
|
|
28
|
+
const encodingParams = this.parameters.lengthsEncoding;
|
|
47
29
|
return this.instantiateCodec(encodingParams, 'int');
|
|
48
|
-
}
|
|
30
|
+
}
|
|
49
31
|
// memoize
|
|
50
|
-
|
|
51
|
-
|
|
32
|
+
_getDataCodec() {
|
|
33
|
+
const encodingParams = this.parameters.valuesEncoding;
|
|
52
34
|
return this.instantiateCodec(encodingParams, 'byte');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
}(_base_1.default));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
56
37
|
exports.default = ByteArrayStopCodec;
|
|
57
38
|
'_getLengthCodec _getDataCodec'
|
|
58
39
|
.split(' ')
|
|
59
|
-
.forEach(
|
|
40
|
+
.forEach(method => (0, util_1.tinyMemoize)(ByteArrayStopCodec, method));
|
|
60
41
|
//# sourceMappingURL=byteArrayLength.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"byteArrayLength.js","sourceRoot":"","sources":["../../../src/cramFile/codecs/byteArrayLength.
|
|
1
|
+
{"version":3,"file":"byteArrayLength.js","sourceRoot":"","sources":["../../../src/cramFile/codecs/byteArrayLength.ts"],"names":[],"mappings":";;;;;AAAA,kCAAqC;AAErC,oDAA4C;AAW5C,MAAqB,kBAAmB,SAAQ,eAG/C;IAGC,YACE,UAAiD,EACjD,QAAqB,EACrB,gBAAkC;QAElC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QAC3B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,QAAQ,KAAK,WAAW,EAAE;YAC5B,MAAM,IAAI,SAAS,CACjB,8CAA8C,QAAQ,EAAE,CACzD,CAAA;SACF;IACH,CAAC;IAED,MAAM,CACJ,KAAgB,EAChB,aAA4B,EAC5B,iBAAgD,EAChD,OAAgB;QAEhB,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,EAAE,CAAA;QAC1C,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,CACpC,KAAK,EACL,aAAa,EACb,iBAAiB,EACjB,OAAO,CACR,CAAA;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;QACtC,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAA;QACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,IAAI,CAAC,EAAE;YACvC,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,CACxB,KAAK,EACL,aAAa,EACb,iBAAiB,EACjB,OAAO,CACR,CAAA;SACF;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAED,UAAU;IACV,eAAe;QACb,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,eAAe,CAAA;QACtD,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAA;IACrD,CAAC;IAED,UAAU;IACV,aAAa;QACX,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,cAAc,CAAA;QACrD,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;IACtD,CAAC;CACF;AA3DD,qCA2DC;AAED,+BAA+B;KAC5B,KAAK,CAAC,GAAG,CAAC;KACV,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAA,kBAAW,EAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC,CAAA"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import CramCodec, { Cursor, Cursors } from './_base';
|
|
3
|
+
import CramSlice from '../slice';
|
|
4
|
+
import { CramFileBlock } from '../file';
|
|
5
|
+
import { ByteArrayStopCramEncoding } from '../encoding';
|
|
6
|
+
export default class ByteArrayStopCodec extends CramCodec<'byteArray', ByteArrayStopCramEncoding['parameters']> {
|
|
7
|
+
constructor(parameters: ByteArrayStopCramEncoding['parameters'], dataType: 'byteArray');
|
|
8
|
+
decode(slice: CramSlice, coreDataBlock: CramFileBlock, blocksByContentId: Record<number, CramFileBlock>, cursors: Cursors): Buffer;
|
|
9
|
+
_decodeByteArray(contentBlock: CramFileBlock, cursor: Cursor): Buffer;
|
|
5
10
|
}
|
|
6
|
-
import CramCodec from "./_base";
|
|
@@ -1,64 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
4
|
};
|
|
20
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
_this._decode = _this._decodeByteArray;
|
|
6
|
+
const errors_1 = require("../../errors");
|
|
7
|
+
const _base_1 = __importDefault(require("./_base"));
|
|
8
|
+
const getBits_1 = require("./getBits");
|
|
9
|
+
class ByteArrayStopCodec extends _base_1.default {
|
|
10
|
+
constructor(parameters, dataType) {
|
|
11
|
+
super(parameters, dataType);
|
|
12
|
+
if (dataType !== 'byteArray') {
|
|
13
|
+
throw new TypeError(`byteArrayStop codec does not support data type ${dataType}`);
|
|
30
14
|
}
|
|
31
|
-
else {
|
|
32
|
-
throw new TypeError("byteArrayStop codec does not support data type ".concat(dataType));
|
|
33
|
-
}
|
|
34
|
-
return _this;
|
|
35
15
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
16
|
+
decode(slice, coreDataBlock, blocksByContentId, cursors) {
|
|
17
|
+
const { blockContentId } = this.parameters;
|
|
18
|
+
const contentBlock = blocksByContentId[blockContentId];
|
|
39
19
|
if (!contentBlock) {
|
|
40
|
-
throw new errors_1.CramMalformedError(
|
|
20
|
+
throw new errors_1.CramMalformedError(`no block found with content ID ${blockContentId}`);
|
|
41
21
|
}
|
|
42
|
-
|
|
43
|
-
return this.
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
22
|
+
const cursor = cursors.externalBlocks.getCursor(blockContentId);
|
|
23
|
+
return this._decodeByteArray(contentBlock, cursor);
|
|
24
|
+
}
|
|
25
|
+
_decodeByteArray(contentBlock, cursor) {
|
|
26
|
+
const dataBuffer = contentBlock.content;
|
|
27
|
+
const { stopByte } = this.parameters;
|
|
48
28
|
// scan to the next stop byte
|
|
49
|
-
|
|
50
|
-
|
|
29
|
+
const startPosition = cursor.bytePosition;
|
|
30
|
+
let stopPosition = cursor.bytePosition;
|
|
51
31
|
while (dataBuffer[stopPosition] !== stopByte &&
|
|
52
32
|
stopPosition < dataBuffer.length) {
|
|
53
33
|
if (stopPosition === dataBuffer.length) {
|
|
54
|
-
throw new
|
|
34
|
+
throw new getBits_1.CramBufferOverrunError(`byteArrayStop reading beyond length of data buffer?`);
|
|
55
35
|
}
|
|
56
|
-
stopPosition
|
|
36
|
+
stopPosition = stopPosition + 1;
|
|
57
37
|
}
|
|
58
38
|
cursor.bytePosition = stopPosition + 1;
|
|
59
|
-
return dataBuffer.
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
}(_base_1.default));
|
|
39
|
+
return dataBuffer.subarray(startPosition, stopPosition);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
63
42
|
exports.default = ByteArrayStopCodec;
|
|
64
43
|
//# sourceMappingURL=byteArrayStop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"byteArrayStop.js","sourceRoot":"","sources":["../../../src/cramFile/codecs/byteArrayStop.
|
|
1
|
+
{"version":3,"file":"byteArrayStop.js","sourceRoot":"","sources":["../../../src/cramFile/codecs/byteArrayStop.ts"],"names":[],"mappings":";;;;;AAAA,yCAAiD;AAEjD,oDAAoD;AAIpD,uCAAkD;AAElD,MAAqB,kBAAmB,SAAQ,eAG/C;IACC,YACE,UAAmD,EACnD,QAAqB;QAErB,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QAC3B,IAAI,QAAQ,KAAK,WAAW,EAAE;YAC5B,MAAM,IAAI,SAAS,CACjB,kDAAkD,QAAQ,EAAE,CAC7D,CAAA;SACF;IACH,CAAC;IAED,MAAM,CACJ,KAAgB,EAChB,aAA4B,EAC5B,iBAAgD,EAChD,OAAgB;QAEhB,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,UAAU,CAAA;QAC1C,MAAM,YAAY,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAA;QACtD,IAAI,CAAC,YAAY,EAAE;YACjB,MAAM,IAAI,2BAAkB,CAC1B,kCAAkC,cAAc,EAAE,CACnD,CAAA;SACF;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;QAC/D,OAAO,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;IACpD,CAAC;IAED,gBAAgB,CAAC,YAA2B,EAAE,MAAc;QAC1D,MAAM,UAAU,GAAG,YAAY,CAAC,OAAO,CAAA;QACvC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,UAAU,CAAA;QACpC,6BAA6B;QAC7B,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,CAAA;QACzC,IAAI,YAAY,GAAG,MAAM,CAAC,YAAY,CAAA;QACtC,OACE,UAAU,CAAC,YAAY,CAAC,KAAK,QAAQ;YACrC,YAAY,GAAG,UAAU,CAAC,MAAM,EAChC;YACA,IAAI,YAAY,KAAK,UAAU,CAAC,MAAM,EAAE;gBACtC,MAAM,IAAI,gCAAsB,CAC9B,qDAAqD,CACtD,CAAA;aACF;YACD,YAAY,GAAG,YAAY,GAAG,CAAC,CAAA;SAChC;QACD,MAAM,CAAC,YAAY,GAAG,YAAY,GAAG,CAAC,CAAA;QACtC,OAAO,UAAU,CAAC,QAAQ,CAAC,aAAa,EAAE,YAAY,CAAC,CAAA;IACzD,CAAC;CACF;AArDD,qCAqDC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CramEncoding } from '../encoding';
|
|
2
|
+
export declare type DataType = 'int' | 'byte' | 'long' | 'byteArray';
|
|
3
|
+
export declare type DataSeriesEncodingKey = 'BF' | 'CF' | 'RI' | 'RL' | 'AP' | 'RG' | 'RN' | 'MF' | 'NS' | 'NP' | 'TS' | 'NF' | 'TL' | 'FN' | 'FC' | 'FP' | 'DL' | 'BB' | 'QQ' | 'BS' | 'IN' | 'RS' | 'PD' | 'HC' | 'SC' | 'MQ' | 'BA' | 'QS' | 'TC' | 'TN';
|
|
4
|
+
export declare type DataSeriesEncodingMap = Record<DataSeriesEncodingKey, CramEncoding>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataSeriesTypes.js","sourceRoot":"","sources":["../../../src/cramFile/codecs/dataSeriesTypes.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import CramCodec, { Cursor, Cursors } from './_base';
|
|
2
|
+
import CramSlice from '../slice';
|
|
3
|
+
import { CramFileBlock } from '../file';
|
|
4
|
+
import { ExternalCramEncoding } from '../encoding';
|
|
5
|
+
export default class ExternalCodec extends CramCodec<'int' | 'byte', ExternalCramEncoding['parameters']> {
|
|
6
|
+
private readonly _decodeData;
|
|
7
|
+
constructor(parameters: ExternalCramEncoding['parameters'], dataType: 'int' | 'byte');
|
|
8
|
+
decode(slice: CramSlice, coreDataBlock: CramFileBlock, blocksByContentId: Record<number, CramFileBlock>, cursors: Cursors): number;
|
|
9
|
+
_decodeInt(contentBlock: CramFileBlock, cursor: Cursor): number;
|
|
10
|
+
_decodeByte(contentBlock: CramFileBlock, cursor: Cursor): number;
|
|
6
11
|
}
|
|
7
|
-
import CramCodec from "./_base";
|
|
@@ -1,63 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
4
|
};
|
|
20
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
_this._decodeData = _this._decodeInt;
|
|
6
|
+
const errors_1 = require("../../errors");
|
|
7
|
+
const _base_1 = __importDefault(require("./_base"));
|
|
8
|
+
const util_1 = require("../util");
|
|
9
|
+
const getBits_1 = require("./getBits");
|
|
10
|
+
class ExternalCodec extends _base_1.default {
|
|
11
|
+
constructor(parameters, dataType) {
|
|
12
|
+
super(parameters, dataType);
|
|
13
|
+
if (this.dataType === 'int') {
|
|
14
|
+
this._decodeData = this._decodeInt;
|
|
31
15
|
}
|
|
32
|
-
else if (
|
|
33
|
-
|
|
16
|
+
else if (this.dataType === 'byte') {
|
|
17
|
+
this._decodeData = this._decodeByte;
|
|
34
18
|
}
|
|
35
19
|
else {
|
|
36
|
-
throw new errors_1.CramUnimplementedError(
|
|
20
|
+
throw new errors_1.CramUnimplementedError(`${this.dataType} decoding not yet implemented by EXTERNAL codec`);
|
|
37
21
|
}
|
|
38
|
-
return _this;
|
|
39
22
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
23
|
+
decode(slice, coreDataBlock, blocksByContentId, cursors) {
|
|
24
|
+
const { blockContentId } = this.parameters;
|
|
25
|
+
const contentBlock = blocksByContentId[blockContentId];
|
|
43
26
|
if (!contentBlock) {
|
|
44
|
-
throw new errors_1.CramMalformedError(
|
|
27
|
+
throw new errors_1.CramMalformedError(`no block found with content ID ${blockContentId}`);
|
|
45
28
|
}
|
|
46
|
-
|
|
29
|
+
const cursor = cursors.externalBlocks.getCursor(blockContentId);
|
|
47
30
|
return this._decodeData(contentBlock, cursor);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
cursor.bytePosition
|
|
31
|
+
}
|
|
32
|
+
_decodeInt(contentBlock, cursor) {
|
|
33
|
+
const [result, bytesRead] = (0, util_1.parseItf8)(contentBlock.content, cursor.bytePosition);
|
|
34
|
+
cursor.bytePosition = cursor.bytePosition + bytesRead;
|
|
52
35
|
return result;
|
|
53
|
-
}
|
|
54
|
-
|
|
36
|
+
}
|
|
37
|
+
_decodeByte(contentBlock, cursor) {
|
|
55
38
|
if (cursor.bytePosition >= contentBlock.content.length) {
|
|
56
|
-
throw new
|
|
39
|
+
throw new getBits_1.CramBufferOverrunError('attempted to read beyond end of block. this file seems truncated.');
|
|
57
40
|
}
|
|
58
41
|
return contentBlock.content[cursor.bytePosition++];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
}(_base_1.default));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
62
44
|
exports.default = ExternalCodec;
|
|
63
45
|
//# sourceMappingURL=external.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.js","sourceRoot":"","sources":["../../../src/cramFile/codecs/external.
|
|
1
|
+
{"version":3,"file":"external.js","sourceRoot":"","sources":["../../../src/cramFile/codecs/external.ts"],"names":[],"mappings":";;;;;AAAA,yCAAyE;AACzE,oDAAoD;AACpD,kCAAmC;AAGnC,uCAAkD;AAGlD,MAAqB,aAAc,SAAQ,eAG1C;IAMC,YACE,UAA8C,EAC9C,QAAwB;QAExB,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QAC3B,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE;YAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,CAAA;SACnC;aAAM,IAAI,IAAI,CAAC,QAAQ,KAAK,MAAM,EAAE;YACnC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;SACpC;aAAM;YACL,MAAM,IAAI,+BAAsB,CAC9B,GAAG,IAAI,CAAC,QAAQ,iDAAiD,CAClE,CAAA;SACF;IACH,CAAC;IAED,MAAM,CACJ,KAAgB,EAChB,aAA4B,EAC5B,iBAAgD,EAChD,OAAgB;QAEhB,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,UAAU,CAAA;QAC1C,MAAM,YAAY,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAA;QACtD,IAAI,CAAC,YAAY,EAAE;YACjB,MAAM,IAAI,2BAAkB,CAC1B,kCAAkC,cAAc,EAAE,CACnD,CAAA;SACF;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;QAC/D,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;IAC/C,CAAC;IAED,UAAU,CAAC,YAA2B,EAAE,MAAc;QACpD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAS,EACnC,YAAY,CAAC,OAAO,EACpB,MAAM,CAAC,YAAY,CACpB,CAAA;QACD,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,GAAG,SAAS,CAAA;QACrD,OAAO,MAAM,CAAA;IACf,CAAC;IAED,WAAW,CAAC,YAA2B,EAAE,MAAc;QACrD,IAAI,MAAM,CAAC,YAAY,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE;YACtD,MAAM,IAAI,gCAAsB,CAC9B,mEAAmE,CACpE,CAAA;SACF;QACD,OAAO,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAA;IACpD,CAAC;CACF;AA3DD,gCA2DC"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import CramCodec, { Cursors } from './_base';
|
|
2
|
+
import { GammaEncoding } from '../encoding';
|
|
3
|
+
import CramSlice from '../slice';
|
|
4
|
+
import { CramFileBlock } from '../file';
|
|
5
|
+
export default class GammaCodec extends CramCodec<'int', GammaEncoding['parameters']> {
|
|
6
|
+
constructor(parameters: GammaEncoding['parameters'], dataType: 'int');
|
|
7
|
+
decode(slice: CramSlice, coreDataBlock: CramFileBlock, blocksByContentId: Record<number, CramFileBlock>, cursors: Cursors): number;
|
|
3
8
|
}
|
|
4
|
-
import CramCodec from "./_base";
|