
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@gmod/bgzf-filehandle
Advanced tools
read from a compressed bgzip file (with .gzi) as if it were uncompressed
Transparently read indexed block-gzipped (BGZF) files, such as those created by bgzip, using coordinates from the uncompressed file. The module is used in @gmod/indexedfasta to read bgzip-indexed fasta files (with gzi index, fai index, and fa).
Users can also use the unzip
function to unzip bgzip files whole (which pako
has trouble with natively)
You can also use the unzipChunkSlice
function to unzip ranges given by BAI or
TBI files for BAM or tabix file formats (which are bgzip based).
The unzip
utility function properly decompresses BGZF chunks in both node and
the browser, using pako
when running in the browser and native zlib
when
running in node.
$ npm install --save @gmod/bgzf-filehandle
const { BgzfFilehandle, unzip, unzipChunk } = require('@gmod/bgzf-filehandle')
const f = new BgzfFilehandle({ path: 'path/to/my_file.gz' })
// assumes a .gzi index exists at path/to/my_file.gz.gzi. can also
// pass `gziPath` to set it explicitly. Can also pass filehandles
// for the files: `filehandle` and `gziFilehandle`
// supports a subset of the NodeJS v10 filehandle API. currently
// just read() and stat()
const myBuf = Buffer.alloc(300)
await f.read(myBuf, 0, 300, 23234)
// now use the data in the buffer
const { size } = f.stat() // stat gives the size as if the file were uncompressed
// unzip takes a buffer and returns a promise for a new buffer
const chunkDataBuffer = readDirectlyFromFile(someFile, 123, 456)
const unzippedBuffer = await unzip(chunkDataBuffer)
// unzipChunk takes a buffer and returns a decompressed buffer plus the offsets
// of the block boundaries in the bgzip file in compressed (cpositions) and
// decompressed (dpositions) coordinates
// you can ignore dpositions/cpositions if your code doesn't care about stable feature IDs
const { buffer, dpositions, cpositions } = await unzipChunk(chunkDataBuffer)
// similar to the above unzipChunk but takes extra chunk argument and trims
// off (0,chunk.minv.dataPosition) and (chunk.maxv.dataPosition)
// used especially for generating stable feature IDs across chunk boundaries
// normal unzip or unzipChunk can be used if this is not important
const { buffer, dpositions, cpositions } = await unzipChunkSlice(
chunkDataBuffer,
chunk,
)
This package was written with funding from the NHGRI as part of the JBrowse project. If you use it in an academic project that you publish, please cite the most recent JBrowse paper, which will be linked from jbrowse.org.
MIT © Robert Buels
This repo is unable to be upgraded to pako v2 at this time due to removal of the Z_SYNC_FLUSH capability. It will produce "invalid distance too far back" errors with pako v2
FAQs
read from a compressed bgzip file (with .gzi) as if it were uncompressed
The npm package @gmod/bgzf-filehandle receives a total of 1,867 weekly downloads. As such, @gmod/bgzf-filehandle popularity was classified as popular.
We found that @gmod/bgzf-filehandle demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.