Skip to content

Commit

Permalink
Update devDeps
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Oct 13, 2023
1 parent c9c86be commit 2b00f16
Show file tree
Hide file tree
Showing 3 changed files with 1,322 additions and 1,023 deletions.
31 changes: 15 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,21 @@
"pako": "^1.0.11"
},
"devDependencies": {
"@types/es6-promisify": "^6.0.0",
"@types/jest": "^29.5.2",
"@types/long": "^4.0.1",
"@types/node": "^18.11.16",
"@types/pako": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.5.0",
"prettier": "^2.8.8",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.0",
"typescript": "^5.1.3"
"@types/es6-promisify": "^6.0.2",
"@types/jest": "^29.5.5",
"@types/node": "^20.8.5",
"@types/pako": "^2.0.1",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-prettier": "^5.0.1",
"jest": "^29.7.0",
"prettier": "^3.0.3",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2"
},
"publishConfig": {
"access": "public"
Expand Down
41 changes: 39 additions & 2 deletions src/bgzFilehandle.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { Buffer } from 'buffer'
import { LocalFile, GenericFilehandle } from 'generic-filehandle'
import {
LocalFile,
GenericFilehandle,
FilehandleOptions,
} from 'generic-filehandle'

// locals
import { unzip } from './unzip'
import GziIndex from './gziIndex'

export default class BgzFilehandle {
export default class BgzFilehandle implements GenericFilehandle {
filehandle: GenericFilehandle
gzi: GziIndex

Expand Down Expand Up @@ -131,4 +135,37 @@ export default class BgzFilehandle {

return { bytesRead, buffer: buf }
}

async close(): Promise<void> {
return
}

public async readFile(): Promise<Buffer>
public async readFile(options: BufferEncoding): Promise<string>
public async readFile<T extends undefined>(
options:
| Omit<FilehandleOptions, 'encoding'>
| (Omit<FilehandleOptions, 'encoding'> & { encoding: T }),
): Promise<Buffer>
public async readFile<T extends BufferEncoding>(
options: Omit<FilehandleOptions, 'encoding'> & { encoding: T },
): Promise<string>
readFile<T extends BufferEncoding>(
options: Omit<FilehandleOptions, 'encoding'> & { encoding: T },
): T extends BufferEncoding ? Promise<Buffer> : Promise<Buffer | string>
async readFile(options: FilehandleOptions | BufferEncoding = {}) {
const data = await this.filehandle.readFile()
const buf = await unzip(data)
let encoding
if (typeof options === 'string') {
encoding = options
} else {
encoding = options.encoding
}
if (encoding === 'utf8') {
return buf.toString('utf8')
} else {
return buf
}
}
}
Loading

0 comments on commit 2b00f16

Please sign in to comment.