Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Aug 30, 2024
1 parent 8ae3cef commit 2264266
Show file tree
Hide file tree
Showing 6 changed files with 1,185 additions and 2,851 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"esm"
],
"scripts": {
"test": "vitest run",
"test": "vitest",
"lint": "eslint --report-unused-disable-directives --max-warnings 0",
"format": "prettier --write .",
"docs": "documentation readme --shallow src/indexedCramFile.ts --section=IndexedCramFile; documentation readme --shallow src/cramFile/file.ts --section=CramFile; documentation readme --shallow src/craiIndex.ts --section=CraiIndex; documentation readme --shallow errors.ts '--section=Exception Classes'; documentation readme --shallow src/cramFile/file.ts --section=CramFile; documentation readme --shallow src/cramFile/record.ts --section=CramRecord",
Expand All @@ -31,7 +31,7 @@
"build:es5": "tsc --target es2015 --module commonjs --outDir dist",
"build": "npm run build:esm && npm run build:es5",
"postbuild": "webpack",
"prepack": "npm test && npm run build && cp dist/errors.js errors.js",
"prepack": "npm test run && npm run build && cp dist/errors.js errors.js",
"postpublish": "rm errors.js",
"postversion": "git push --follow-tags"
},
Expand Down
10 changes: 4 additions & 6 deletions src/craiIndex.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import AbortablePromiseCache from '@gmod/abortable-promise-cache'
import QuickLRU from 'quick-lru'
import { unzip } from './unzip'
import { open } from './io'
import { CramMalformedError } from './errors'
Expand Down Expand Up @@ -68,9 +66,9 @@ export default class CraiIndex {
this.filehandle = open(args.url, args.path, args.filehandle)
}

async parseIndex(opts: { signal?: AbortSignal } = {}) {
async parseIndex() {
const index: ParsedIndex = {}
const uncompressedBuffer = maybeUnzip(await this.filehandle.readFile(opts))
const uncompressedBuffer = maybeUnzip(await this.filehandle.readFile())
if (
uncompressedBuffer.length > 4 &&
uncompressedBuffer.readUInt32LE(0) === BAI_MAGIC
Expand Down Expand Up @@ -122,9 +120,9 @@ export default class CraiIndex {
return index
}

getIndex(opts?: { signal?: AbortSignal }) {
getIndex() {
if (!this.parseIndexP) {
this.parseIndexP = this.parseIndex(opts).catch(e => {
this.parseIndexP = this.parseIndex().catch((e: unknown) => {
this.parseIndexP = undefined
throw e
})
Expand Down
7 changes: 3 additions & 4 deletions src/cramFile/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ export default class CramFile {
cacheSize: args.cacheSize ?? 20000,
}

// cache of features in a slice, keyed by the
// slice offset. caches all of the features in a slice, or none.
// the cache is actually used by the slice object, it's just
// kept here at the level of the file
// cache of features in a slice, keyed by the slice offset. caches all of
// the features in a slice, or none. the cache is actually used by the
// slice object, it's just kept here at the level of the file
this.featureCache = new QuickLRU({
maxSize: this.options.cacheSize,
})
Expand Down
8 changes: 4 additions & 4 deletions src/cramFile/slice/decodeRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function parseTagData(tagType: string, buffer: Uint8Array) {
return readNullTerminatedString(buffer)
}
if (tagType === 'A') {
return String.fromCharCode(buffer[0])
return String.fromCharCode(buffer[0]!)
}
if (tagType === 'I') {
return new Uint32Array(buffer.buffer)[0]
Expand All @@ -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 @@ -312,7 +312,6 @@ export default function decodeRecord(
// TN = tag names
const TN = compressionScheme.getTagNames(TLindex)!
const ntags = TN.length

for (let i = 0; i < ntags; i += 1) {
const tagId = TN[i]!
const tagName = tagId.slice(0, 2)
Expand All @@ -321,7 +320,8 @@ export default function decodeRecord(
const tagData = compressionScheme
.getCodecForTag(tagId)
.decode(slice, coreDataBlock, blocksByContentId, cursors)
tags[tagName] = parseTagData(tagType, tagData)
tags[tagName] =
typeof tagData === 'number' ? tagData : parseTagData(tagType, tagData)
}

let readFeatures: ReadFeature[] | undefined
Expand Down
1 change: 0 additions & 1 deletion test/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ describe('CRAM reader', () => {
refSeqStart: 0,
})
const {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
content,
parsedContent: compressionBlockData,
...compressionBlock
Expand Down
Loading

0 comments on commit 2264266

Please sign in to comment.