{"_id":"stream-length","_rev":"11-a3fa6006a8b95f7b158303355ce0895f","name":"stream-length","description":"For a given Buffer or Stream, this module will attempt to determine the total length of the stream contents. It currently supports Buffers, `fs` streams, `http` responses, and `request` objects, and allows for specifying custom stream types.","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"stream-length","version":"1.0.0","description":"For a given Buffer or Stream, this module will attempt to determine the total length of the stream contents. It currently supports Buffers, `fs` streams, `http` responses, and `request` objects, and allows for specifying custom stream types.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/joepie91/node-stream-length"},"keywords":["stream","length","content-length"],"author":{"name":"Sven Slootweg"},"license":"WTFPL","dependencies":{"bluebird":"^2.6.2"},"devDependencies":{"request":"^2.51.0"},"gitHead":"e78579f94c961819d90f2011ec8bf43e59131802","bugs":{"url":"https://github.com/joepie91/node-stream-length/issues"},"homepage":"https://github.com/joepie91/node-stream-length","_id":"stream-length@1.0.0","_shasum":"9bb49b82ad4c7aaa916e419fb8ff7d4aa30ce343","_from":".","_npmVersion":"2.1.3","_nodeVersion":"0.10.32","_npmUser":{"name":"joepie91","email":"admin@cryto.net"},"maintainers":[{"name":"joepie91","email":"admin@cryto.net"}],"dist":{"shasum":"9bb49b82ad4c7aaa916e419fb8ff7d4aa30ce343","tarball":"https://registry.npmjs.org/stream-length/-/stream-length-1.0.0.tgz","integrity":"sha512-QF3uM7H1GbXHbnKa0sgf3Zr3aCNb0j1a5hMHqHTlkKfd681dMJ5JFLb6zhZPI/MP/FSGe55po073PsUCVg/i2A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDx3+JiQj2Ac5j+KboZFAVqyWsQ3GO+nDLRBRFh2kDQBAIhAODrtStahIfLkOg1COSMeXvlYS5/nVW40p5ADFGg4jQF"}]},"directories":{}},"1.0.1":{"name":"stream-length","version":"1.0.1","description":"For a given Buffer or Stream, this module will attempt to determine the total length of the stream contents. It currently supports Buffers, `fs` streams, `http` responses, and `request` objects, and allows for specifying custom stream types.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/joepie91/node-stream-length"},"keywords":["stream","length","content-length"],"author":{"name":"Sven Slootweg"},"license":"WTFPL","dependencies":{"bluebird":"^2.6.2"},"devDependencies":{"request":"^2.51.0","gulp":"~3.8.0","gulp-cached":"~0.0.3","gulp-coffee":"~2.0.1","gulp-concat":"~2.2.0","gulp-livereload":"~2.1.0","gulp-nodemon":"~1.0.4","gulp-plumber":"~0.6.3","gulp-remember":"~0.2.0","gulp-rename":"~1.2.0","gulp-util":"~2.2.17"},"gitHead":"7fd2c158a4c74f4e320b66e2b10d53955c5e8430","bugs":{"url":"https://github.com/joepie91/node-stream-length/issues"},"homepage":"https://github.com/joepie91/node-stream-length","_id":"stream-length@1.0.1","_shasum":"0fb186c38ffc59c78a75050eb9ef09ee2e0d7cd7","_from":".","_npmVersion":"2.1.3","_nodeVersion":"0.10.32","_npmUser":{"name":"joepie91","email":"admin@cryto.net"},"maintainers":[{"name":"joepie91","email":"admin@cryto.net"}],"dist":{"shasum":"0fb186c38ffc59c78a75050eb9ef09ee2e0d7cd7","tarball":"https://registry.npmjs.org/stream-length/-/stream-length-1.0.1.tgz","integrity":"sha512-+r2p9aY9pqa2fAiMT3gfOz/WjBIC8AUtr3ZR15C9uQzTck6Fl/YKBi/zTLIPiZgQSzrNfOjKRBaxhIRy9sonTQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCUVEtF9H97+ShV4w23xN2q2LKGf6J28hkFz1rqz1prVwIhAPKAGuKCoCLkXfqGfj17HdUXo//yq7V8JS9zpWzUwRIh"}]},"directories":{}},"1.0.2":{"name":"stream-length","version":"1.0.2","description":"For a given Buffer or Stream, this module will attempt to determine the total length of the stream contents. It currently supports Buffers, `fs` streams, `http` responses, and `request` objects, and allows for specifying custom stream types.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/joepie91/node-stream-length"},"keywords":["stream","length","content-length"],"author":{"name":"Sven Slootweg"},"license":"WTFPL","dependencies":{"bluebird":"^2.6.2"},"devDependencies":{"request":"^2.51.0","gulp":"~3.8.0","gulp-cached":"~0.0.3","gulp-coffee":"~2.0.1","gulp-concat":"~2.2.0","gulp-livereload":"~2.1.0","gulp-nodemon":"~1.0.4","gulp-plumber":"~0.6.3","gulp-remember":"~0.2.0","gulp-rename":"~1.2.0","gulp-util":"~2.2.17"},"gitHead":"49826545e4b544167d659f4041abfaa93d5c9d38","bugs":{"url":"https://github.com/joepie91/node-stream-length/issues"},"homepage":"https://github.com/joepie91/node-stream-length","_id":"stream-length@1.0.2","_shasum":"8277f3cbee49a4daabcfdb4e2f4a9b5e9f2c9f00","_from":".","_npmVersion":"2.1.3","_nodeVersion":"0.10.32","_npmUser":{"name":"joepie91","email":"admin@cryto.net"},"maintainers":[{"name":"joepie91","email":"admin@cryto.net"}],"dist":{"shasum":"8277f3cbee49a4daabcfdb4e2f4a9b5e9f2c9f00","tarball":"https://registry.npmjs.org/stream-length/-/stream-length-1.0.2.tgz","integrity":"sha512-aI+qKFiwoDV4rsXiS7WRoCt+v2RX1nUj17+KJC5r2gfh5xoSJIfP6Y3Do/HtvesFcTSWthIuJ3l1cvKQY/+nZg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDpIHGRvzKrSCg67RWoXbllKdp2BQbTNBnP3c3aEYfLLAiEArYEExIcv0NexdEwHUsH4lL2PSVb6HfOWQA/lkO0Kjfk="}]},"directories":{}}},"readme":"# stream-length\n\nAttempts to determine the total content length of a Stream or Buffer.\n\nSupports both Promises and nodebacks.\n\n## License\n\n[WTFPL](http://www.wtfpl.net/txt/copying/) or [CC0](https://creativecommons.org/publicdomain/zero/1.0/), whichever you prefer. A donation and/or attribution are appreciated, but not required.\n\n## Donate\n\nMy income consists entirely of donations for my projects. If this module is useful to you, consider [making a donation](http://cryto.net/~joepie91/donate.html)!\n\nYou can donate using Bitcoin, PayPal, Gratipay, Flattr, cash-in-mail, SEPA transfers, and pretty much anything else.\n\n## Contributing\n\nPull requests welcome. Please make sure your modifications are in line with the overall code style, and ensure that you're editing the `.coffee` files, not the `.js` files.\n\nBuild tool of choice is `gulp`; simply run `gulp` while developing, and it will watch for changes.\n\nBe aware that by making a pull request, you agree to release your modifications under the licenses stated above.\n\n## Supported stream types\n\n* Buffers\n* `fs.createReadStream` streams\n* `http.request` and `http.get` responses\n* `request` requests\n* `combined-stream2` streams\n\n## Usage\n\nUsing Promises:\n\n```javascript\nvar streamLength = require(\"stream-length\");\n\nPromise.try(function(){\n\treturn streamLength(fs.createReadStream(\"README.md\"));\n})\n.then(function(result){\n\tconsole.log(\"The length of README.md is \" + result);\n})\n.catch(function(err){\n\tconsole.log(\"Could not determine length. Error: \" + err.toString());\n});\n```\n\nUsing nodebacks:\n\n```javascript\nvar streamLength = require(\"stream-length\");\n\nstreamLength(fs.createReadStream(\"README.md\"), {}, function(err, result){\n\tif(err)\n\t{\n\t\tconsole.log(\"Could not determine length. Error: \" + err.toString());\n\t}\n\telse\n\t{\n\t\tconsole.log(\"The length of README.md is \" + result);\n\t}\n});\n```\n\nCustom lengthRetrievers:\n\n```javascript\nPromise.try(function(){\n\treturn streamLength(fs.createReadStream(\"README.md\"), [\n\t\tfunction(stream, callback){\n\t\t\tdoSomethingWith(stream, function(err, len){\n\t\t\t\tcallback(err ? err : len);\n\t\t\t})\n\t\t}\n\t]);\n})\n.then(function(result){\n\tconsole.log(\"The length of README.md is \" + result);\n})\n.catch(function(err){\n\tconsole.log(\"Could not determine length. Error: \" + err.toString());\n});\n```\n\n\n## API\n\n### streamLength(stream, [options, [callback]])\n\nDetermines the length of `stream`, which can be a supported type of Stream or a Buffer. Optionally you can specify `options`:\n\n* __lengthRetrievers__: An array of (potentially asynchronous) functions for establishing stream lengths. You can specify one or more of these if you wish to extend `stream-length`s list of supported Stream types. Each retriever function is called with a signature of `(stream, callback)` where `stream` is the stream in question, and `callback` can be called with the result. If an Error occurs, simply pass the Error to the callback instead of the value.\n\nIf you define a `callback`, it will be treated as a nodeback and called when the function completes. If you don't, the function will return a Promise that resolves when the function completes.\n","maintainers":[{"name":"joepie91","email":"admin@cryto.net"}],"time":{"modified":"2023-05-20T13:42:22.089Z","created":"2015-01-13T01:54:03.017Z","1.0.0":"2015-01-13T01:54:03.017Z","1.0.1":"2015-01-13T01:56:27.962Z","1.0.2":"2015-01-21T12:41:31.100Z"},"homepage":"https://github.com/joepie91/node-stream-length","keywords":["stream","length","content-length"],"repository":{"type":"git","url":"git://github.com/joepie91/node-stream-length"},"author":{"name":"Sven Slootweg"},"bugs":{"url":"https://github.com/joepie91/node-stream-length/issues"},"license":"WTFPL","readmeFilename":"README.md","users":{"srksumanth":true}}