Skip to content
/ bvfs Public

A zero-dependency virtual filesystem for browsers. With persistence, an in-memory cache for performance, and supports directories, metadata, and optional encryption.

License

Notifications You must be signed in to change notification settings

meel-hd/bvfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BVFS

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.

Features

  • Persistent storage via IndexedDB
  • Real directories and metadata (mkdir, rmdir, stat)
  • Optional pluggable encryption
  • LRU cache for hot entries
  • Zero dependencies
  • Promise-based API

Installation

# Unpublished, include files manually
# npm install bvfs 

Usage

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 });

Extending Encryption

class MyEncryptor {
  encrypt(data) { return customEncrypt(JSON.stringify(data)); }
  decrypt(data) { return JSON.parse(customDecrypt(data)); }
}

const vfs = new VirtualFS({ encryptor: new MyEncryptor() });

License

MIT

About

A zero-dependency virtual filesystem for browsers. With persistence, an in-memory cache for performance, and supports directories, metadata, and optional encryption.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published