{"name":"stream-events","version":"1.0.2","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":"git+https://github.com/stephenplusplus/stream-events.git"},"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":"^3.0.0"},"gitHead":"0be7aa919fa4b5aa1a3f57ea60bfee39b94fa3eb","_id":"stream-events@1.0.2","_shasum":"abf39f66c0890a4eb795bc8d5e859b2615b590b2","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.8.0","_npmUser":{"name":"stephenplusplus","email":"sawchuk@gmail.com"},"dist":{"shasum":"abf39f66c0890a4eb795bc8d5e859b2615b590b2","tarball":"http://registry-npm.ywwl.com/stream-events/download/stream-events-1.0.2.tgz","integrity":"sha512-1DCZA2cyY1ttsbZwdwgcEhJolv/pcri1SZltxZt1OxVU8eZOI2vhPDp3VP9s7wiqtMo8D3DhqTpOZh2YRa/cMg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBSwyhu20DWMDrkHq8TUa0ufQWgY8ppmYPh3B+5m6Q8DAiEAgndgNQeh48oN+x/MoEnx2wWFEo9ptpAM0NFBS3HYPg4="}],"size":1980,"noattachment":false,"key":"/stream-events/-/stream-events-1.0.2.tgz"},"maintainers":[{"name":"stephenplusplus","email":"sawchuk@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/stream-events-1.0.2.tgz_1494261289471_0.34139894461259246"},"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":1494261291280,"_cnpm_publish_time":1494261291280,"dist-tags":{"latest":"1.0.5"}}