Skip to content

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

Folders and files

NameName
Last commit message
Last commit date
Jun 24, 2018
Jun 25, 2018
Jun 25, 2018
Jun 25, 2018
Jun 24, 2018
Jun 25, 2018
Jul 17, 2020
Jun 24, 2018
Jun 25, 2018
Jun 24, 2018
Jul 8, 2019
Jun 25, 2018
Jun 7, 2019
Jun 24, 2018

Repository files navigation

random-access-idb-mutable-file

travis package downloads styled with prettier

random-access storage layer over IDBMutableFile, which is non-standard IndexedDB extension in Gecko to provide virtual file system API with-in the IndexedDB.

This library will only work in Firefox (unless other browsers implement IDBMutableFile API) and it's mostly targeted at WebExtensions. It mostly amis to be a drop-in replacement for random-access-file. It is also an alternative to random-access-idb that is able to avoid loading all of the file content for random read / writes at the expanse of limited runtime suport.

Usage

import RandomAccess from "random-access-idb-mutable-file"

const main = async (filename, options) => {
  const randomAccessFile = await RandomAccess.mount()

  const file = randomAccessFile(filename, options)
  file.write(10, Buffer.from("hello"), error => {
    // write a buffer to offset 10
    file.read(10, 5, (error, buffer) => {
      console.log(buffer) // read 5 bytes from offset 10
      file.close(() => {
        console.log("file is closed")
      })
    })
  })
}

Install

npm install random-access-idb-mutable-file

About

random-access-storage provider via non-standard IDBMutableFile API

Resources

License

Stars

Watchers

Forks

Packages

No packages published