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

@qvac/dl-hyperdrive

v0.2.1

Published

`@qvac/dl-hyperdrive` is a data loading library designed to load model weights and other resources from a [Hyperdrive](https://github.com/holepunchto/hyperdrive) instance. It leverages the `Hyperdrive` distributed file system for efficient peer-to-peer fi

Readme

@qvac/dl-hyperdrive

@qvac/dl-hyperdrive is a data loading library designed to load model weights and other resources from a Hyperdrive instance. It leverages the Hyperdrive distributed file system for efficient peer-to-peer file sharing, enabling dynamic loading of files required for AI model inference, training, and other operations.

Usage

HyperDriveDL Class

HyperDriveDL extends BaseDL to provide a unified interface for loading files from a Hyperdrive instance. It integrates seamlessly with other QVAC AI Runtime libraries and classes.

Constructor:

const HyperDriveDL = require("@qvac/dl-hyperdrive");

const hdDL = new HyperDriveDL({ key: "hd://your_hyperdrive_key" });
  • key (optional): A string representing the Hyperdrive key with the hd:// protocol prefix.
  • store (optional): A Corestore instance for managing storage. If not provided, the Hyperdrive will use an in-memory store.
  • drive (optional): A Hyperdrive instance. If provided, the Hyperdrive will use the provided instance instead of creating a new one.

Note: If both key and drive are provided, the key will be ignored.

Methods:

  • ready(): Initializes the Hyperdrive client. This method must be called before interacting with the Hyperdrive.

    await hdDL.ready();
  • getStream(path): Asynchronously retrieves a readable stream for a specified file path in the Hyperdrive.

    const stream = await hdDL.getStream("/path/to/file");
  • list(directoryPath): Asynchronously lists files in a given directory in the Hyperdrive. By default, it lists files from the root directory.

    const files = await hdDL.list("/");
    console.log(files); // Output: ['file1.bin', 'file2.bin']
  • download(path, opts): Downloads files to local cache or directly to disk. Returns an object with trackers that can be used to monitor and cancel downloads.

    // Download a single file to cache
    const download = await hdDL.download("/path/to/file");
    console.log("Download started", download);
      
    // Wait for download to complete and get results
    const results = await download.await();
    console.log("Download completed:", results);
      
    // Download a directory to cache
    const dirDownload = await hdDL.download("/path/to/directory/");
    console.log(`Directory download started with ${dirDownload.trackers.length} trackers`);
      
    // Download with progress tracking
    const progressReport = new ProgressReport({ "/path/to/file": 1000 }, callback);
    const downloadWithProgress = await hdDL.download("/path/to/file", progressReport);
    const progressResults = await downloadWithProgress.await(); // Wait for completion
      
    // Download directly to disk
    const diskDownload = await hdDL.download("/path/to/file", { 
      diskPath: "./downloads" 
    });
    const diskResults = await diskDownload.await(); // Wait for file to be saved to disk
      
    // Download to disk with progress tracking
    const diskProgressDownload = await hdDL.download("/path/to/file", {
      diskPath: "./downloads",
      progressReporter: progressReport
    });
      
    // Download with progress callback
    const callbackDownload = await hdDL.download("/path/to/file", {
      diskPath: "./downloads",
      progressCallback: (data) => console.log("Progress:", data)
    });
  • await(): Waits for all downloads to complete and returns an array of results. This method is available on the download object returned by download().

  • cancel(): Cancels active downloads. This method is available on the download object returned by download().

    const download = await hdDL.download("/path/to/file");
      
    // Wait for download to complete and get results
    const results = await download.await();
    console.log(results);
    // Output: [{ file: '/path/to/file', error: null, cached: false }]
      
    // Check for errors
    results.forEach(result => {
      if (result.error) {
        console.error(`Failed to download ${result.file}:`, result.error);
      } else {
        console.log(`Successfully downloaded ${result.file}`);
      }
    });
      
    // Cancel the download (if still in progress)
    await download.cancel();
      
    // Multiple downloads can be managed individually
    const file1Download = await hdDL.download("/file1.txt");
    const file2Download = await hdDL.download("/file2.txt");
      
    // Wait for specific downloads to complete and get results
    const results1 = await file1Download.await();
    const results2 = await file2Download.await();
      
    // Or cancel them
    await file1Download.cancel(); // Cancel only file1
    await file2Download.cancel(); // Cancel only file2
  • cached(path): Checks if a file or directory is cached locally.

    const isCached = await hdDL.cached("/path/to/file");
    console.log(`File is cached: ${isCached}`);
  • deleteLocal(path): Deletes cached files from local storage.

    const deleted = await hdDL.deleteLocal("/path/to/file");
    console.log(`File deleted: ${deleted}`);
      
    // Delete all cached files
    await hdDL.deleteLocal();
  • close(): Stops the Hyperdrive client and releases resources.

    await hdDL.close();

Examples

Loading Models with QVAC Runtime

Below is an example of how HyperDriveDL can be used within the QVAC AI Runtime to dynamically load models:

const Qvac = require("qvac-rt-local");
const HyperDriveDL = require("@qvac/dl-hyperdrive");
const MLCWhisper = require("qvac-lib-inference-addon-mlc-whisper");

const qvac = new Qvac({
  /* runtime options */
});

// Create an inference instance for Whisper using Hyperdrive to load weights
const whisper = qvac.inference.add(
  new MLCWhisper({
    weights: new HyperDriveDL({ key: "hd://your_hyperdrive_key" }),
    params: {
      /* model parameters */
    },
  })
);

// Load model weights
await whisper.load();

HyperDriveDL in AI Models

The HyperDriveDL class can be integrated directly within model classes to dynamically fetch and load model files from a Hyperdrive instance.

class MyModel {
  constructor(loader) {
    this.loader = loader;
  }

  async load() {
    const weightsStream = await this.loader.getStream("model_weights.bin");
    // Process all the required files from the stream...
  }
}

Script Usage

This repository includes a script that allows you to serve files from a specified folder over Hyperdrive. To run the script using npm:

  1. Run the script with a folder path argument:

    npm run hd-provider -- ./path/to/model/files ./path/to/storage(optional)

    This command will start serving files from the specified folder over Hyperdrive and output the Hyperdrive key, which can be used by clients to access the files.

    The path to storage is optional. If it's not provided, the files will be served from memory.

Development

  1. Install dependencies:

    npm install
  2. Run unit tests:

    npm test
  3. Run all tests with coverage and generate HTML reports:

    npm run coverage:unit           # Unit test coverage (HTML: coverage/unit/index.html)
    npm run coverage:integration   # Integration test coverage (HTML: coverage/integration/index.html)
    npm run coverage               # All tests coverage (HTML: coverage/all/index.html)
    • These commands run the respective test suites and generate coverage reports in the coverage/unit, coverage/integration, and coverage/all directories.
    • To view the HTML report, open the corresponding index.html file in your browser.
  4. Run only unit or integration tests (without coverage):

    npm run test:unit
    npm run test:integration
  • All test files must be named with the .test.js suffix and placed in the appropriate test/unit or test/integration directories.
  • Coverage is collected using brittle-bare --coverage and HTML reports are generated using Istanbul.