{"_id":"@anandsuresh/smart-stream","_rev":"4-d9e7ba8f750c66cd098db7e500f39d97","name":"@anandsuresh/smart-stream","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@anandsuresh/smart-stream","version":"1.0.0","description":"A smart stream implementation","license":"MIT","main":"lib/smart-stream.js","repository":{"type":"git","url":"git+https://github.com/anandsuresh/smart-stream.git"},"author":{"name":"Anand Suresh"},"bugs":{"url":"https://github.com/anandsuresh/smart-stream/issues"},"homepage":"https://github.com/anandsuresh/smart-stream#readme","scripts":{"coverage":"NODE_ENV=test istanbul cover -i 'lib/**/*.js' _mocha -- --ui bdd --reporter spec --recursive spec && open coverage/lcov-report/index.html > /dev/null 2>&1","lint":"standard","test":"mocha --ui bdd --reporter spec --recursive spec"},"dependencies":{"msgpack5":"4.0.2","@anandsuresh/smart_timer":"^1.0.0"},"devDependencies":{"chai":"4.1.2","istanbul":"1.1.0-alpha.1","mocha":"5.0.5","sinon":"5.0.0","standard":"11.0.1"},"standard":{"ignore":[],"globals":["after","afterEach","before","beforeEach","describe","it"]},"gitHead":"4db806fcac3b902421fb0a8e8ead1d1312372b47","_id":"@anandsuresh/smart-stream@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.9.0","_npmUser":{"name":"anandsuresh","email":"anandsuresh@gmail.com"},"dist":{"integrity":"sha512-+jMivitBURDHZ7BJFD9XdU4K1un10LB65rOtgpLxlm6Z+8oVxxyfXE2WktHYGWCxkClX7R7rSLYBtIihWseSRg==","shasum":"2b535502d6f5cb51c70589616b9a1efa473f9ab2","tarball":"https://registry.npmjs.org/@anandsuresh/smart-stream/-/smart-stream-1.0.0.tgz","fileCount":5,"unpackedSize":19450,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICL7dQx1vivu6peHF7zbJeRRXFfN49QFgaqY1YV1kXN4AiAWqvzUz1Zle6Gfpp4AJuSbHWY+K2ZGnL/k/eV/wvg2+Q=="}]},"maintainers":[{"name":"anandsuresh","email":"anandsuresh@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/smart-stream_1.0.0_1522100466629_0.6182028089887046"},"_hasShrinkwrap":false},"1.0.1":{"name":"@anandsuresh/smart-stream","version":"1.0.1","description":"A smart stream implementation","license":"MIT","main":"lib/smart_stream.js","repository":{"type":"git","url":"git+https://github.com/anandsuresh/smart-stream.git"},"author":{"name":"Anand Suresh"},"bugs":{"url":"https://github.com/anandsuresh/smart-stream/issues"},"homepage":"https://github.com/anandsuresh/smart-stream#readme","scripts":{"coverage":"NODE_ENV=test istanbul cover -i 'lib/**/*.js' _mocha -- --ui bdd --reporter spec --recursive spec && open coverage/lcov-report/index.html > /dev/null 2>&1","lint":"standard","test":"mocha --ui bdd --reporter spec --recursive spec"},"dependencies":{"@anandsuresh/smart-timer":"^1.0.0","msgpack5":"4.0.2"},"devDependencies":{"chai":"4.1.2","istanbul":"1.1.0-alpha.1","mocha":"5.0.5","sinon":"5.0.0","standard":"11.0.1"},"standard":{"ignore":[],"globals":["after","afterEach","before","beforeEach","describe","it"]},"gitHead":"dd343a3d81d356e78607d09d52538dfeef90a12a","_id":"@anandsuresh/smart-stream@1.0.1","_npmVersion":"5.6.0","_nodeVersion":"9.9.0","_npmUser":{"name":"anandsuresh","email":"anandsuresh@gmail.com"},"dist":{"integrity":"sha512-pqENlHVJHbmVYszxHqArPRFvzZRiEPMW0mw3bd0AIelEmCrB4gMOerf6q7iJD6qVydV33k4FwCkNaN1gUOycZQ==","shasum":"68ed4f43797bd0bb864416bb84f8fdf8c59154f3","tarball":"https://registry.npmjs.org/@anandsuresh/smart-stream/-/smart-stream-1.0.1.tgz","fileCount":5,"unpackedSize":19463,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDuj3MPtQZzm/oq8y2Rr51HHXI1RfC6h7eaORjd4HMEvQIhAJo+5L4NhYy7D1WG9Zk+SsjPFoGqU+68ee9M05hPjxH8"}]},"maintainers":[{"name":"anandsuresh","email":"anandsuresh@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/smart-stream_1.0.1_1522113620418_0.2246184893319778"},"_hasShrinkwrap":false},"1.1.0":{"name":"@anandsuresh/smart-stream","version":"1.1.0","description":"A smart stream implementation","license":"MIT","main":"lib/smart_stream.js","repository":{"type":"git","url":"git+https://github.com/anandsuresh/smart-stream.git"},"author":{"name":"Anand Suresh"},"bugs":{"url":"https://github.com/anandsuresh/smart-stream/issues"},"homepage":"https://github.com/anandsuresh/smart-stream#readme","engines":{"node":">=8.0.0"},"scripts":{"coverage":"NODE_ENV=test istanbul cover -i 'lib/**/*.js' _mocha -- --ui bdd --reporter spec --recursive spec && open coverage/lcov-report/index.html > /dev/null 2>&1","lint":"standard","test":"mocha --ui bdd --reporter spec --recursive spec"},"dependencies":{"@anandsuresh/smart-timer":"^1.0.0","msgpack5":"4.0.2"},"devDependencies":{"chai":"4.1.2","istanbul":"1.1.0-alpha.1","mocha":"5.0.5","sinon":"5.0.0","standard":"11.0.1"},"standard":{"ignore":[],"globals":["after","afterEach","before","beforeEach","describe","it"]},"gitHead":"1241acccf3dd7e3c7dab1aa199aa7870994c7c78","_id":"@anandsuresh/smart-stream@1.1.0","_npmVersion":"5.8.0","_nodeVersion":"8.11.0","_npmUser":{"name":"anandsuresh","email":"anandsuresh@gmail.com"},"dist":{"integrity":"sha512-2EJmKKzgngIvoCxPWQqRMztdet5RG46XhKausnqVjG2ZancsJszKDgCBNhtZG3EHNJmcna+vcXxVOrKVpKiFuA==","shasum":"2ad70894f2252ce6eac80710d4b14751f84b21da","tarball":"https://registry.npmjs.org/@anandsuresh/smart-stream/-/smart-stream-1.1.0.tgz","fileCount":6,"unpackedSize":22017,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFsIavfu9fEfi0H81oEigxrsy4XX/eTnY7gcty30sRfHAiANwhkpPtIwNkEvB4tDc3dykklLS3Vj74DtCc7qM7dBNQ=="}]},"maintainers":[{"name":"anandsuresh","email":"anandsuresh@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/smart-stream_1.1.0_1523587978882_0.9611860557168745"},"_hasShrinkwrap":false}},"time":{"created":"2018-03-26T21:41:06.582Z","1.0.0":"2018-03-26T21:41:06.709Z","modified":"2022-04-04T13:55:15.900Z","1.0.1":"2018-03-27T01:20:20.498Z","1.1.0":"2018-04-13T02:52:58.961Z"},"maintainers":[{"name":"anandsuresh","email":"anandsuresh@gmail.com"}],"description":"A smart stream implementation","homepage":"https://github.com/anandsuresh/smart-stream#readme","repository":{"type":"git","url":"git+https://github.com/anandsuresh/smart-stream.git"},"author":{"name":"Anand Suresh"},"bugs":{"url":"https://github.com/anandsuresh/smart-stream/issues"},"license":"MIT","readme":"# smart-stream\n\n[![node (scoped)](https://img.shields.io/node/v/@anandsuresh/smart-stream.svg?style=plastic)](https://nodejs.org/en/download/)\n[![npm (scoped)](https://img.shields.io/npm/v/@anandsuresh/smart-stream.svg?style=plastic)](https://www.npmjs.com/package/@anandsuresh/smart-stream)\n[![npm](https://img.shields.io/npm/dt/@anandsuresh/smart-stream.svg?style=plastic)](https://www.npmjs.com/package/@anandsuresh/smart-stream)\n[![Travis](https://img.shields.io/travis/anandsuresh/smart-stream.svg?style=plastic)](https://travis-ci.org/anandsuresh/smart-stream)\n[![license](https://img.shields.io/github/license/anandsuresh/smart-stream.svg?style=plastic)](LICENSE)\n[![GitHub followers](https://img.shields.io/github/followers/anandsuresh.svg?style=social&label=Follow)](https://github.com/anandsuresh)\n[![Twitter Follow](https://img.shields.io/twitter/follow/anandsuresh.svg?style=social&label=Follow)](https://twitter.com/intent/follow?screen_name=anandsuresh)\n\nA smart stream provides the abstraction of a stream of bytes. It has the following properties:\n\n- `contentType`: representing the MIME type of that the stream of bytes represent\n- `contentEncoding`: representing the type of encoding (`gzip`, `deflate`, `identity`)\n- `contentLength`: the length of the stream, in bytes. Not always available.\n\n## Usage\n\n```\nconst {fromFile, fromHttpRequest} = require('smart_stream')\n\nasync function handleRequest(req, res) {\n  try {\n    const inStream = fromHttpRequest(req)\n    if (!inStream.isDeserializable) {\n      res.statusCode = 400\n      return res.end()\n    }\n\n    const obj = await stream.toObject()\n\n    // Do something with the object\n    // Then respond with a file\n\n    fromFile('/path/to/file.jpg', {contentType: 'image/jpeg'}).pipe(res)\n  } catch (err) {\n    res.statusCode = 500\n    res.end(err.stack)\n  }\n}\n```\n","readmeFilename":"README.md"}