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

bufferedstream

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bufferedstream - npm Package Compare versions

Comparing version 2.6.0 to 2.7.0

modules/utils/binaryFrom.js

4

CHANGES.md

@@ -0,1 +1,5 @@

= 2.7.0 / 2014-08-26
* Use bodec instead of Buffer for smaller browser builds
= 2.6.0 / 2014-08-15

@@ -2,0 +6,0 @@

31

modules/BufferedStream.js
var d = require('d');
var Buffer = require('buffer').Buffer;
var EventEmitter = require('events').EventEmitter;
var isBinary = require('./utils/isBinary');
var binaryFrom = require('./utils/binaryFrom');
var binaryTo = require('./utils/binaryTo');
require('setimmediate');

@@ -12,18 +14,2 @@

/**
* The set of valid encodings.
*/
var VALID_ENCODINGS = {
'hex': true,
'utf8': true,
'utf-8': true,
'ascii': true,
'binary': true,
'base64': true,
'ucs2': true,
'ucs-2': true,
'utf16le': true,
'utf-16le': true
};
/**
* A robust stream implementation for node.js and the browser based on the

@@ -132,7 +118,6 @@ * initial version of the stream API in Node.js.

* strings using that encoding. Otherwise, it emits binary objects.
*
* Valid encodings are "hex", "base64", "utf8", and "utf-8".
*/
setEncoding: d(function (encoding) {
if (VALID_ENCODINGS[encoding] !== true)
throw new Error('Unknown encoding: ' + encoding);
this.encoding = encoding;

@@ -245,4 +230,4 @@ }),

if (!Buffer.isBuffer(chunk))
chunk = new Buffer(chunk, arguments[1]);
if (!isBinary(chunk))
chunk = binaryFrom(chunk, arguments[1]);

@@ -314,3 +299,3 @@ this._chunks.push(chunk);

if (stream.encoding) {
stream.emit('data', chunk.toString(stream.encoding));
stream.emit('data', binaryTo(chunk, stream.encoding));
} else {

@@ -317,0 +302,0 @@ stream.emit('data', chunk);

@@ -5,3 +5,3 @@ {

"author": "Michael Jackson",
"version": "2.6.0",
"version": "2.7.0",
"repository": {

@@ -13,3 +13,3 @@ "type": "git",

"scripts": {
"test": "./scripts/run-specs"
"test": "scripts/run-specs"
},

@@ -20,3 +20,3 @@ "engines": {

"dependencies": {
"buffer": "~2.5.0",
"bodec": "~0.1.0",
"d": "~0.1.1",

@@ -23,0 +23,0 @@ "events": "~1.0.1",

@@ -55,3 +55,3 @@ [![build status](https://secure.travis-ci.org/mjackson/bufferedstream.png)](http://travis-ci.org/mjackson/bufferedstream)

Then open [http://localhost:8080/](http://localhost:8080/) in a browser.
Then open [http://localhost:8080/](http://localhost:8080/) in a browser.

@@ -58,0 +58,0 @@ ### License

var assert = require('assert');
var expect = require('expect');
var Buffer = require('buffer').Buffer;
var BufferedStream = require('../modules/BufferedStream');
var isBinary = require('../modules/utils/isBinary');
var binaryFrom = require('../modules/utils/binaryFrom');
var binaryTo = require('../modules/utils/binaryTo');

@@ -194,3 +196,3 @@ describe('A BufferedStream', function () {

var stream = new BufferedStream;
stream.write(new Buffer(new Buffer(content), 'base64'), 'base64');
stream.write(binaryTo(binaryFrom(content), 'base64'), 'base64');
stream.end();

@@ -226,4 +228,6 @@

testSourceType('BufferedStream', BufferedStream);
testSourceType('Buffer', Buffer);
if (typeof Buffer !== 'undefined')
testSourceType('Buffer', Buffer);
var describeNode = typeof process === 'undefined' ? describe.skip : describe;

@@ -268,5 +272,3 @@

function stringifyData(data) {
return data.map(function (chunk) {
return chunk.toString();
}).join('');
return binaryTo(require('bodec').join(data));
}

@@ -315,3 +317,3 @@

data.forEach(function (chunk) {
assert(Buffer.isBuffer(chunk));
assert(isBinary(chunk));
});

@@ -329,3 +331,3 @@ assert.equal(stringifyData(data), content);

});
assert.equal(stringifyData(data), content);
assert.equal(data.join(''), content);
callback(null);

@@ -340,3 +342,3 @@ });

data.forEach(function (chunk) {
assert(Buffer.isBuffer(chunk));
assert(isBinary(chunk));
});

@@ -354,3 +356,3 @@ assert.equal(stringifyData(data), content);

});
assert.equal(stringifyData(data), content);
assert.equal(data.join(''), content);
callback(null);

@@ -357,0 +359,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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