bufferedstream
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -7,5 +7,2 @@ var d = require('d'); | ||
if (typeof setImmediate === 'undefined') | ||
require('setimmediate'); | ||
/** | ||
@@ -26,4 +23,4 @@ * The default maximum buffer size. | ||
/** | ||
* A flexible event emitter for binary data that reliably emits data on the | ||
* next turn of the event loop. | ||
* A robust stream implementation for node.js and the browser based on the | ||
* initial version of the stream API in Node.js. | ||
* | ||
@@ -66,5 +63,8 @@ * The maxSize determines the number of bytes the buffer can hold before it is | ||
if (typeof source !== 'undefined') { | ||
if (source && typeof source.pipe === 'function') { | ||
if (source != null) { | ||
if (typeof source.pipe === 'function') { | ||
source.pipe(this); | ||
if (typeof source.resume === 'function') | ||
source.resume(); | ||
} else { | ||
@@ -137,7 +137,4 @@ this.end(source, sourceEncoding); | ||
function ondata(chunk) { | ||
if (dest.writable) { | ||
if (false === dest.write(chunk) && source.pause) { | ||
source.pause(); | ||
} | ||
} | ||
if (dest.writable && false === dest.write(chunk)) | ||
source.pause(); | ||
} | ||
@@ -148,5 +145,4 @@ | ||
function ondrain() { | ||
if (source.readable && source.resume) { | ||
if (source.readable) | ||
source.resume(); | ||
} | ||
} | ||
@@ -199,2 +195,6 @@ | ||
// Mimic the behavior of node v2 streams where pipe() resumes the flow. | ||
// This also lets us avoid having to do stream.resume() all over the place. | ||
source.resume(); | ||
// Allow for unix-like usage: A.pipe(B).pipe(C) | ||
@@ -262,2 +262,4 @@ return dest; | ||
require('setimmediate'); | ||
function flushSoon(stream) { | ||
@@ -264,0 +266,0 @@ if (stream._flushing) |
@@ -1,3 +0,8 @@ | ||
= HEAD | ||
= 2.3.0 / 2014-08-02 | ||
* Auto-resume on pipe(). This mimics the behavior of node streams v2. | ||
= 2.2.0 / 2014-07-14 | ||
* Don't emit "drain" when stream is already ended | ||
* Maximum stream length defaults to 64k | ||
@@ -4,0 +9,0 @@ |
{ | ||
"name": "bufferedstream", | ||
"description": "A reliable read/write stream class for node.js and browsers", | ||
"author": "Michael Jackson <mjijackson@gmail.com>", | ||
"version": "2.2.0", | ||
"description": "A robust stream implementation for node.js and the browser", | ||
"author": "Michael Jackson", | ||
"version": "2.3.0", | ||
"repository": { | ||
@@ -26,3 +26,6 @@ "type": "git", | ||
"mocha": "~1.20.1" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/mjackson/bufferedstream/issues" | ||
} | ||
} |
[![build status](https://secure.travis-ci.org/mjackson/bufferedstream.png)](http://travis-ci.org/mjackson/bufferedstream) | ||
BufferedStream is a reliable read/write stream class for node.js and browsers. 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. | ||
[BufferedStream](https://github.com/mjackson/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. | ||
This class 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. | ||
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. | ||
## Installation | ||
### Installation | ||
@@ -15,7 +15,7 @@ Using [npm](http://npmjs.org): | ||
## Usage | ||
### 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. | ||
```javascript | ||
```js | ||
var BufferedStream = require('bufferedstream'); | ||
@@ -40,3 +40,3 @@ | ||
## Specs | ||
### Specs | ||
@@ -47,10 +47,4 @@ Run the specs with [mocha](http://visionmedia.github.com/mocha/): | ||
## License | ||
### License | ||
Copyright 2014 Michael Jackson | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. | ||
[MIT](http://opensource.org/licenses/MIT) |
@@ -108,4 +108,4 @@ var assert = require('assert'); | ||
done(); | ||
}); | ||
}); | ||
}, 5); | ||
}, 5); | ||
}); | ||
@@ -112,0 +112,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
1
20678
48