Skip to content

Commit

Permalink
Couple more
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Dec 15, 2024
1 parent 57971d6 commit b4e53aa
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/cramFile/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export default class CramFile {
}
}

// can just stat this object like a filehandle
read(length: number, position: number) {
return this.file.read(length, position)
}
Expand Down Expand Up @@ -260,11 +259,6 @@ export default class CramFile {
const { majorVersion } = await this.getDefinition()
const sectionParsers = getSectionParsers(majorVersion)
const { cramBlockHeader } = sectionParsers
const { size: fileSize } = await this.file.stat()

if (position + cramBlockHeader.maxLength >= fileSize) {
return undefined
}

const buffer = await this.file.read(cramBlockHeader.maxLength, position)
return parseItem(buffer, cramBlockHeader.parser, 0, position)
Expand All @@ -282,16 +276,7 @@ export default class CramFile {
size = section.maxLength,
preReadBuffer?: Uint8Array,
) {
let buffer: Uint8Array
if (preReadBuffer) {
buffer = preReadBuffer
} else {
const { size: fileSize } = await this.file.stat()
if (position + size >= fileSize) {
return undefined
}
buffer = await this.file.read(size, position)
}
const buffer = preReadBuffer ?? (await this.file.read(size, position))
const data = parseItem(buffer, section.parser, 0, position)
if (data._size !== size) {
throw new CramMalformedError(
Expand Down

0 comments on commit b4e53aa

Please sign in to comment.