memorystream
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -99,3 +99,3 @@ var stream = require('stream'), | ||
if (string.length){ | ||
ret += data; | ||
ret += string; | ||
} | ||
@@ -102,0 +102,0 @@ } else { |
{ | ||
"name": "memorystream", | ||
"description": "This is lightweight memory stream module for node.js.", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "memory", |
# Introduction | ||
node-memorystream - this module allow create streams in memory. It's can be used for emulating file streams, as a buffer for incoming data that you want to pipe to another stream, the gap between two data/network streams of variable rates, etc. MemoryStream support read/write states or only read state or only write state. The API is meant to follow node's Stream implementation. | ||
node-memorystream - this module allow create streams in memory. It can be used for emulating file streams, filtering/mutating data between one stream and another, buffering incoming data, being the gap between two data/network streams of variable rates, etc. MemoryStream support read/write states or only read state or only write state. The API is meant to follow node's Stream implementation. | ||
Original module is here git://github.com/ollym/memstream.git was remaked and improved. | ||
Original module is here git://github.com/ollym/memstream.git was remade and improved. | ||
@@ -18,4 +18,4 @@ ## Installation | ||
#### Basic IO Operation | ||
In this example i illustrate the basic IO operations of the memory stream. | ||
#### Basic I/O Operation | ||
In this example I illustrate the basic I/O operations of the memory stream. | ||
@@ -26,3 +26,3 @@ var MemoryStream = require('memorystream'); | ||
var data = ''; | ||
memStream.on('data',function(chunk){ | ||
memStream.on('data', function(chunk) { | ||
data += chunk.toString(); | ||
@@ -33,4 +33,5 @@ }); | ||
memStream.on('end',function(){ | ||
console.log(data);//output 'Hello World!' | ||
memStream.on('end', function() { | ||
// outputs 'Hello World!' | ||
console.log(data); | ||
}); | ||
@@ -40,3 +41,3 @@ memStream.end('!'); | ||
#### Piping | ||
In this example i'm piping all data from the memory stream to the process' stdout stream. | ||
In this example I'm piping all data from the memory stream to the process's stdout stream. | ||
@@ -49,8 +50,6 @@ var MemoryStream = require('memorystream'); | ||
#### Pumping | ||
In this example i'm pumping all data from the response stream to the memorystream. Memorystream works like buffer. | ||
In this example I'm piping all data from the response stream to the memory stream. | ||
var http = require('http'), | ||
MemoryStream = require('memorystream'), | ||
util = require('util'); | ||
MemoryStream = require('memorystream'); | ||
@@ -60,13 +59,12 @@ var options = { | ||
}; | ||
var memStream = new MemoryStream(null,{ | ||
var memStream = new MemoryStream(null, { | ||
readable : false | ||
}); | ||
var req = http.request(options, function(res) { | ||
util.pump(res, memStream); | ||
res.on('end',function(){ | ||
var req = http.get(options, function(res) { | ||
res.pipe(memStream); | ||
res.on('end', function() { | ||
console.log(memStream.toString()); | ||
}); | ||
}); | ||
req.end(); | ||
@@ -80,3 +78,3 @@ #### Delayed Response | ||
var data = ''; | ||
memStream.on('data',function(chunk){ | ||
memStream.on('data', function(chunk) { | ||
data += chunk; | ||
@@ -89,3 +87,3 @@ }); | ||
setTimeout(function() { | ||
stream.resume(); | ||
memStream.resume(); | ||
}, 1000); | ||
@@ -92,0 +90,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
15263
89