{"name":"memorystream","description":"This is lightweight memory stream module for node.js.","version":"0.0.3","keywords":["memory","stream"],"author":{"name":"Dmitry Nizovtsev","url":"https://github.com/JSBizon"},"contributors":[{"name":"Dmitry Nizovtsev","email":"dmitryp3@gmail.com"}],"repository":{"type":"git","url":"git://github.com/JSBizon/node-memorystream.git"},"homepage":"https://github.com/JSBizon/node-memorystream","engines":{"node":">= 0.1.98"},"_id":"memorystream@0.0.3","_engineSupported":true,"_npmVersion":"0.3.18","_nodeVersion":"v0.4.1","directories":{},"files":[""],"_defaultsLoaded":true,"dist":{"shasum":"ab345e11ca3fa9ea623ca0a996b8a7668fe9fe43","tarball":"http://registry-npm.ywwl.com/memorystream/download/memorystream-0.0.3.tgz","integrity":"sha512-pJrzhWYkGjvDHbmYSudRBP++lnwbkXZAmUr7wOFOnKuYIfgnXEN/u5ddZegFMWb0WZY97VCWpEpQpNUFCO/9SA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBXtM1OtdorRzzFguBNOOaEiaf2Gf+O6ugaIjJWTsTXkAiEAzHq2uXJ98iMcQEmO0O4ZSnxaEeGLgACEqDVjJBvcyg8="}],"size":3403,"noattachment":false,"key":"/memorystream/-/memorystream-0.0.3.tgz"},"maintainers":[{"name":"jsbizon","email":"dmitryp3@gmail.com"}],"readme":"[![Build Status](https://travis-ci.org/JSBizon/node-memorystream.svg?branch=master)](https://travis-ci.org/JSBizon/node-memorystream)\n\n# Introduction\nnode-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.\nModule supports streams for node > 0.10 now.\n\n\nOriginal module is here git://github.com/ollym/memstream.git was remade and improved. \n\n## Installation\nIf you have npm installed, you can simply type:\n\n\tnpm install memorystream\n\t\nOr you can clone this repository using the git command:\n\n\tgit clone git://github.com/JSBizon/node-memorystream.git\n\t\n## Usage\nSome examples how to use memorystream module.\n\n#### Basic I/O Operation\nIn this example I illustrate the basic I/O operations of the memory stream.\n\n\tvar MemoryStream = require('memorystream');\n\tvar memStream = new MemoryStream(['Hello',' ']);\n\t\n\tvar data = '';\n\tmemStream.on('data', function(chunk) {\n\t\tdata += chunk.toString();\n\t});\n\t\n\tmemStream.write('World');\n\t\n\tmemStream.on('end', function() {\n\t\t// outputs 'Hello World!'\n\t\tconsole.log(data);\n\t});\n\tmemStream.end('!');\n\t\n#### Piping\nIn this example I'm piping all data from the memory stream to the process's stdout stream.\n\n\tvar MemoryStream = require('memorystream');\n\tvar memStream = new MemoryStream();\n\tmemStream.pipe(process.stdout, { end: false });\n\t\n\tmemStream.write('Hello World!');\n\t\nIn this example I'm piping all data from the response stream to the memory stream.\n\n\tvar http = require('http'),\n\t\tMemoryStream = require('memorystream');\n\n\tvar options = {\n\t\thost: 'google.com'\n\t};\n\tvar memStream = new MemoryStream(null, {\n\t\treadable : false\n\t});\n\n\tvar req = http.get(options, function(res) {\n\t\tres.pipe(memStream);\n\t\tres.on('end', function() {\n\t\t\tconsole.log(memStream.toString());\n\t\t});\n\t});\n\n#### Delayed Response\nIn the example below, we first pause the stream before writing the data to it. The stream is then resumed after 1 second, and the data is written to the console.\n\n\tvar MemoryStream = require('memorystream');\n\n\tvar memStream = new MemoryStream('Hello');\n\tvar data = '';\n\tmemStream.on('data', function(chunk) {\n\t\tdata += chunk;\n\t});\n\t\n\tmemStream.pause();\n\tmemStream.write('World!');\n\t\n\tsetTimeout(function() {\n\t\tmemStream.resume();\n\t}, 1000);\n\n## Documentation\nThe memory stream adopts all the same methods and events as node's Stream implementation.\nDocumentation is [available here](http://github.com/JSBizon/node-memorystream/wiki/API/ \"Documentation\").\n\n\n\n\t","publish_time":1314464243801,"_cnpm_publish_time":1314464243801,"dist-tags":{"latest":"0.3.1"}}