{"name":"memorystream","description":"This is lightweight memory stream module for node.js.","version":"0.0.2","keywords":["memory","stream"],"contributors":[{"name":"Dmitry Nizovtsev","email":"dmitryp3@gmail.com"}],"repository":{"type":"git","url":"git://github.com/JSBizon/node-memorystream.git"},"engines":{"node":">= 0.1.98"},"_id":"memorystream@0.0.2","_engineSupported":true,"_npmVersion":"0.3.18","_nodeVersion":"v0.4.1","directories":{},"files":[""],"_defaultsLoaded":true,"dist":{"shasum":"86486fdb7075225e02b1a3bf9214e2d387b35136","tarball":"http://registry-npm.ywwl.com/memorystream/download/memorystream-0.0.2.tgz","integrity":"sha512-wRl7u81zqF29oAMmlEwW8KX48yvgAZdmKj6VvcuVp+RdjX6eQHvwdd/O9bS4U/0dTIFEewOPqOokI/kab+lmdw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA8IQTCLWED3uK76etI3Ch43fq3Dj4rQkcyR6IMC3YSRAiB4kWoHOj24g04l6W0ufNiarP450u9vDSIKF/jYgsh+Eg=="}],"size":3389,"noattachment":false,"key":"/memorystream/-/memorystream-0.0.2.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":1314457640778,"_cnpm_publish_time":1314457640778,"dist-tags":{"latest":"0.3.1"}}