bufferedstream
A robust stream implementation for node.js and the browser
Last updated 10 years ago by mjackson .
Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install bufferedstream 
SYNC missed versions from official npm registry.

npm package build status dependency status code climate

BufferedStream is a robust stream implementation for node.js and the browser based on the initial version of the stream API in Node.js. All data that is written to a BufferedStream is buffered until the next turn of the event loop. This greatly enhances the usability of streams by making it easy to setup listeners in the same turn of the event loop before data is emitted.

The implementation follows the first version of the node streams API, which is powerful because of its simplicity. Node has since moved on to other, much more complex streams implementations, but there never was a problem with the initial API. The only problems were with node's implementation. For example, streams did not always wait until the next tick to emit data. Also, some streams did not respect pause/resume semantics.

BufferedStream addresses these problems by providing a well-tested, performant implementation that preserves the original streams API and works in both node.js and browsers.

Usage

The key feature of this class is that anything you write to the stream in the current turn of the event loop is buffered until the next one. This allows you to register event handlers, pause the stream, etc. reliably without losing any data.

var BufferedStream = require('bufferedstream');

var stream = new BufferedStream;
stream.write('Hello ');
stream.pause();

setTimeout(function () {
  stream.write('IHdvcmxkLg==', 'base64');
  stream.resume();
  stream.on('data', function (chunk) {
    console.log(chunk.toString()); // Hello world.
  });
}, 10);

The BufferedStream constructor may also accept a "source" which may be another stream that will be piped directly through to this stream or a string. This is useful for wrapping various stream-like objects and normalizing their behavior across implementations.

var stream = new BufferedStream(anotherStream);

Please see the source code for more information. The module is small enough (and well-documented) that it should be easy to digest in a quick skim.

Installation

Using npm:

$ npm install bufferedstream

Or, include dist/BufferedStream.min.js in a <script> tag:

<script src="BufferedStream.min.js"></script>

Issues

Please file issues on the issue tracker on GitHub.

Tests

To run the tests in node:

$ npm install
$ npm test

To run the tests in Chrome:

$ npm install
$ npm run test-browser

License

MIT

Current Tags

  • 3.1.1                                ...           latest (10 years ago)

32 Versions

  • 3.1.1                                ...           10 years ago
  • 3.1.0                                ...           10 years ago
  • 3.0.9                                ...           10 years ago
  • 3.0.8                                ...           10 years ago
  • 3.0.7                                ...           10 years ago
  • 3.0.6                                ...           10 years ago
  • 3.0.5                                ...           10 years ago
  • 3.0.4                                ...           10 years ago
  • 3.0.3                                ...           10 years ago
  • 3.0.2                                ...           10 years ago
  • 3.0.1                                ...           10 years ago
  • 3.0.0                                ...           10 years ago
  • 2.8.0                                ...           10 years ago
  • 2.7.0                                ...           10 years ago
  • 2.6.0                                ...           10 years ago
  • 2.5.0                                ...           10 years ago
  • 2.4.0                                ...           10 years ago
  • 2.3.1                                ...           10 years ago
  • 2.3.0                                ...           10 years ago
  • 2.2.0                                ...           10 years ago
  • 2.1.0                                ...           10 years ago
  • 1.6.0                                ...           12 years ago
  • 1.5.1                                ...           12 years ago
  • 1.5.0                                ...           12 years ago
  • 1.4.1                                ...           12 years ago
  • 1.4.0                                ...           12 years ago
  • 1.3.0                                ...           12 years ago
  • 1.2.0                                ...           12 years ago
  • 1.1.0                                ...           12 years ago
  • 1.0.2                                ...           12 years ago
  • 1.0.1                                ...           13 years ago
  • 1.0.0                                ...           13 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 12
Last Day 0
Last Week 12
Last Month 0
Dependencies (4)
Dev Dependencies (4)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |