npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gmod/tabix

v3.4.2

Published

Read Tabix-indexed files, supports both .tbi and .csi indexes

Readme

@gmod/tabix

NPM version Build Status

Read Tabix-indexed files using either .tbi or .csi indexes.

Install

npm install @gmod/tabix

Usage

import { TabixIndexedFile } from '@gmod/tabix'

// Local file — TBI index assumed at path + '.tbi'
const file = new TabixIndexedFile({ path: 'file.vcf.gz' })

// CSI index
const file = new TabixIndexedFile({
  path: 'file.vcf.gz',
  csiPath: 'file.vcf.gz.csi',
})

// Remote files
const file = new TabixIndexedFile({
  url: 'https://example.com/file.vcf.gz',
  tbiUrl: 'https://example.com/file.vcf.gz.tbi',
})

// Or with a filehandle from generic-filehandle2
import { RemoteFile } from 'generic-filehandle2'

const file = new TabixIndexedFile({
  filehandle: new RemoteFile('https://example.com/file.vcf.gz'),
  tbiFilehandle: new RemoteFile('https://example.com/file.vcf.gz.tbi'),
})

getLines

Fetches lines overlapping a region. start/end are 0-based half-open coordinates (unlike the tabix CLI which uses 1-based closed).

const lines: string[] = []
await file.getLines('chr1', 200, 300, line => lines.push(line))

The callback also receives the virtual file offset and parsed coordinates for the line:

await file.getLines('chr1', 200, 300, (line, fileOffset, start, end) => {
  lines.push(line)
})

Pass an options object to use an AbortSignal:

const aborter = new AbortController()
await file.getLines('chr1', 200, 300, {
  lineCallback: (line, fileOffset, start, end) => lines.push(line),
  signal: aborter.signal,
})

Notes:

  • Meta/comment lines are skipped
  • Line strings have no trailing whitespace
  • Pass undefined for end to read to the end of the contig

Without NPM (CDN)

<script src="https://unpkg.com/@gmod/tabix/dist/tabix-bundle.js"></script>

See example/index.html for a working demo.

API

new TabixIndexedFile(args)

| Arg | Type | Description | | --- | --- | --- | | path | string? | Local file path | | url | string? | Remote URL | | filehandle | GenericFilehandle? | Custom filehandle (from generic-filehandle2) | | tbiPath | string? | TBI index path (defaults to path + '.tbi') | | tbiUrl | string? | TBI index URL | | tbiFilehandle | GenericFilehandle? | TBI index filehandle | | csiPath | string? | CSI index path | | csiUrl | string? | CSI index URL | | csiFilehandle | GenericFilehandle? | CSI index filehandle | | chunkCacheSize | number? | Chunk LRU cache size in bytes (default 5 MiB) |

getLines(refName, start, end, opts)

Calls opts (or opts.lineCallback) for each line overlapping [start, end).

Callback signature: (line: string, fileOffset: number, start: number, end: number) => void

getHeader(opts?): Promise<string>

Returns all comment/meta lines before the first data line as a string.

getHeaderBuffer(opts?): Promise<Uint8Array>

Returns the header as raw bytes.

getReferenceSequenceNames(opts?): Promise<string[]>

Returns reference sequence names in index order. renameRefSeqs is not applied to these names.

lineCount(refName, opts?): Promise<number>

Returns the number of data lines on the given reference, or -1 if the reference is not in the index.

bytesForRegions(regions, opts?): Promise<number>

Estimates the compressed byte size of index chunks covering the given regions. Useful for deciding whether a request is too large before calling getLines.

Publishing

Trusted publishing via GitHub Actions.

pnpm version patch  # or minor/major

Academic Use

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.

License

MIT © Robert Buels