{"_id":"stream-meter","_rev":"2967199","name":"stream-meter","description":"A stream meter that both counts the bytes piped through it, and can optionally abort on a max size.  (e.g. limit a http request size)","dist-tags":{"latest":"1.0.4"},"maintainers":[{"name":"bryce","email":""}],"time":{"modified":"2023-05-08T06:37:05.000Z","created":"2013-07-04T01:55:19.727Z","1.0.4":"2016-07-13T22:57:12.967Z","1.0.3":"2013-09-25T23:32:42.752Z","1.0.2":"2013-09-23T03:17:16.611Z","1.0.1":"2013-07-21T19:57:10.392Z","1.0.0":"2013-07-04T01:55:19.727Z"},"users":{},"author":{"name":"Bryce B. Baril"},"repository":{"type":"git","url":"git+https://github.com/brycebaril/node-stream-meter.git"},"versions":{"1.0.4":{"name":"stream-meter","version":"1.0.4","description":"A stream meter that both counts the bytes piped through it, and can optionally abort on a max size.  (e.g. limit a http request size)","main":"index.js","directories":{"test":"test"},"dependencies":{"readable-stream":"^2.1.4"},"devDependencies":{"concat-stream":"^1.5.1","stream-spigot":"^3.0.3","tape":"^4.6.0"},"scripts":{"test":"node test/"},"repository":{"type":"git","url":"git+https://github.com/brycebaril/node-stream-meter.git"},"keywords":["streams2","streams","meter","abort"],"author":{"name":"Bryce B. Baril"},"license":"MIT","bugs":{"url":"https://github.com/brycebaril/node-stream-meter/issues"},"gitHead":"c4ac12861e3097c3d59d2043d94077f2728a837a","homepage":"https://github.com/brycebaril/node-stream-meter#readme","_id":"stream-meter@1.0.4","_shasum":"52af95aa5ea760a2491716704dbff90f73afdd1d","_from":".","_npmVersion":"3.9.3","_nodeVersion":"6.2.2-pre","_npmUser":{"name":"bryce","email":"bryce@ravenwall.com"},"maintainers":[{"name":"bryce","email":""}],"dist":{"shasum":"52af95aa5ea760a2491716704dbff90f73afdd1d","size":2871,"noattachment":false,"key":"/stream-meter/-/stream-meter-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/stream-meter/download/stream-meter-1.0.4.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/stream-meter-1.0.4.tgz_1468450629582_0.028855931479483843"},"publish_time":1468450632967,"_hasShrinkwrap":false,"_cnpm_publish_time":1468450632967,"_cnpmcore_publish_time":"2021-12-16T14:57:53.709Z"},"1.0.3":{"name":"stream-meter","version":"1.0.3","description":"A stream meter that both counts the bytes piped through it, and can optionally abort on a max size.  (e.g. limit a http request size)","main":"index.js","directories":{"test":"test"},"dependencies":{"readable-stream":"~1.1.9"},"devDependencies":{"concat-stream":"~1.0.1","stream-spigot":"~2.1.2","tape":"~1.1.1"},"scripts":{"test":"node test/"},"repository":{"type":"git","url":"https://github.com/brycebaril/node-stream-meter.git"},"keywords":["streams2","streams","meter","abort"],"author":{"name":"Bryce B. Baril"},"license":"MIT","bugs":{"url":"https://github.com/brycebaril/node-stream-meter/issues"},"readmeFilename":"README.md","_id":"stream-meter@1.0.3","dist":{"shasum":"52784e7f44d0aa19f5d3edce8a4ed7ba3c17bb5d","size":2876,"noattachment":false,"key":"/stream-meter/-/stream-meter-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/stream-meter/download/stream-meter-1.0.3.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"bryce","email":"bryce@ravenwall.com"},"maintainers":[{"name":"bryce","email":""}],"publish_time":1380151962752,"_hasShrinkwrap":false,"_cnpm_publish_time":1380151962752,"_cnpmcore_publish_time":"2021-12-16T14:57:53.960Z"},"1.0.2":{"name":"stream-meter","version":"1.0.2","description":"A stream meter that both counts the bytes piped through it, and can optionally abort on a max size.  (e.g. limit a http request size)","main":"index.js","directories":{"test":"test"},"dependencies":{"readable-stream":"~1.1.9"},"devDependencies":{"concat-stream":"~1.0.0","stream-spigot":"~2.1.2","tap":"~0.4.3"},"scripts":{"test":"tap test/*.js"},"repository":{"type":"git","url":"https://github.com/brycebaril/node-stream-meter.git"},"keywords":["streams2","streams","meter","abort"],"author":{"name":"Bryce B. Baril"},"license":"MIT","bugs":{"url":"https://github.com/brycebaril/node-stream-meter/issues"},"readmeFilename":"README.md","_id":"stream-meter@1.0.2","dist":{"shasum":"6210d30086af66cdf68315d2b06bf047c6766a2d","size":2800,"noattachment":false,"key":"/stream-meter/-/stream-meter-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/stream-meter/download/stream-meter-1.0.2.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"bryce","email":"bryce@ravenwall.com"},"maintainers":[{"name":"bryce","email":""}],"publish_time":1379906236611,"_hasShrinkwrap":false,"_cnpm_publish_time":1379906236611,"_cnpmcore_publish_time":"2021-12-16T14:57:54.175Z"},"1.0.1":{"name":"stream-meter","version":"1.0.1","description":"A stream meter that both counts the bytes piped through it, and can optionally abort on a max size.  (e.g. limit a http request size)","main":"index.js","directories":{"test":"test"},"dependencies":{"readable-stream":"~1.0.2"},"devDependencies":{"concat-stream":"~1.0.0","stream-spigot":"~2.0.0","tap":"~0.4.3"},"scripts":{"test":"tap test/*.js"},"repository":{"type":"git","url":"https://github.com/brycebaril/node-stream-meter.git"},"keywords":["streams2","streams","meter","abort"],"author":{"name":"Bryce B. Baril"},"license":"MIT","bugs":{"url":"https://github.com/brycebaril/node-stream-meter/issues"},"readmeFilename":"README.md","_id":"stream-meter@1.0.1","dist":{"shasum":"86115b8ea96eaabf6e12f8b9c4c24112b2dd9f1b","size":2824,"noattachment":false,"key":"/stream-meter/-/stream-meter-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/stream-meter/download/stream-meter-1.0.1.tgz"},"_from":".","_npmVersion":"1.3.2","_npmUser":{"name":"bryce","email":"bryce@ravenwall.com"},"maintainers":[{"name":"bryce","email":""}],"publish_time":1374436630392,"_hasShrinkwrap":false,"_cnpm_publish_time":1374436630392,"_cnpmcore_publish_time":"2021-12-16T14:57:54.409Z"},"1.0.0":{"name":"stream-meter","version":"1.0.0","description":"A stream meter that both counts the bytes piped through it, and can optionally abort on a max size.  (e.g. limit a http request size)","main":"index.js","directories":{"test":"test"},"dependencies":{"readable-stream":"~1.0.2"},"devDependencies":{"concat-stream":"~1.0.0","stream-spigot":"~1.0.0","tap":"~0.4.3"},"scripts":{"test":"tap test/*.js"},"repository":{"type":"git","url":"https://github.com/brycebaril/node-stream-meter.git"},"keywords":["streams2","streams","meter","abort"],"author":{"name":"Bryce B. Baril"},"license":"MIT","bugs":{"url":"https://github.com/brycebaril/node-stream-meter/issues"},"readmeFilename":"README.md","_id":"stream-meter@1.0.0","dist":{"shasum":"7e30e9ed55c13488d49cb0d3e3e8d578cae8f1bd","size":2714,"noattachment":false,"key":"/stream-meter/-/stream-meter-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/stream-meter/download/stream-meter-1.0.0.tgz"},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"bryce","email":"bryce@ravenwall.com"},"maintainers":[{"name":"bryce","email":""}],"publish_time":1372902919727,"_hasShrinkwrap":false,"_cnpm_publish_time":1372902919727,"_cnpmcore_publish_time":"2021-12-16T14:57:54.640Z"}},"readme":"Stream Meter\n============\n\n[![NPM](https://nodei.co/npm/stream-meter.png)](https://nodei.co/npm/stream-meter/)\n\n[![david-dm](https://david-dm.org/brycebaril/node-stream-meter.png)](https://david-dm.org/brycebaril/node-stream-meter/)\n[![david-dm](https://david-dm.org/brycebaril/node-stream-meter/dev-status.png)](https://david-dm.org/brycebaril/node-stream-meter#info=devDependencies/)\n\nStream Meter is a... uh, meter for streams.\n\nIt is a streams2 Transform stream that passes through content, but counts the number of bytes it forwards.\n\nHowever, give it a size in bytes and it will abort as soon as that threshold is passed. This is useful for capping your [hyperquest](http://npm.im/hyperquest) or http/https clients or servers content size.\n\n```\nnpm install stream-meter\n```\n\nExamples:\n\n```javascript\nvar meter = require(\"stream-meter\")\n\n// make an un-capped meter\nvar m = meter()\nprocess.stdin.pipe(m).pipe(process.stdout)\nsetTimeout(function () {\n  // Log how much we saw in a couple seconds.\n  console.log(m.bytes)\n}, 2000)\n\n// this will abort (with an Error) in the frame where 1024 bytes is reached\nprocess.stdin.pipe(meter(1024)).pipe(process.stdout)\n\n// create a 1024 byte-capped meter\nvar m = meter(1024)\nm.on(\"error\", function (e) {\n  // log the error but don't kill the process\n  console.log(e.message)\n})\nprocess.stdin.pipe(m).pipe(process.stdout)\n\n```\n\n```javascript\nvar hyperquest = require(\"hyperquest\")\n\nvar req = hyperquest(\"https://raw.github.com/mranney/node_redis/master/index.js\")\n\nvar meter = require(\"stream-meter\")(1024)\nmeter.on(\"error\", function (e) {\n  console.log(e.message)\n  console.log(\"Read %s bytes\", meter.bytes)\n})\n\n\nreq.pipe(meter).pipe(process.stderr)\n```\n\n```bash\n$ node hypermeter.js 2> /dev/null\nStream exceeded specified max of 1024 bytes.\nRead 7377 bytes\n```\n\nUsage\n=====\n\n```javascript\nvar meter = require(\"stream-meter\")\n\nvar stream = meter(size)\nstream.on(\"error\", function (e) {\n  // handle the meter aborting the stream\n})\n\n// read the bytes processed by the meter and passed through to any subsequent streams.\nvar size = stream.bytes\n```\n\nSee test/index.js for additional examples.\n\nOptions\n=======\n\nsize\n----\n\nSize (in bytes) to trigger the stream to abort. It will complete whatever frame it aborted in, so the size streamed will still be >= size but no more than size + highWaterMark\n\nProperties\n==========\n\nbytes\n-----\n\nNumber of bytes handled and passed through the meter.\n\nLICENSE\n=======\n\nMIT\n","_attachments":{},"homepage":"https://github.com/brycebaril/node-stream-meter#readme","bugs":{"url":"https://github.com/brycebaril/node-stream-meter/issues"},"license":"MIT"}