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

@ncbijs/etl

v0.1.1

Published

Pre-wired NCBI data loaders: one function call to download, parse, and sink any dataset

Readme

Runtime: Browser + Node.js


What is this?

Using @ncbijs/pipeline directly requires knowing the NCBI FTP URL, the correct parser function, and how to wire them together. @ncbijs/etl encapsulates all of that: you only provide the destination.

import { load } from '@ncbijs/etl';

await load('mesh', mySink);

The package ships a registry of 6 NCBI bulk datasets with their URLs, parsers, and source constructors. You bring the sink (DuckDB, a REST API, a file, anything that implements Sink<object>), and the ETL handles the rest.

Installation

pnpm add @ncbijs/etl

Quick start

Load a single dataset

import { load } from '@ncbijs/etl';
import { createSink } from '@ncbijs/pipeline';

const records: Array<object> = [];

await load(
  'clinvar',
  createSink(async (batch) => {
    records.push(...batch);
  }),
);

Load all datasets into DuckDB

import { loadAll } from '@ncbijs/etl';
import { DuckDbFileStorage } from '@ncbijs/store';

const storage = await DuckDbFileStorage.open('ncbi.duckdb');

const { results, totalDurationMs } = await loadAll((dataset) => storage.createSink(dataset));

for (const entry of results) {
  if (entry.error) {
    console.error(`${entry.dataset} failed:`, entry.error.message);
  } else {
    console.log(`${entry.dataset}: ${entry.result!.recordsProcessed} records`);
  }
}

Available datasets

| ID | Name | Format | Compressed | Estimated size | Estimated records | Update frequency | | ------------- | ----------------- | ------ | ---------- | -------------- | ----------------- | ---------------- | | mesh | MeSH Descriptors | XML | No | ~360 MB | ~30K descriptors | Annual | | clinvar | ClinVar Variants | TSV | Yes (.gz) | ~150 MB | ~2.5M submissions | Weekly | | genes | Gene Info | TSV | Yes (.gz) | ~600 MB | ~35M genes | Daily | | taxonomy | Taxonomy | tar.gz | Yes | ~80 MB | ~2.5M taxa | Daily | | compounds | PubChem Compounds | TSV | Yes (.gz) | ~15 GB | ~115M compounds | Daily | | id-mappings | PMC ID Mappings | CSV | Yes (.gz) | ~233 MB | ~9.5M mappings | Daily |

API

load(dataset, sink, options?)

Load a single dataset from NCBI HTTP into the provided sink.

| Parameter | Type | Description | | -------------------- | ---------------------- | --------------------------------------------- | | dataset | EtlDatasetType | Dataset identifier (see table above) | | sink | Sink<object> | Target sink from @ncbijs/pipeline | | options.transform | (records) => records | Filter or transform records before writing | | options.signal | AbortSignal | Cancel the pipeline | | options.batchSize | number | Records per batch (default: pipeline default) | | options.onProgress | (event) => void | Progress callback |

Returns Promise<PipelineResult>.

loadAll(sinkFactory, options?)

Load multiple (or all) datasets. The factory is called once per dataset to create its sink.

| Parameter | Type | Description | | --------------------------- | ------------------------------- | ----------------------------------- | | sinkFactory | (dataset) => Sink<object> | Creates a sink for each dataset | | options.datasets | ReadonlyArray<EtlDatasetType> | Subset to load (default: all) | | options.signal | AbortSignal | Cancel all pipelines | | options.batchSize | number | Records per batch | | options.onDatasetComplete | (dataset, result) => void | Called after each dataset completes | | options.onError | 'abort' \| 'skip' | Error strategy (default: 'abort') |

Returns Promise<LoadAllResult>.

listDatasets()

Returns metadata for all available datasets.

import { listDatasets } from '@ncbijs/etl';

for (const dataset of listDatasets()) {
  console.log(`${dataset.name}: ${dataset.estimatedRecords}`);
}

getDataset(id)

Returns metadata for a single dataset.

import { getDataset } from '@ncbijs/etl';

const mesh = getDataset('mesh');
console.log(mesh.sourceUrls); // ['https://nlmpubs.nlm.nih.gov/...']

Transform example

Filter ClinVar to only pathogenic human variants:

await load('clinvar', mySink, {
  transform: (records) =>
    records.filter((record) => {
      const variant = record as { clinicalSignificance?: string };
      return variant.clinicalSignificance?.includes('Pathogenic');
    }),
});

Keep data fresh

After the initial load, use createCheckers() with @ncbijs/sync to poll for upstream changes and re-load only what changed:

import { createCheckers, load } from '@ncbijs/etl';
import { SyncScheduler, InMemorySyncState } from '@ncbijs/sync';

// Phase 1: initial load (see examples above)

// Phase 2: watch for changes and re-sync
const scheduler = new SyncScheduler(new InMemorySyncState(), createCheckers(), {
  checkIntervalMs: 3600_000,
  datasets: ['clinvar', 'genes'],
  onUpdate: async (dataset) => {
    await load(dataset, mySink);
  },
});

await scheduler.start();

createCheckers() reads the dataset registry and auto-selects the best change detection strategy per dataset (MD5 checksum or HTTP Last-Modified). See @ncbijs/sync for details.

Taxonomy note

The taxonomy dataset is distributed as a tar.gz archive containing names.dmp and nodes.dmp files. The createSource in the registry throws with guidance because createHttpSource can decompress gzip but cannot extract tar entries. To load taxonomy, pre-extract the files and use createCompositeSource from @ncbijs/pipeline directly.