# random-access-idb

> [random-access][1]-compatible indexedDB storage layer

Latest version **1.2.2** (published 2022-02-07) · BSD license · 0 weekly downloads

## Install

```sh
npm install random-access-idb
pnpm add random-access-idb
yarn add random-access-idb
bun add random-access-idb
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2022-02-07 |
| First published | 2017-05-25 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 16.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | substack |
| Maintainers | soyuka, substack |
| Keywords | random-access, abstract-random-access, indexeddb, idb, browser, storage |

## Links

- npm: https://www.npmjs.com/package/random-access-idb
- npm.io page: https://npm.io/package/random-access-idb

## Dependencies (6)

- [once](https://npm.io/package/once.md) ^1.4.0
- [inherits](https://npm.io/package/inherits.md) ^2.0.3
- [next-tick](https://npm.io/package/next-tick.md) ^1.0.0
- [buffer-from](https://npm.io/package/buffer-from.md) ^0.1.1
- [buffer-alloc](https://npm.io/package/buffer-alloc.md) ^1.1.0
- [random-access-storage](https://npm.io/package/random-access-storage.md) ^1.3.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.2.2 (latest) — 2022-02-07
- 1.2.1 — 2019-01-25
- 1.2.0 — 2018-10-21
- 1.1.1 — 2018-10-21
- 1.1.0 — 2018-10-21
- 1.0.4 — 2017-08-21
- 1.0.3 — 2017-08-20
- 1.0.2 — 2017-08-20
- 1.0.1 — 2017-05-26
- 1.0.0 — 2017-05-25

## README

# random-access-idb

[random-access][1]-compatible indexedDB storage layer

[1]: https://npmjs.com/package/abstract-random-access

# example

``` js
var random = require('random-access-idb')('dbname')
var cool = random('cool.txt')
cool.write(100, new Buffer('GREETINGS'), function (err) {
  if (err) return console.error(err)
  cool.read(104, 3, function (err, buf) {
    if (err) return console.error(err)
    console.log(buf.toString()) // TIN
  })
})
```

# api

``` js
var random = require('random-access-idb')
```

## var db = random(dbname, opts)

Open an indexedDB database at `dbname`.

Any `opts` provided are forwarded to `db(name, opts)` as default options.

## var file = db(name, opts)

Create a handle `file` from `name` and `opts`:

* `opts.size` - internal chunk size to use (default 4096)

You must keep `opts.size` the same after you've written data.
If you change the size, bad things will happen.

## file.read(offset, length, cb)

Read `length` bytes at an `offset` from `file` as `cb(err, buf)`.

## file.write(offset, buf, cb)

Write `buf` to `file` at an `offset`.

# install

npm install random-access-idb

# license

BSD

---
_Source: https://npm.io/package/random-access-idb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
