Skip to content

Commit

Permalink
Throw error on catching memoized async error
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Mar 18, 2024
1 parent d5805ad commit 77f2e54
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
31 changes: 14 additions & 17 deletions src/craiIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class CraiIndex {
// because some .crai files can be pretty large.
let currentRecord: number[] = []
let currentString = ''
for (const charCode of uncompressedBuffer) {
for (const charCode of uncompressedBuffer) {
if (
(charCode >= 48 && charCode <= 57) /* 0-9 */ ||
(!currentString && charCode === 45) /* leading - */
Expand All @@ -100,22 +100,19 @@ export default class CraiIndex {
}
}

// if the file ends without a \n, we need to flush our buffers
if (currentString) {
currentRecord.push(Number.parseInt(currentString, 10))
}
if (currentRecord.length === 6) {
addRecordToIndex(index, currentRecord)
}

// sort each of them by start
Object.entries(index).forEach(([seqId, ent]) => {
index[seqId] = ent.sort(
(a, b) => a.start - b.start || a.span - b.span,
)
})
return index
})
// if the file ends without a \n, we need to flush our buffers
if (currentString) {
currentRecord.push(Number.parseInt(currentString, 10))
}
if (currentRecord.length === 6) {
addRecordToIndex(index, currentRecord)
}

// sort each of them by start
Object.entries(index).forEach(([seqId, ent]) => {
index[seqId] = ent.sort((a, b) => a.start - b.start || a.span - b.span)
})
return index
}

getIndex(opts?: { signal?: AbortSignal }) {
Expand Down
3 changes: 2 additions & 1 deletion src/cramFile/slice/decodeRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function parseTagData(tagType: string, buffer: Uint8Array) {
return new Int8Array(buffer.buffer)[0]
}
if (tagType === 'C') {
return buffer[0] as number
return buffer[0]
}
if (tagType === 'f') {
return new Float32Array(buffer.buffer)[0]
Expand Down Expand Up @@ -323,6 +323,7 @@ export default function decodeRecord(
blocksByContentId,
cursors,
)
// @ts-expect-error
tags[tagName] = parseTagData(tagType, tagData)
}

Expand Down
2 changes: 1 addition & 1 deletion src/cramFile/slice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export default class CramSlice {
constructor(
public container: CramContainer,
public containerPosition: number,
_unused: number,
public sliceSize: number,
) {
this.file = container.file
}
Expand Down
1 change: 1 addition & 0 deletions test/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ describe('CRAM reader', () => {
refSeqStart: 0,
})
const {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
content,
parsedContent: compressionBlockData,
...compressionBlock
Expand Down

0 comments on commit 77f2e54

Please sign in to comment.