New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

enstore

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enstore

In-memory persistence for streams

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.9K
decreased by-25.87%
Maintainers
1
Weekly downloads
 
Created
Source

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 for a fast and flexible streaming storage engine based on LevelDB.

downloads

browser support

Usage

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.

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 do

$ npm install enstore

For the client, bundle with browserify.

License

(MIT)

Keywords

FAQs

Package last updated on 13 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc