{"name":"stream-events","version":"1.0.1","description":"Get an event when you're being sent data or asked for it.","main":"index.js","scripts":{"test":"node ./test"},"repository":{"type":"git","url":"https://github.com/stephenplusplus/stream-events"},"keywords":["stream","events","read","write","duplexify","lazy-stream"],"author":{"name":"Stephen Sawchuk"},"license":"MIT","bugs":{"url":"https://github.com/stephenplusplus/stream-events/issues"},"homepage":"https://github.com/stephenplusplus/stream-events","devDependencies":{"duplexify":"^3.2.0"},"dependencies":{"stubs":"^1.1.0"},"gitHead":"adc423f635728ddb2e13a2abad73423ab86cb283","_id":"stream-events@1.0.1","_shasum":"4fe7b2bbfcc53e6af31087e8c540483f412ce8c6","_from":".","_npmVersion":"2.1.3","_nodeVersion":"0.10.32","_npmUser":{"name":"stephenplusplus","email":"sawchuk@gmail.com"},"maintainers":[{"name":"stephenplusplus","email":"sawchuk@gmail.com"}],"dist":{"shasum":"4fe7b2bbfcc53e6af31087e8c540483f412ce8c6","tarball":"http://registry-npm.ywwl.com/stream-events/download/stream-events-1.0.1.tgz","integrity":"sha512-zQYZ3+VgH5ZCwVVWmnapjiK3WfxonhiroM0FdSLlQadafALm0duxJcUO+fuiBr31OFW+Q/3s/xNbLcTKUlHCkg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAabAcaIiRRYceNqWqssVrDcMfPpmtbPz7L+NnDpqonNAiEAt7jJ+C3vn44+GCVYBDvcCOUA8rPv637Hi+OQTIUL/X0="}],"size":2008,"noattachment":false,"key":"/stream-events/-/stream-events-1.0.1.tgz"},"directories":{},"readme":"# stream-events\n\n> Get an event when you're being sent data or asked for it.\n\n## About\n\nThis is just a simple thing that tells you when `_read` and `_write` have been called, saving you the trouble of writing this yourself. You receive two events `reading` and `writing`-- no magic is performed.\n\nThis works well with [duplexify](https://github.com/mafintosh/duplexify) or lazy streams, so you can wait until you know you're being used as a stream to do something asynchronous, such as fetching an API token.\n\n\n## Use\n```sh\n$ npm install --save stream-events\n```\n```js\nvar stream = require('stream')\nvar streamEvents = require('stream-events')\nvar util = require('util')\n\nfunction MyStream() {\n  stream.Duplex.call(this)\n  streamEvents.call(this)\n}\nutil.inherits(MyStream, stream.Duplex)\n\nMyStream.prototype._read = function(chunk) {\n  console.log('_read called as usual')\n  this.push(new Buffer(chunk))\n  this.push(null)\n}\n\nMyStream.prototype._write = function() {\n  console.log('_write called as usual')\n}\n\nvar stream = new MyStream\n\nstream.on('reading', function() {\n  console.log('stream is being asked for data')\n})\n\nstream.on('writing', function() {\n  console.log('stream is being sent data')\n})\n\nstream.pipe(stream)\n```\n\n### Using with Duplexify\n```js\nvar duplexify = require('duplexify')\nvar streamEvents = require('stream-events')\nvar fs = require('fs')\n\nvar dup = streamEvents(duplexify())\n\ndup.on('writing', function() {\n  // do something async\n  dup.setWritable(/*writable stream*/)\n})\n\nfs.createReadStream('file').pipe(dup)\n```","publish_time":1413501555702,"_cnpm_publish_time":1413501555702,"dist-tags":{"latest":"1.0.5"}}