Registry / storage / random-access-idb-mutable-file

random-access-idb-mutable-file

JSON →
library0.3.0jsnpmunverified

A random-access-storage provider that implements the non-standard IDBMutableFile API in Firefox/Gecko. v0.3.0 (last released in 2018) provides a virtual file system within IndexedDB, avoiding loading entire file contents into memory. Works only in Firefox (or Gecko-based browsers). Alternative to random-access-file for WebExtensions, with limited runtime support. Intended as a drop-in replacement for random-access-file with the trade-off of browser restriction.

npm install random-access-idb-mutable-file
INSTALL
IMPORT
SIG · RANDOM-ACCESS-IDB-
R
random-access-idb-mutable-file
storagejavascriptv0.3.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.

default
import RandomAccess from 'random-access-idb-mutable-file'
const RandomAccess = require('random-access-idb-mutable-file')
ESM-only; package ships ES modules, not CommonJS. Also note that RandomAccess is a default export.
mount
const storage = await RandomAccess.mount()
import { mount } from 'random-access-idb-mutable-file'
mount is a static method on the default export, not a named export.
RandomAccess (instance)
const file = storage(filename, options)
const file = new storage(filename, options)
storage is a factory function, not a constructor. Do not use 'new'.

Mounts IDBMutableFile storage, writes a buffer at offset 10, reads 5 bytes, logs result, then closes file.

import RandomAccess from 'random-access-idb-mutable-file'; const main = async () => { try { const storage = await RandomAccess.mount(); const file = storage('test.txt', { size: 100 }); const buf = Buffer.from('hello'); await new Promise((resolve, reject) => { file.write(10, buf, (err) => { if (err) reject(err); else resolve(); }); }); const data = await new Promise((resolve, reject) => { file.read(10, 5, (err, buffer) => { if (err) reject(err); else resolve(buffer); }); }); console.log(data.toString()); // 'hello' await new Promise((resolve, reject) => { file.close((err) => { if (err) reject(err); else resolve(); }); }); } catch (e) { console.error(e); } }; main();
Debug
Known issues
deprecatedIDBMutableFile API is non-standard and only implemented in Firefox/Gecko. Browser support is very limited.
fix
Consider using random-access-idb or random-access-file for broader compatibility.
affects: >=0.0.0
gotchaThe storage must be mounted before creating files. RandomAccess.mount() returns a factory function.
fix
Call await RandomAccess.mount() and then use the returned factory.
affects: >=0.0.0
gotchaThe factory function is not a constructor. Do not use 'new' when creating a file.
fix
Use const file = storage(filename, options) without new.
affects: >=0.0.0
gotchaAll I/O operations are callback-based. Promises not provided natively; must wrap in Promise manually.
fix
Wrap callbacks in new Promise as shown in quickstart.
affects: >=0.0.0
gotchaBuffer is required; this library is Node.js-oriented and expects Buffer global.
fix
Ensure Buffer is available (e.g., import { Buffer } from 'buffer' in browser environments).
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: RandomAccess.mount is not a function
Trying to use CommonJS require or named import instead of default ESM import
fix
Use 'import RandomAccess from "random-access-idb-mutable-file"'
TypeError: storage is not a constructor
Using 'new storage()' instead of factory call
fix
Use 'const file = storage(filename, options)' without new
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
random-access-storagerequiredInterface dependency for storage provider
Agent activity
16 hits · last 30 days
node
14
Amazon
1
Resources
random-access-idb-mutable-file — npm install random-access-idb-mutable-file · libregistry