{"name":"stream-events","version":"1.0.4","description":"Get an event when you're being sent data or asked for it.","main":"index.js","types":"index.d.ts","files":["index.js","index.d.ts"],"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":"542c252c88b1768dc7b9abdc70e969f4b94d1a96","_id":"stream-events@1.0.4","_npmVersion":"5.8.0","_nodeVersion":"9.1.0","_npmUser":{"name":"stephenplusplus","email":"stephenplusplusplus@gmail.com"},"dist":{"integrity":"sha512-D243NJaYs/xBN2QnoiMDY7IesJFIK7gEhnvAYqJa5JvDdnh2dC4qDBwlCf0ohPpX2QRlA/4gnbnPd3rs3KxVcA==","shasum":"73bfd4007b8f677b46ec699f14e9e2304c2f0a9e","tarball":"http://registry-npm.ywwl.com/stream-events/download/stream-events-1.0.4.tgz","fileCount":4,"unpackedSize":2989,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD7hv3NAvVD6RN7LreAuM9OINr9Ajzpk4yGCQ3D/bcQZgIgUiSLjf4C78LC0mArFmubwd+DC2znUaBKMSKGNCP3yVs="}],"size":1372,"noattachment":false,"key":"/stream-events/-/stream-events-1.0.4.tgz"},"maintainers":[{"name":"stephenplusplus","email":"sawchuk@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-events_1.0.4_1523639875066_0.6791485458004121"},"_hasShrinkwrap":false,"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":1523639876302,"_cnpm_publish_time":1523639876302,"dist-tags":{"latest":"1.0.5"}}