Registry / storage / hyperdrive-import-queue

hyperdrive-import-queue

JSON →
library2.1.0jsnpmunverified

A queue-based file importer for hyperdrive archives that emits per-file and overall progress events. Version 2.1.0 is the latest stable release, with occasional maintenance updates. It wraps the hyperdrive API and uses progress-stream to provide granular write progress. Unlike manual streaming, it handles batching, queuing, and progress reporting out of the box. Ideal for building file upload UIs in browser or Node.js with Dat ecosystem.

npm install hyperdrive-import-queue
INSTALL
IMPORT
SIG · HYPERDRIVE-IMPORT-
H
hyperdrive-import-queue
storagejavascriptv2.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

hyperdriveImportQueue
import hyperdriveImportQueue from 'hyperdrive-import-queue'
const hyperdriveImportQueue = require('hyperdrive-import-queue')
Default export; ESM only as of v2. CommonJS require may not work.
hyperdriveImportQueue
const hyperdriveImportQueue = require('hyperdrive-import-queue')
If using CommonJS with older version (v1), require works.
hyperdriveImportQueue (TypeScript)
import hyperdriveImportQueue from 'hyperdrive-import-queue'
Package does not ship TypeScript types; declare module or use @types if available.

Demonstrates queue import of two files into a hyperdrive archive with progress events.

import hyperdriveImportQueue from 'hyperdrive-import-queue'; import hyperdrive from 'hyperdrive'; import memdb from 'memdb'; const drive = hyperdrive(memdb('./mydrive')); const files = [ { name: 'file1.txt', data: Buffer.from('hello') }, { name: 'file2.txt', data: Buffer.from('world') } ]; hyperdriveImportQueue(files, drive, { cwd: '/uploads', progressInterval: 200, chunkSize: 64 * 1024, onFileWriteBegin: (err, file) => { console.log(`Starting: ${file.name}`); file.progressListener.on('progress', (prog) => { console.log(`Progress: ${prog.percentage}%`); }); }, onFileWriteComplete: (err, file) => { console.log(`Completed: ${file.name}`); }, onCompleteAll: (err, files) => { console.log('All files imported'); } });
Debug
Known issues
gotchaRequires hyperdrive archive to be writable and open; ensure archive is ready before calling.
fix
Call drive.ready() before using hyperdriveImportQueue.
affects: >=2.0.0
gotchafile.progressListener only available in onFileWriteBegin callback; attempt to access it earlier will be undefined.
fix
Attach progress listener only inside onFileWriteBegin.
affects: >=1.0.0
deprecatedCallback-based API; consider using promises or async/await with wrapper.
fix
Wrap callbacks in Promises if needed.
affects: >=2.0.0
gotchacwd option is prepended to file names; if omitted, files are written to root.
fix
Set cwd to empty string for root or provide desired prefix.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: hyperdriveImportQueue is not a function
Using wrong import style (e.g., named import instead of default).
fix
Use import hyperdriveImportQueue from 'hyperdrive-import-queue' (default import).
Error: archive not writable
Hyperdrive archive not opened in write mode.
fix
Ensure drive is created with { latest: true } and drive.ready() resolved.
progressListener is undefined
Accessing file.progressListener outside onFileWriteBegin callback.
fix
Only use file.progressListener inside the onFileWriteBegin callback.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
hyperdriverequiredPeer dependency for archive operations
progress-streamrequiredProvides progress event emission
Agent activity
14 hits · last 30 days
node
14
Resources
hyperdrive-import-queue — npm install hyperdrive-import-queue · libregistry