Skip to content

Commit 4e449d3

Browse files
committed
update readme
1 parent ff9c275 commit 4e449d3

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

Readme.md

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,48 @@
11
# random-access-idb-mutable-file
2+
23
[![travis][travis.icon]][travis.url]
34
[![package][version.icon] ![downloads][downloads.icon]][package.url]
45
[![styled with prettier][prettier.icon]][prettier.url]
56

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

7-
8-
random-access-storage provider via non-standard IDBMutableFile API
9+
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.
910

1011
## Usage
1112

12-
### Import
13-
14-
Rest of the the document & provided code examples assumes that library is installed (with yarn or npm) and imported as follows:
15-
1613
```js
17-
import * as random-access-idb-mutable-file from "random-access-idb-mutable-file"
14+
import RandomAccess from "random-access-idb-mutable-file"
15+
16+
const main = async (filename, options) => {
17+
const randomAccessFile = await RandomAccess.mount()
18+
19+
const file = randomAccessFile(filename, options)
20+
file.write(10, Buffer.from("hello"), error => {
21+
// write a buffer to offset 10
22+
file.read(10, 5, (error, buffer) => {
23+
console.log(buffer) // read 5 bytes from offset 10
24+
file.close(() => {
25+
console.log("file is closed")
26+
})
27+
})
28+
})
29+
}
1830
```
1931

20-
21-
2232
## Install
2333

2434
npm install random-access-idb-mutable-file
2535

2636
[travis.icon]: https://travis-ci.org/Gozala/random-access-idb-mutable-file.svg?branch=master
2737
[travis.url]: https://travis-ci.org/Gozala/random-access-idb-mutable-file
28-
2938
[version.icon]: https://img.shields.io/npm/v/random-access-idb-mutable-file.svg
3039
[package.url]: https://npmjs.org/package/random-access-idb-mutable-file
31-
3240
[downloads.icon]: https://img.shields.io/npm/dm/random-access-idb-mutable-file.svg
3341
[downloads.url]: https://npmjs.org/package/random-access-idb-mutable-file
34-
35-
[prettier.icon]:https://img.shields.io/badge/styled_with-prettier-ff69b4.svg
36-
[prettier.url]:https://github.com/prettier/prettier
42+
[prettier.icon]: https://img.shields.io/badge/styled_with-prettier-ff69b4.svg
43+
[prettier.url]: https://github.com/prettier/prettier
44+
[random-access-storage]: https://github.com/random-access-storage/random-access-storage
45+
[random-access-file]: https://github.com/random-access-storage/random-access-file
46+
[idbmutablefile]: https://developer.mozilla.org/en-US/docs/Web/API/IDBMutableFile
47+
[webextensions]: https://developer.mozilla.org/en-US/Add-ons/WebExtensions
48+
[random-access-idb]: https://github.com/random-access-storage/random-access-idb

0 commit comments

Comments
 (0)