# enstore

> In-memory persistence for streams

Latest version **1.0.1** (published 2014-11-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install enstore
pnpm add enstore
yarn add enstore
bun add enstore
```

## 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.0.1 |
| Published | 2014-11-13 |
| First published | 2013-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 34 |
| Author | Julian Gruber |
| Maintainers | juliangruber |
| Keywords | stream, store, save, persistence, memory |

## Links

- npm: https://www.npmjs.com/package/enstore
- Repository: https://github.com/juliangruber/enstore
- Issues: https://github.com/juliangruber/enstore/issues
- npm.io page: https://npm.io/package/enstore

## Dependencies (1)

- [monotonic-timestamp](https://npm.io/package/monotonic-timestamp.md) 0.0.8

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2014-11-13
- 1.0.0 — 2014-11-13
- 0.0.2 — 2013-04-16
- 0.0.1 — 2013-03-25
- 0.0.0 — 2013-03-25

## README

# enstore

In-memory persistence for streams. Enables you to replay streams, even if they're not finished yet.

*Need real persistence? Check out [level-store](https://github.com/juliangruber/level-store) for a fast and flexible
streaming storage engine based on LevelDB.*

[![downloads](https://img.shields.io/npm/dm/enstore.svg)](https://www.npmjs.org/package/enstore)

[![browser support](https://ci.testling.com/juliangruber/enstore.png)](https://ci.testling.com/juliangruber/enstore)

## Usage

```js
var enstore = require('enstore');

// create a new store
var store = enstore();

// store a someStream in it
someStream.pipe(store.createWriteStream());

// pipe everything someStream emitted to someWhereElse
// doesn't matter if someStream already finished
store.createReadStream().pipe(someWhereElse);
```

## Example: Cache for browserify

This basically can be done for any streaming resource, like `fs.createReadStream()` or `request()`, that you
want to cache in memory.

```js
var http = require('http');
var browserify = require('browserify');
var enstore = require('enstore');

// fill the cache
var cache = enstore();
browserify('app.js').bundle().pipe(cache.createWriteStream());

http.createServer(function (req, res) {
  if (req.url == '/bundle.js') {
    // stream the bundle to the client
    res.writeHead(200, { 'Content-Type' : 'application/javascript' });
    store.createReadStream().pipe(res);
  }
});
```

To recreate / flush the cache just overwrite the `cache` variable with a new `enstore` instance.

## API

### enstore()

Returns a new store.

### enstore#createWriteStream(opts)

Writable stream that stores written data in the internal store. `opts` will be passed to the `Writable()` constructor.

### enstore#createReadStream()

Readable stream that emits both what is already stored and what comes in over
`createWriteStream()` until `end` is emitted. `opts` will be passed to the `Readable()` constructor.

## Installation

With [npm](http://npmjs.org) do

```bash
$ npm install enstore
```

For the client, bundle with [browserify](https://github.com/substack/node-browserify).

## License

(MIT)

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