{"_id":"stream-events","_rev":"212495","name":"stream-events","description":"Get an event when you're being sent data or asked for it.","dist-tags":{"latest":"1.0.5"},"maintainers":[{"name":"stephenplusplus","email":""}],"time":{"modified":"2021-06-03T15:31:14.000Z","created":"2014-10-16T22:51:03.471Z","1.0.5":"2018-10-26T17:11:24.761Z","1.0.4":"2018-04-13T17:17:56.302Z","1.0.3":"2018-04-02T12:49:34.858Z","1.0.2":"2017-05-08T16:34:51.280Z","1.0.1":"2014-10-16T23:19:15.702Z","1.0.0":"2014-10-16T22:51:03.471Z"},"users":{"davidbwaters":true},"author":{"name":"Stephen Sawchuk"},"repository":{"type":"git","url":"git+https://github.com/stephenplusplus/stream-events.git"},"versions":{"1.0.5":{"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":{"shasum":"bbc898ec4df33a4902d892333d47da9bf1c406d5","size":1387,"noattachment":false,"key":"/stream-events/-/stream-events-1.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/stream-events/download/stream-events-1.0.5.tgz"},"maintainers":[{"name":"stephenplusplus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-events_1.0.5_1540573884573_0.691532400787328"},"_hasShrinkwrap":false,"publish_time":1540573884761,"_cnpm_publish_time":1540573884761},"1.0.4":{"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":{"shasum":"73bfd4007b8f677b46ec699f14e9e2304c2f0a9e","size":1372,"noattachment":false,"key":"/stream-events/-/stream-events-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/stream-events/download/stream-events-1.0.4.tgz"},"maintainers":[{"name":"stephenplusplus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-events_1.0.4_1523639875066_0.6791485458004121"},"_hasShrinkwrap":false,"publish_time":1523639876302,"_cnpm_publish_time":1523639876302},"1.0.3":{"name":"stream-events","version":"1.0.3","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":"aa8674ddcc672d47be185ad060a45c5789ffff6f","_id":"stream-events@1.0.3","_npmVersion":"5.7.1","_nodeVersion":"9.1.0","_npmUser":{"name":"stephenplusplus","email":"stephenplusplusplus@gmail.com"},"dist":{"shasum":"73502d794e9e03607682e0c21948406cc650e54c","size":1363,"noattachment":false,"key":"/stream-events/-/stream-events-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/stream-events/download/stream-events-1.0.3.tgz"},"maintainers":[{"name":"stephenplusplus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-events_1.0.3_1522673374779_0.7791773091920282"},"_hasShrinkwrap":false,"publish_time":1522673374858,"_cnpm_publish_time":1522673374858},"1.0.2":{"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","size":1980,"noattachment":false,"key":"/stream-events/-/stream-events-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/stream-events/download/stream-events-1.0.2.tgz"},"maintainers":[{"name":"stephenplusplus","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/stream-events-1.0.2.tgz_1494261289471_0.34139894461259246"},"directories":{},"publish_time":1494261291280,"_cnpm_publish_time":1494261291280,"_hasShrinkwrap":false},"1.0.1":{"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":""}],"dist":{"shasum":"4fe7b2bbfcc53e6af31087e8c540483f412ce8c6","size":2008,"noattachment":false,"key":"/stream-events/-/stream-events-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/stream-events/download/stream-events-1.0.1.tgz"},"directories":{},"publish_time":1413501555702,"_cnpm_publish_time":1413501555702,"_hasShrinkwrap":false},"1.0.0":{"name":"stream-events","version":"1.0.0","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.0.0"},"gitHead":"9c48046525a140b51cba576c07c278a6e4f79d0c","_id":"stream-events@1.0.0","_shasum":"71d1dd69f06cbc84edfaf9ccdecc41abb4be2d7b","_from":".","_npmVersion":"2.1.3","_nodeVersion":"0.10.32","_npmUser":{"name":"stephenplusplus","email":"sawchuk@gmail.com"},"maintainers":[{"name":"stephenplusplus","email":""}],"dist":{"shasum":"71d1dd69f06cbc84edfaf9ccdecc41abb4be2d7b","size":1974,"noattachment":false,"key":"/stream-events/-/stream-events-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/stream-events/download/stream-events-1.0.0.tgz"},"directories":{},"publish_time":1413499863471,"_cnpm_publish_time":1413499863471,"_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```","_attachments":{},"homepage":"https://github.com/stephenplusplus/stream-events","bugs":{"url":"https://github.com/stephenplusplus/stream-events/issues"},"license":"MIT"}