{"name":"stream-events","version":"1.0.5","description":"Get an event when you're being sent data or asked for it.","main":"index.js","types":"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":"b53b9533cbccbad8dd50633ab95b6f3fe4e6258e","_id":"stream-events@1.0.5","_npmVersion":"6.4.1","_nodeVersion":"10.11.0","_npmUser":{"name":"stephenplusplus","email":"stephenplusplusplus@gmail.com"},"dist":{"integrity":"sha512-E1GUzBSgvct8Jsb3v2X15pjzN1tYebtbLaMg+eBOUOAxgbLoSbT2NS91ckc5lJD1KfLjId+jXJRgo0qnV5Nerg==","shasum":"bbc898ec4df33a4902d892333d47da9bf1c406d5","tarball":"http://registry-npm.ywwl.com/stream-events/download/stream-events-1.0.5.tgz","fileCount":4,"unpackedSize":3028,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb00q9CRA9TVsSAnZWagAA5wAP/1Uc9n18wgEu2mIhdMRs\npEnT+GkLiH5W3Djma26uJrbJP94YPMWQpbAuxdkzHJwHR01cO+ADCacQT19o\nkHoZXK4IjAdjtp/k6IdzUzhvRHGOeH+JPRgh5ANqwjpDH19FWnl8Ayf+3xno\nZwN+IexuB7s9I9vCn+JsqBrnkLTKMfZhhd3OJP5tInKTL6ipK/TAfvFdYWXN\nGiBcZPTE1YkEr2zmTVRNII5zOq7vMM2h1dGy8tySRxRpsZn9XRHCA1KjrHa5\nAGXiOGNlb3ezYbn3FcKeuF/3dEdPogGZii5WU2+t9nQhVW5PToBA96rDATI7\naEQOJZ/Fjv7U49Ij/+BCTZwY9A79AB0+PCf6Bw9IPFuzygbBIJ0hZYWGEVuX\nwd35QULBUrO6+sGVPANl9rPVp0woSQU9DcbFrm2ZBC1fjZ2UnJWbeg1XSqzk\nZePEXnb4gEmsGw6zK8SDksocBpWUKBlmI0oqdGNAR2MPYIvWXZUu6nPQ2SS/\ngxDuHmSGKFK/Yw8wnmnaxbmpKyRXDYH1dRSHt9UnVJOuPYc0OwavVysGx47J\nTHbtVkoB4kH7Iblw107hlr7bIvq42PgqiNH0Vts64oOgn5SeYp86CaS/CrZn\nrOzDX4cysyiDETS0Qu4J1btFsAzOc9+y/9skgjif37fIb7KsCpZ48tb/WaxO\nSeEC\r\n=VlKZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEXx6sbhkoSX2OXTIbaVQKnkb+e1RD+tla6gvEYOj52fAiBryRObJsnYQhnnP2VEivg0Nu3Cc0W/bT0SJh12MDqMAg=="}],"size":1387,"noattachment":false,"key":"/stream-events/-/stream-events-1.0.5.tgz"},"maintainers":[{"name":"stephenplusplus","email":"sawchuk@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-events_1.0.5_1540573884573_0.691532400787328"},"_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":1540573884761,"_cnpm_publish_time":1540573884761,"dist-tags":{"latest":"1.0.5"}}