# level-blobs

> Save binary blobs in level and stream then back

Latest version **0.1.7** (published 2014-10-10) · 0 weekly downloads

## Install

```sh
npm install level-blobs
pnpm add level-blobs
yarn add level-blobs
bun add level-blobs
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.7 |
| Published | 2014-10-10 |
| First published | 2014-04-07 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Maintainers | mafintosh |
| Keywords | level, db, blobs, stream, buffer, data, store |

## Links

- npm: https://www.npmjs.com/package/level-blobs
- Repository: https://github.com/mafintosh/level-blobs
- Issues: https://github.com/mafintosh/level-blobs/issues
- npm.io page: https://npm.io/package/level-blobs

## Dependencies (3)

- [once](https://npm.io/package/once.md) ^1.3.0
- [level-peek](https://npm.io/package/level-peek.md) 1.0.6
- [readable-stream](https://npm.io/package/readable-stream.md) ^1.0.26-4

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 0.1.7 (latest) — 2014-10-10
- 0.1.6 — 2014-04-13
- 0.1.5 — 2014-04-12
- 0.1.4 — 2014-04-12
- 0.1.3 — 2014-04-12
- 0.1.2 — 2014-04-08
- 0.1.1 — 2014-04-07
- 0.1.0 — 2014-04-07
- 0.0.0 — 2014-04-07

## README

# level-blobs

Save binary blobs in level and stream then back.
Similar to [level-store](https://github.com/juliangruber/level-store) but streams2 and with support for random access writes and reads

	npm install level-blobs

[![build status](http://img.shields.io/travis/mafintosh/level-filesystem.svg?style=flat)](http://travis-ci.org/mafintosh/level-blobs)
![dat](http://img.shields.io/badge/Development%20sponsored%20by-dat-green.svg?style=flat)

[![browser support](https://ci.testling.com/mafintosh/level-blobs.png)](https://ci.testling.com/mafintosh/level-blobs)

## Usage

``` js
var blobs = require('level-blobs');
var level = require('level');

var db = level('/tmp/my-blobs-db');
var bl = blobs(db);

// create a write stream
var ws = blobs.createWriteStream('my-file.txt');

ws.on('finish', function() {
	// lets read the blob and pipe it to stdout
	var rs = blobs.createReadStream('my-file.txt');
	rs.pipe(process.stdout);
});

ws.write('hello ');
ws.write('world');
ws.end();
```

## API

#### `blobs(db, opts)`

Create a new blobs instance. Options default to

``` js
{
	blockSize: 65536, // byte size for each block of data stored
	batch: 100        // batch at max 100 blocks when writing
}
```

#### `bl.createReadStream(name, opts)`

Create a read stream for `name`. Options default to

``` js
{
	start: 0       // start reading from this byte offset
	end: Infinity  // end at end-of-file or this offset (inclusive)
}
```

#### `bl.createWriteStream(name, opts)`

Create a write stream to `name`. Options default to

``` js
{
	start: 0       // start writing at this offset
	               // if append === true start defaults to end-of-file
	append: false  // set to true if you want to append to the file
	               // if not true the file will be truncated before writing
}
```

#### `bl.read(name, opts, cb)`

Create a read stream and buffer the stream into a single buffer that is passed to the callback.
Options are passed to `createReadStream`.

#### `bl.write(name, data, opts, cb)`

Write `data` to `name` and call the callback when done.
Options are passed to `createWriteStream`.

#### `bl.remove(name, cb)`

Remove `name` from the blob store

## License

MIT

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