bufferedstream
Advanced tools
Comparing version 2.3.1 to 2.4.0
var d = require('d'); | ||
var bops = require('bops'); | ||
var Buffer = require('buffer').Buffer; | ||
var ee = require('event-emitter'); | ||
@@ -16,5 +16,12 @@ var allOff = require('event-emitter/all-off'); | ||
var VALID_ENCODINGS = { | ||
utf8: true, | ||
hex: true, | ||
base64: true | ||
'hex': true, | ||
'utf8': true, | ||
'utf-8': true, | ||
'ascii': true, | ||
'binary': true, | ||
'base64': true, | ||
'ucs2': true, | ||
'ucs-2': true, | ||
'utf16le': true, | ||
'utf-16le': true | ||
}; | ||
@@ -100,3 +107,3 @@ | ||
if (VALID_ENCODINGS[encoding] !== true) | ||
throw new Error('Invalid encoding: ' + encoding); | ||
throw new Error('Unknown encoding: ' + encoding); | ||
@@ -218,7 +225,7 @@ this.encoding = encoding; | ||
if (!bops.is(chunk)) | ||
chunk = bops.from(chunk, arguments[1]); | ||
if (!Buffer.isBuffer(chunk)) | ||
chunk = new Buffer(chunk, arguments[1]); | ||
this._chunks.push(chunk); | ||
this.size += getByteLength(chunk); | ||
this.size += chunk.length; | ||
@@ -286,6 +293,6 @@ flushSoon(this); | ||
while (chunk = stream._chunks.shift()) { | ||
stream.size -= getByteLength(chunk); | ||
stream.size -= chunk.length; | ||
if (stream.encoding) { | ||
stream.emit('data', bops.to(chunk, stream.encoding)); | ||
stream.emit('data', chunk.toString(stream.encoding)); | ||
} else { | ||
@@ -311,9 +318,2 @@ stream.emit('data', chunk); | ||
function getByteLength(chunk) { | ||
if (typeof chunk.byteLength !== 'undefined') | ||
return chunk.byteLength; | ||
return chunk.length; | ||
} | ||
module.exports = BufferedStream; |
@@ -0,8 +1,13 @@ | ||
= 2.4.0 / 2014-08-05 | ||
* Use Browserify's Buffer module instead of bops | ||
* Added browser specs | ||
= 2.3.1 / 2014-08-04 | ||
* Fix compat regression with node v2 Readable streams. | ||
* Fix compat regression with node v2 Readable streams | ||
= 2.3.0 / 2014-08-02 | ||
* Auto-resume on pipe(). This mimics the behavior of node streams v2. | ||
* Auto-resume on pipe(). This mimics the behavior of node streams v2 | ||
@@ -9,0 +14,0 @@ = 2.2.0 / 2014-07-14 |
@@ -5,3 +5,3 @@ { | ||
"author": "Michael Jackson", | ||
"version": "2.3.1", | ||
"version": "2.4.0", | ||
"repository": { | ||
@@ -13,3 +13,3 @@ "type": "git", | ||
"scripts": { | ||
"test": "mocha spec" | ||
"test": "./scripts/run-specs" | ||
}, | ||
@@ -20,3 +20,3 @@ "engines": { | ||
"dependencies": { | ||
"bops": "~0.1.1", | ||
"buffer": "~2.5.0", | ||
"d": "~0.1.1", | ||
@@ -27,3 +27,5 @@ "event-emitter": "~0.3.1", | ||
"devDependencies": { | ||
"browserify": "~4.1.9", | ||
"expect": "~0.1.1", | ||
"http-server": "^0.6.1", | ||
"mocha": "~1.20.1" | ||
@@ -30,0 +32,0 @@ }, |
@@ -45,8 +45,16 @@ [![build status](https://secure.travis-ci.org/mjackson/bufferedstream.png)](http://travis-ci.org/mjackson/bufferedstream) | ||
Run the specs with [mocha](http://visionmedia.github.com/mocha/): | ||
To run the specs in node: | ||
$ mocha spec | ||
$ npm install | ||
$ ./scripts/run-specs | ||
To run the specs in a browser, first run: | ||
$ npm install | ||
$ ./scripts/serve-specs | ||
Then open [http://localhost:8080/](http://localhost:8080/) in a browser. | ||
### License | ||
[MIT](http://opensource.org/licenses/MIT) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
150280
14
5542
60
4
11
1
+ Addedbuffer@~2.5.0
+ Addedbase64-js@0.0.8(transitive)
+ Addedbuffer@2.5.1(transitive)
+ Addedieee754@1.1.13(transitive)
- Removedbops@~0.1.1
- Removedbase64-js@0.0.2(transitive)
- Removedbops@0.1.1(transitive)
- Removedto-utf8@0.0.1(transitive)