@zacharygriffee/random-access-idb

3.1.4 • Public • Published

random-access-idb


See: random-access-storage for the full api about what this library derives from.


Test it

In Node

npm test

In Browser


Installation

npm install @zacharygriffee/random-access-idb --save

Import

import rai from "@zacharygriffee/random-access-idb";

Improvements

  • Uses b4a for buffer operations
  • Implements del and truncate, and removes empty chunks from database with these operations
  • Extends with purge to delete a file from the database
  • Metadata that holds the chunkSize. IF you reopen a file that had a declared chunk size, it will open the file in that chunk size despite the configuration.
  • New blocking handlers for multiple tab support. If a file is open in one place, and another place tries to open the same file, use the blocking handlers to specify how to handle the conflict
  • Close now has a necessary reason to exist.

!!! NEW BEHAVIOR !!!

If you plan on using this cross-tab... It is now important to close the IDB file when you're done so that other tabs in the same origin can open the file.

Example

    import rai from "@zacharygriffee/random-access-idb";
    
    const file = rai("hello.txt");
    file.write(0, b4a.from("hello world"), (e) => {
        file.read(0, 5, (e, buffer) => {
            b4a.toString(buffer); // hello
        })
    });

Todo

  • [x] Add a metadata for stats. Block/Chunk size.
  • [ ] Error handling and testing of errors
  • [x] Multiple browser tab support (needs testing)

Distributed under the MIT license. See LICENSE for more information.

Readme

Keywords

none

Package Sidebar

Install

npm i @zacharygriffee/random-access-idb

Weekly Downloads

3

Version

3.1.4

License

MIT

Unpacked Size

78.9 kB

Total Files

17

Last publish

Collaborators

  • zacharygriffee