Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rereadable-stream

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rereadable-stream

A simple standards-based stream that can be read again from begining.

  • 1.4.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
decreased by-41.11%
Maintainers
1
Weekly downloads
 
Created
Source

Re-Readable Stream

The module exposes a Writable stream that you can replay at any given moment to any number of Writable outputs. Think of it as a DVR feature for Node.js streams - one stream can start playing, but others may want to join in at any given point in time and start reading from the begining.

Usage:

const {ReReadable} = require("rereadable-stream");

let rereadable = fs.createReadStream("myfile")
    .pipe(new ReReadable(options));

srv.on("connection", (sock) => sock.pipe(rereadable.rewind()));

The module exposes a simple API on as an extension a standard Writable stream:

  • tail(count) - the last number of stream chunks will be pushed and then rest of it.
  • rewind() - this will stream from the begining of the buffer.

The options are:

  • length - 1 million items as standard
  • standard Writable stream options

If one of readable stream cannot cope with the speed of other streams drop events will be emitted to inform about it.

rewound.on("drop", (count) => console.log(`dropped ${count} items`));

Notice: For version 1.0.0 only object streams are well tested. There's no reason why buffer stream should not work, but they won't follow any sensible limits. This will be fixed in 1.2.0.

License

See LICENSE (MIT).

For other licensing options please open an issue or contact the author at opensource (at) signicode.com

FAQs

Package last updated on 19 Nov 2020

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