See: random-access-storage for the full api about what this library derives from.
npm test
npm install @zacharygriffee/random-access-idb --save
import rai from "@zacharygriffee/random-access-idb";
- Uses b4a for buffer operations
- Implements
del
andtruncate
, 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.
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
})
});
- [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.