Browser Virtual File System.
- Only a Concept
A zero-dependency virtual filesystem for browsers. Uses IndexedDB for persistence, an in-memory cache for performance, and supports directories, metadata, and optional encryption.
- Persistent storage via IndexedDB
- Real directories and metadata (
mkdir,rmdir,stat) - Optional pluggable encryption
- LRU cache for hot entries
- Zero dependencies
- Promise-based API
# Unpublished, include files manually
# npm install bvfs import { VirtualFS } from 'bvfs';
import { SimpleCrypto } from 'bvfs/src/crypto.js';
const vfs = new VirtualFS({
encryptor: new SimpleCrypto('secret'), // optional
maxCacheSize: 200
});
await vfs.init();
// Directory operations
await vfs.mkdir('/notes');
console.log(await vfs.stat('/notes')); // { path: '/notes', type: 'dir', ... }
// File operations
await vfs.writeFile('/notes/todo.txt', 'buy milk');
console.log(await vfs.readFile('/notes/todo.txt')); // 'buy milk'
// Directory listing
console.log(await vfs.readdir('/notes')); // ['todo.txt']
// Recursive removal
await vfs.rmdir('/notes', { recursive: true });class MyEncryptor {
encrypt(data) { return customEncrypt(JSON.stringify(data)); }
decrypt(data) { return JSON.parse(customDecrypt(data)); }
}
const vfs = new VirtualFS({ encryptor: new MyEncryptor() });MIT