@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
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CramSizeLimitError, CramUnimplementedError } from './errors'
|
|
2
2
|
|
|
3
3
|
import CramFile from './cramFile'
|
|
4
|
+
import CramRecord from './cramFile/record'
|
|
5
|
+
import { SeqFetch } from './cramFile/file'
|
|
6
|
+
import { Filehandle } from './cramFile/filehandle'
|
|
7
|
+
import { Slice } from './craiIndex'
|
|
8
|
+
|
|
9
|
+
export type CramFileSource = {
|
|
10
|
+
cramFilehandle?: Filehandle
|
|
11
|
+
cramUrl?: string
|
|
12
|
+
cramPath?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type CramIndexLike = {
|
|
16
|
+
getEntriesForRange: (
|
|
17
|
+
seqId: number,
|
|
18
|
+
start: number,
|
|
19
|
+
end: number,
|
|
20
|
+
) => Promise<Slice[]>
|
|
21
|
+
hasDataForReferenceSequence: (seqId: number) => Promise<boolean>
|
|
22
|
+
}
|
|
4
23
|
|
|
5
24
|
export default class IndexedCramFile {
|
|
25
|
+
public cram: CramFile
|
|
26
|
+
public index: CramIndexLike
|
|
27
|
+
private fetchSizeLimit: number
|
|
28
|
+
|
|
6
29
|
/**
|
|
7
30
|
*
|
|
8
31
|
* @param {object} args
|
|
@@ -13,7 +36,20 @@ export default class IndexedCramFile {
|
|
|
13
36
|
* @param {boolean} [args.checkSequenceMD5] - default true. if false, disables verifying the MD5
|
|
14
37
|
* checksum of the reference sequence underlying a slice. In some applications, this check can cause an inconvenient amount (many megabases) of sequences to be fetched.
|
|
15
38
|
*/
|
|
16
|
-
constructor(
|
|
39
|
+
constructor(
|
|
40
|
+
args: {
|
|
41
|
+
index: CramIndexLike
|
|
42
|
+
fetchSizeLimit?: number
|
|
43
|
+
} & (
|
|
44
|
+
| { cram: CramFile }
|
|
45
|
+
| ({
|
|
46
|
+
cram?: undefined
|
|
47
|
+
seqFetch: SeqFetch
|
|
48
|
+
checkSequenceMD5: boolean
|
|
49
|
+
cacheSize?: number
|
|
50
|
+
} & CramFileSource)
|
|
51
|
+
),
|
|
52
|
+
) {
|
|
17
53
|
// { cram, index, seqFetch /* fasta, fastaIndex */ }) {
|
|
18
54
|
if (args.cram) {
|
|
19
55
|
this.cram = args.cram
|
|
@@ -47,7 +83,16 @@ export default class IndexedCramFile {
|
|
|
47
83
|
* @param {number} end end of the range of interest. 1-based closed coordinates.
|
|
48
84
|
* @returns {Promise[Array[CramRecord]]}
|
|
49
85
|
*/
|
|
50
|
-
async getRecordsForRange(
|
|
86
|
+
async getRecordsForRange(
|
|
87
|
+
seq: number,
|
|
88
|
+
start: number,
|
|
89
|
+
end: number,
|
|
90
|
+
opts: {
|
|
91
|
+
viewAsPairs?: boolean
|
|
92
|
+
pairAcrossChr?: boolean
|
|
93
|
+
maxInsertSize?: number
|
|
94
|
+
} = {},
|
|
95
|
+
) {
|
|
51
96
|
opts.viewAsPairs = opts.viewAsPairs || false
|
|
52
97
|
opts.pairAcrossChr = opts.pairAcrossChr || false
|
|
53
98
|
opts.maxInsertSize = opts.maxInsertSize || 200000
|
|
@@ -70,20 +115,24 @@ export default class IndexedCramFile {
|
|
|
70
115
|
// TODO: do we need to merge or de-duplicate the blocks?
|
|
71
116
|
|
|
72
117
|
// fetch all the slices and parse the feature data
|
|
73
|
-
const filter = feature =>
|
|
118
|
+
const filter = (feature: CramRecord) =>
|
|
74
119
|
feature.sequenceId === seq &&
|
|
75
120
|
feature.alignmentStart <= end &&
|
|
121
|
+
feature.lengthOnRef !== undefined &&
|
|
76
122
|
feature.alignmentStart + feature.lengthOnRef - 1 >= start
|
|
77
123
|
const sliceResults = await Promise.all(
|
|
78
124
|
slices.map(slice => this.getRecordsInSlice(slice, filter)),
|
|
79
125
|
)
|
|
80
126
|
|
|
81
|
-
let ret = Array.prototype.concat(...sliceResults)
|
|
127
|
+
let ret: CramRecord[] = Array.prototype.concat(...sliceResults)
|
|
82
128
|
if (opts.viewAsPairs) {
|
|
83
|
-
const readNames = {}
|
|
84
|
-
const readIds = {}
|
|
129
|
+
const readNames: Record<string, number> = {}
|
|
130
|
+
const readIds: Record<string, number> = {}
|
|
85
131
|
for (let i = 0; i < ret.length; i += 1) {
|
|
86
132
|
const name = ret[i].readName
|
|
133
|
+
if (name === undefined) {
|
|
134
|
+
throw new Error()
|
|
135
|
+
}
|
|
87
136
|
const id = ret[i].uniqueId
|
|
88
137
|
if (!readNames[name]) {
|
|
89
138
|
readNames[name] = 0
|
|
@@ -91,7 +140,7 @@ export default class IndexedCramFile {
|
|
|
91
140
|
readNames[name] += 1
|
|
92
141
|
readIds[id] = 1
|
|
93
142
|
}
|
|
94
|
-
const unmatedPairs = {}
|
|
143
|
+
const unmatedPairs: Record<string, boolean> = {}
|
|
95
144
|
Object.entries(readNames).forEach(([k, v]) => {
|
|
96
145
|
if (v === 1) {
|
|
97
146
|
unmatedPairs[k] = true
|
|
@@ -99,18 +148,22 @@ export default class IndexedCramFile {
|
|
|
99
148
|
})
|
|
100
149
|
const matePromises = []
|
|
101
150
|
for (let i = 0; i < ret.length; i += 1) {
|
|
102
|
-
const
|
|
151
|
+
const cramRecord = ret[i]
|
|
152
|
+
const name = cramRecord.readName
|
|
153
|
+
if (name === undefined) {
|
|
154
|
+
throw new Error()
|
|
155
|
+
}
|
|
103
156
|
if (
|
|
104
157
|
unmatedPairs[name] &&
|
|
105
|
-
|
|
106
|
-
(
|
|
107
|
-
Math.abs(
|
|
158
|
+
cramRecord.mate &&
|
|
159
|
+
(cramRecord.mate.sequenceId === seqId || opts.pairAcrossChr) &&
|
|
160
|
+
Math.abs(cramRecord.alignmentStart - cramRecord.mate.alignmentStart) <
|
|
108
161
|
opts.maxInsertSize
|
|
109
162
|
) {
|
|
110
163
|
const mateSlices = this.index.getEntriesForRange(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
164
|
+
cramRecord.mate.sequenceId,
|
|
165
|
+
cramRecord.mate.alignmentStart,
|
|
166
|
+
cramRecord.mate.alignmentStart + 1,
|
|
114
167
|
)
|
|
115
168
|
matePromises.push(mateSlices)
|
|
116
169
|
}
|
|
@@ -129,7 +182,7 @@ export default class IndexedCramFile {
|
|
|
129
182
|
)
|
|
130
183
|
|
|
131
184
|
const mateRecordPromises = []
|
|
132
|
-
const mateFeatPromises = []
|
|
185
|
+
const mateFeatPromises: Array<Promise<CramRecord[]>> = []
|
|
133
186
|
|
|
134
187
|
const mateTotalSize = mateChunks
|
|
135
188
|
.map(s => s.sliceBytes)
|
|
@@ -151,6 +204,9 @@ export default class IndexedCramFile {
|
|
|
151
204
|
const mateRecs = []
|
|
152
205
|
for (let i = 0; i < feats.length; i += 1) {
|
|
153
206
|
const feature = feats[i]
|
|
207
|
+
if (feature.readName === undefined) {
|
|
208
|
+
throw new Error()
|
|
209
|
+
}
|
|
154
210
|
if (unmatedPairs[feature.readName] && !readIds[feature.uniqueId]) {
|
|
155
211
|
mateRecs.push(feature)
|
|
156
212
|
}
|
|
@@ -171,8 +227,12 @@ export default class IndexedCramFile {
|
|
|
171
227
|
}
|
|
172
228
|
|
|
173
229
|
getRecordsInSlice(
|
|
174
|
-
{
|
|
175
|
-
|
|
230
|
+
{
|
|
231
|
+
containerStart,
|
|
232
|
+
sliceStart,
|
|
233
|
+
sliceBytes,
|
|
234
|
+
}: { containerStart: number; sliceStart: number; sliceBytes: number },
|
|
235
|
+
filterFunction: (r: CramRecord) => boolean,
|
|
176
236
|
) {
|
|
177
237
|
const container = this.cram.getContainerAtPosition(containerStart)
|
|
178
238
|
const slice = container.getSlice(sliceStart, sliceBytes)
|
|
@@ -185,7 +245,7 @@ export default class IndexedCramFile {
|
|
|
185
245
|
* @returns {Promise} true if the CRAM file contains data for the given
|
|
186
246
|
* reference sequence numerical ID
|
|
187
247
|
*/
|
|
188
|
-
hasDataForReferenceSequence(seqId) {
|
|
248
|
+
hasDataForReferenceSequence(seqId: number) {
|
|
189
249
|
return this.index.hasDataForReferenceSequence(seqId)
|
|
190
250
|
}
|
|
191
251
|
}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import url from 'url'
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { ensureNotNullish } from '../typescript'
|
|
3
|
+
import { Filehandle } from '../cramFile/filehandle'
|
|
4
|
+
import { LocalFile, RemoteFile } from 'generic-filehandle'
|
|
4
5
|
|
|
5
|
-
function fromUrl(source) {
|
|
6
|
+
function fromUrl(source: string) {
|
|
6
7
|
const { protocol, pathname } = url.parse(source)
|
|
7
8
|
if (protocol === 'file:') {
|
|
8
|
-
return new LocalFile(unescape(pathname))
|
|
9
|
+
return new LocalFile(unescape(ensureNotNullish(pathname)))
|
|
9
10
|
}
|
|
10
11
|
return new RemoteFile(source)
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
function open(
|
|
14
|
+
function open(
|
|
15
|
+
maybeUrl?: string,
|
|
16
|
+
maybePath?: string,
|
|
17
|
+
maybeFilehandle?: Filehandle,
|
|
18
|
+
): Filehandle {
|
|
14
19
|
if (maybeFilehandle) {
|
|
15
20
|
return maybeFilehandle
|
|
16
21
|
}
|
package/src/{sam.js → sam.ts}
RENAMED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type HeaderDataItem = {
|
|
2
|
+
tag: string
|
|
3
|
+
data: Array<{ tag: string; value: string }>
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function parseHeaderText(text: string): HeaderDataItem[] {
|
|
2
7
|
const lines = text.split(/\r?\n/)
|
|
3
|
-
const data = []
|
|
8
|
+
const data: HeaderDataItem[] = []
|
|
4
9
|
lines.forEach(line => {
|
|
5
10
|
const [tag, ...fields] = line.split(/\t/)
|
|
6
11
|
const parsedFields = fields.map(f => {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function ensureNotNullish<T>(x: T | null | undefined): T {
|
|
2
|
+
if (x === null || x === undefined) {
|
|
3
|
+
throw new Error('Value must not be nullish.')
|
|
4
|
+
}
|
|
5
|
+
return x
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type TupleOf<T, N extends number> = N extends N
|
|
9
|
+
? number extends N
|
|
10
|
+
? T[]
|
|
11
|
+
: _TupleOf<T, N, []>
|
|
12
|
+
: never
|
|
13
|
+
export type _TupleOf<
|
|
14
|
+
T,
|
|
15
|
+
N extends number,
|
|
16
|
+
R extends unknown[],
|
|
17
|
+
> = R['length'] extends N ? R : _TupleOf<T, N, [T, ...R]>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
declare module '@gmod/binary-parser' {
|
|
2
|
+
export type Options = {
|
|
3
|
+
stripNull?: boolean
|
|
4
|
+
formatter?: (item: any) => any
|
|
5
|
+
length?: number | string | ((this: { $parent: unknown }) => void)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class Parser<T = unknown> {
|
|
9
|
+
public static start<TStart>(): Parser<TStart>
|
|
10
|
+
|
|
11
|
+
public uint8(name?: string | null, options?: Options): Parser
|
|
12
|
+
|
|
13
|
+
public itf8(name?: string | null, options?: Options): Parser
|
|
14
|
+
|
|
15
|
+
public ltf8(name?: string | null, options?: Options): Parser
|
|
16
|
+
|
|
17
|
+
public uint32(name?: string | null, options?: Options): Parser
|
|
18
|
+
|
|
19
|
+
public int32(name?: string | null, options?: Options): Parser
|
|
20
|
+
|
|
21
|
+
public buffer(name?: string | null, options?: Options): Parser
|
|
22
|
+
|
|
23
|
+
public string(name?: string | null, options?: Options): Parser
|
|
24
|
+
|
|
25
|
+
public namely(name: string): Parser
|
|
26
|
+
|
|
27
|
+
public nest(
|
|
28
|
+
name?: string | null,
|
|
29
|
+
options?: { type: Parser | string } & Options,
|
|
30
|
+
): Parser
|
|
31
|
+
|
|
32
|
+
public choice(
|
|
33
|
+
name?: string | null,
|
|
34
|
+
options?: { tag: string; choices: any } & Options,
|
|
35
|
+
): Parser
|
|
36
|
+
|
|
37
|
+
public array(
|
|
38
|
+
name?: string | null,
|
|
39
|
+
options?: { type: string | Parser } & Options,
|
|
40
|
+
): Parser
|
|
41
|
+
|
|
42
|
+
parse(bytes: Buffer): { result: T; offset: number }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare module '@jkbonfield/htscodecs' {
|
|
2
|
+
function r4x16_uncompress(input: Buffer, output: Buffer): void
|
|
3
|
+
function arith_uncompress(input: Buffer, output: Buffer): void
|
|
4
|
+
function fqzcomp_uncompress(input: Buffer, output: Buffer): void
|
|
5
|
+
function tok3_uncompress(input: Buffer, output: Buffer): void
|
|
6
|
+
}
|
package/dist/io/bufferCache.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export default class BufferCache {
|
|
2
|
-
constructor({ fetch, size, chunkSize }: {
|
|
3
|
-
fetch: any;
|
|
4
|
-
size?: number | undefined;
|
|
5
|
-
chunkSize?: number | undefined;
|
|
6
|
-
});
|
|
7
|
-
fetch: any;
|
|
8
|
-
chunkSize: number;
|
|
9
|
-
lruCache: any;
|
|
10
|
-
get(outputBuffer: any, offset: any, length: any, position: any): Promise<void>;
|
|
11
|
-
_getChunk(chunkNumber: any): any;
|
|
12
|
-
}
|
package/dist/io/bufferCache.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var quick_lru_1 = __importDefault(require("quick-lru"));
|
|
43
|
-
var BufferCache = /** @class */ (function () {
|
|
44
|
-
function BufferCache(_a) {
|
|
45
|
-
var fetch = _a.fetch, _b = _a.size, size = _b === void 0 ? 10000000 : _b, _c = _a.chunkSize, chunkSize = _c === void 0 ? 32768 : _c;
|
|
46
|
-
if (!fetch) {
|
|
47
|
-
throw new Error('fetch function required');
|
|
48
|
-
}
|
|
49
|
-
this.fetch = fetch;
|
|
50
|
-
this.chunkSize = chunkSize;
|
|
51
|
-
this.lruCache = new quick_lru_1.default({ maxSize: Math.floor(size / chunkSize) });
|
|
52
|
-
}
|
|
53
|
-
BufferCache.prototype.get = function (outputBuffer, offset, length, position) {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
55
|
-
var firstChunk, lastChunk, fetches, _loop_1, this_1, chunk, chunks, chunksOffset;
|
|
56
|
-
var _this = this;
|
|
57
|
-
return __generator(this, function (_a) {
|
|
58
|
-
switch (_a.label) {
|
|
59
|
-
case 0:
|
|
60
|
-
if (outputBuffer.length < offset + length) {
|
|
61
|
-
throw new Error('output buffer not big enough for request');
|
|
62
|
-
}
|
|
63
|
-
firstChunk = Math.floor(position / this.chunkSize);
|
|
64
|
-
lastChunk = Math.floor((position + length) / this.chunkSize);
|
|
65
|
-
fetches = new Array(lastChunk - firstChunk + 1);
|
|
66
|
-
_loop_1 = function (chunk) {
|
|
67
|
-
fetches[chunk - firstChunk] = this_1._getChunk(chunk).then(function (data) { return ({
|
|
68
|
-
data: data,
|
|
69
|
-
chunkNumber: chunk,
|
|
70
|
-
}); });
|
|
71
|
-
};
|
|
72
|
-
this_1 = this;
|
|
73
|
-
for (chunk = firstChunk; chunk <= lastChunk; chunk += 1) {
|
|
74
|
-
_loop_1(chunk);
|
|
75
|
-
}
|
|
76
|
-
return [4 /*yield*/, Promise.all(fetches)];
|
|
77
|
-
case 1:
|
|
78
|
-
chunks = _a.sent();
|
|
79
|
-
chunksOffset = position - chunks[0].chunkNumber * this.chunkSize;
|
|
80
|
-
chunks.forEach(function (_a) {
|
|
81
|
-
var data = _a.data, chunkNumber = _a.chunkNumber;
|
|
82
|
-
var chunkPositionStart = chunkNumber * _this.chunkSize;
|
|
83
|
-
var copyStart = 0;
|
|
84
|
-
var copyEnd = _this.chunkSize;
|
|
85
|
-
var copyOffset = offset + (chunkNumber - firstChunk) * _this.chunkSize - chunksOffset;
|
|
86
|
-
if (chunkNumber === firstChunk) {
|
|
87
|
-
copyOffset = offset;
|
|
88
|
-
copyStart = chunksOffset;
|
|
89
|
-
}
|
|
90
|
-
if (chunkNumber === lastChunk) {
|
|
91
|
-
copyEnd = position + length - chunkPositionStart;
|
|
92
|
-
}
|
|
93
|
-
data.copy(outputBuffer, copyOffset, copyStart, copyEnd);
|
|
94
|
-
});
|
|
95
|
-
return [2 /*return*/];
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
BufferCache.prototype._getChunk = function (chunkNumber) {
|
|
101
|
-
var cachedPromise = this.lruCache.get(chunkNumber);
|
|
102
|
-
if (cachedPromise) {
|
|
103
|
-
return cachedPromise;
|
|
104
|
-
}
|
|
105
|
-
var freshPromise = this.fetch(chunkNumber * this.chunkSize, this.chunkSize);
|
|
106
|
-
this.lruCache.set(chunkNumber, freshPromise);
|
|
107
|
-
return freshPromise;
|
|
108
|
-
};
|
|
109
|
-
return BufferCache;
|
|
110
|
-
}());
|
|
111
|
-
exports.default = BufferCache;
|
|
112
|
-
//# sourceMappingURL=bufferCache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bufferCache.js","sourceRoot":"","sources":["../../src/io/bufferCache.js"],"names":[],"mappings":"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"}
|
package/dist/io/localFile.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export default class LocalFile {
|
|
2
|
-
constructor(source: any);
|
|
3
|
-
position: number;
|
|
4
|
-
filename: any;
|
|
5
|
-
fd: any;
|
|
6
|
-
read(buffer: any, offset: number | undefined, length: any, position: any): Promise<any>;
|
|
7
|
-
readFile(): Promise<any>;
|
|
8
|
-
stat(): Promise<any>;
|
|
9
|
-
_stat: any;
|
|
10
|
-
}
|
package/dist/io/localFile.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var es6_promisify_1 = require("es6-promisify");
|
|
43
|
-
var fs_1 = __importDefault(require("fs"));
|
|
44
|
-
var fsOpen = fs_1.default && (0, es6_promisify_1.promisify)(fs_1.default.open);
|
|
45
|
-
var fsRead = fs_1.default && (0, es6_promisify_1.promisify)(fs_1.default.read);
|
|
46
|
-
var fsFStat = fs_1.default && (0, es6_promisify_1.promisify)(fs_1.default.fstat);
|
|
47
|
-
var fsReadFile = fs_1.default && (0, es6_promisify_1.promisify)(fs_1.default.readFile);
|
|
48
|
-
var LocalFile = /** @class */ (function () {
|
|
49
|
-
function LocalFile(source) {
|
|
50
|
-
this.position = 0;
|
|
51
|
-
this.filename = source;
|
|
52
|
-
this.fd = fsOpen(this.filename, 'r');
|
|
53
|
-
}
|
|
54
|
-
LocalFile.prototype.read = function (buffer, offset, length, position) {
|
|
55
|
-
if (offset === void 0) { offset = 0; }
|
|
56
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var readPosition, _a;
|
|
58
|
-
return __generator(this, function (_b) {
|
|
59
|
-
switch (_b.label) {
|
|
60
|
-
case 0:
|
|
61
|
-
readPosition = position;
|
|
62
|
-
if (readPosition === null) {
|
|
63
|
-
readPosition = this.position;
|
|
64
|
-
this.position += length;
|
|
65
|
-
}
|
|
66
|
-
_a = fsRead;
|
|
67
|
-
return [4 /*yield*/, this.fd];
|
|
68
|
-
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent(), buffer, offset, length, position])];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
LocalFile.prototype.readFile = function () {
|
|
74
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
-
var _a;
|
|
76
|
-
return __generator(this, function (_b) {
|
|
77
|
-
switch (_b.label) {
|
|
78
|
-
case 0:
|
|
79
|
-
_a = fsReadFile;
|
|
80
|
-
return [4 /*yield*/, this.fd];
|
|
81
|
-
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
LocalFile.prototype.stat = function () {
|
|
87
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
-
var _a, _b;
|
|
89
|
-
return __generator(this, function (_c) {
|
|
90
|
-
switch (_c.label) {
|
|
91
|
-
case 0:
|
|
92
|
-
if (!!this._stat) return [3 /*break*/, 3];
|
|
93
|
-
_a = this;
|
|
94
|
-
_b = fsFStat;
|
|
95
|
-
return [4 /*yield*/, this.fd];
|
|
96
|
-
case 1: return [4 /*yield*/, _b.apply(void 0, [_c.sent()])];
|
|
97
|
-
case 2:
|
|
98
|
-
_a._stat = _c.sent();
|
|
99
|
-
_c.label = 3;
|
|
100
|
-
case 3: return [2 /*return*/, this._stat];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
return LocalFile;
|
|
106
|
-
}());
|
|
107
|
-
exports.default = LocalFile;
|
|
108
|
-
//# sourceMappingURL=localFile.js.map
|
package/dist/io/localFile.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localFile.js","sourceRoot":"","sources":["../../src/io/localFile.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAyC;AACzC,0CAAmB;AAEnB,IAAM,MAAM,GAAG,YAAE,IAAI,IAAA,yBAAS,EAAC,YAAE,CAAC,IAAI,CAAC,CAAA;AACvC,IAAM,MAAM,GAAG,YAAE,IAAI,IAAA,yBAAS,EAAC,YAAE,CAAC,IAAI,CAAC,CAAA;AACvC,IAAM,OAAO,GAAG,YAAE,IAAI,IAAA,yBAAS,EAAC,YAAE,CAAC,KAAK,CAAC,CAAA;AACzC,IAAM,UAAU,GAAG,YAAE,IAAI,IAAA,yBAAS,EAAC,YAAE,CAAC,QAAQ,CAAC,CAAA;AAE/C;IACE,mBAAY,MAAM;QAChB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAA;QACjB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAA;QACtB,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IACtC,CAAC;IAEK,wBAAI,GAAV,UAAW,MAAM,EAAE,MAAU,EAAE,MAAM,EAAE,QAAQ;QAA5B,uBAAA,EAAA,UAAU;;;;;;wBACvB,YAAY,GAAG,QAAQ,CAAA;wBAC3B,IAAI,YAAY,KAAK,IAAI,EAAE;4BACzB,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAA;4BAC5B,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAA;yBACxB;wBACM,KAAA,MAAM,CAAA;wBAAC,qBAAM,IAAI,CAAC,EAAE,EAAA;4BAA3B,sBAAO,kBAAO,SAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAC,EAAA;;;;KAC/D;IAEK,4BAAQ,GAAd;;;;;;wBACS,KAAA,UAAU,CAAA;wBAAC,qBAAM,IAAI,CAAC,EAAE,EAAA;4BAA/B,sBAAO,kBAAW,SAAa,EAAC,EAAA;;;;KACjC;IAEK,wBAAI,GAAV;;;;;;6BACM,CAAC,IAAI,CAAC,KAAK,EAAX,wBAAW;wBACb,KAAA,IAAI,CAAA;wBAAe,KAAA,OAAO,CAAA;wBAAC,qBAAM,IAAI,CAAC,EAAE,EAAA;4BAA3B,qBAAM,kBAAQ,SAAa,EAAC,EAAA;;wBAAzC,GAAK,KAAK,GAAG,SAA4B,CAAA;;4BAE3C,sBAAO,IAAI,CAAC,KAAK,EAAA;;;;KAClB;IACH,gBAAC;AAAD,CAAC,AA1BD,IA0BC"}
|
package/dist/io/remoteFile.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export default class RemoteFile {
|
|
2
|
-
constructor(source: any);
|
|
3
|
-
position: number;
|
|
4
|
-
url: any;
|
|
5
|
-
cache: BufferCache;
|
|
6
|
-
_fetch(position: any, length: any): Promise<Buffer>;
|
|
7
|
-
_stat: {
|
|
8
|
-
size: number;
|
|
9
|
-
} | undefined;
|
|
10
|
-
read(buffer: any, offset?: number, length?: number, position?: number): Promise<void>;
|
|
11
|
-
readFile(): Promise<Buffer>;
|
|
12
|
-
stat(): Promise<{
|
|
13
|
-
size: number;
|
|
14
|
-
}>;
|
|
15
|
-
}
|
|
16
|
-
import BufferCache from "./bufferCache";
|