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

memory-stream

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memory-stream - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

test/object.json

14

index.js

@@ -30,4 +30,5 @@ var Stream = require("stream").Stream;

this.buffer.push(new Buffer(chunk));
}
else {
} else if (this._writableState.objectMode) {
this.buffer.push(Buffer.isBuffer(chunk) ? JSON.parse(chunk) : chunk);
} else {
this.buffer.push(chunk);

@@ -41,4 +42,3 @@ }

return this.buffer;
}
else {
} else {
return this.toBuffer();

@@ -51,4 +51,3 @@ }

JSON.stringify(this.buffer);
}
else {
} else {
return this.buffer.join('');

@@ -61,4 +60,3 @@ }

return new Buffer(this.toString());
}
else {
} else {
return Buffer.concat(this.buffer);

@@ -65,0 +63,0 @@ }

{
"name": "memory-stream",
"version": "0.0.2",
"version": "0.0.3",
"description": "Node.js streams implementation for buffered memory writes",

@@ -5,0 +5,0 @@ "main": "index.js",

var fs = require('fs');
var path = require('path');
var assert = require('assert');
var source = path.join(process.cwd(), 'test/source.txt');
var gold = fs.readFileSync(source);
var MemoryStream = require('../../index.js');

@@ -11,16 +9,36 @@

test('Stream file', function(done) {
var rs = fs.createReadStream(source);
var ws = new MemoryStream();
var source = path.join(process.cwd(), 'test/source.txt');
var gold = fs.readFileSync(source);
var rs = fs.createReadStream(source);
var ws = new MemoryStream();
ws.on('finish', function() {
// console.log(gold.toString());
// console.log(ws.get().toString());
assert.equal(ws.get().toString(), gold.toString(), 'Output should equal file source.');
done();
});
ws.on('finish', function() {
// console.log(gold.toString());
// console.log(ws.get().toString());
assert.equal(ws.get().toString(), gold.toString(), 'Output should equal file source.');
done();
});
rs.pipe(ws);
rs.pipe(ws);
});
test('Stream file objectMode true', function(done) {
var source = path.join(process.cwd(), 'test/object.json');
var gold = require(source);
var rs = fs.createReadStream(source);
var ws = new MemoryStream({
objectMode: true
});
ws.on('finish', function() {
console.error(ws.get(), gold);
assert.deepEqual(ws.get(), [gold], 'Output should equal file source.');
done();
});
rs.pipe(ws);
});
});
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