@webufs/webufs-idb
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Webufs-idb is an IndexedDB implementation of webufs.

This is a plugin library for @webufs/webufs (also an example).

Usage

import { createDefaultContext } from '@webufs/webufs'
import { IDBFS } from '@webufs/webufs-idb'

const ctx = await createDefaultContext()
ctx.getVFS().registerFSType(IDBFS)
await ctx.mkdir('idb')
await ctx.mount('idbfs', '/idb')
await ctx.chdir('idb')

Mounting Options

Example:

import { indexedDB } from 'fake-indexeddb'

// ...

await ctx.mount('idbfs', '/idb', {
	/**
	 * type: IDBFactory
	 * defualt: indexedDB (in the corresponding global context)
	 * 
	 * You can choose any other custom indexedDB implementation
	 * instead of the default one.
	 */
	indexedDB: indexedDB,

	/**
	 * type: string
	 * default: 'webufs-idb'
	 * 
	 * the name of the IndexedDB database that our filesystem uses
	 * as the storage
	 * 
	 * In this way we can have multiple independent idbfs storages 
	 * at the same time.
	 */
	dbName: 'hello-webufs-idb'
})

// ...

Package Sidebar

Install

npm i @webufs/webufs-idb

Weekly Downloads

8

Version

0.1.2

License

MIT

Unpacked Size

24.8 kB

Total Files

4

Last publish

Collaborators

  • parabola2004