{"_id":"@anandsuresh/smart_stream","_rev":"2-bc45e4ed1273f1e34818345a6c062d01","name":"@anandsuresh/smart_stream","dist-tags":{"latest":"1.0.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","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":"3eea807871cfa0372d370e139470c3daa3cc5aaa","_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-ayN+p1zuxJ4dduFye8JuizoE6I2f+pvxtO0vOc5R4W43wd20zCgrlqAlC6OFIvI5g8nGkXkkcWh4L+Rofy28lQ==","shasum":"27ea8865468d4b6e5e1b1b2895e4bade533118b6","tarball":"https://registry.npmjs.org/@anandsuresh/smart_stream/-/smart_stream-1.0.0.tgz","fileCount":5,"unpackedSize":19437,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCsm89Q1Do5vvD7GZUCP0jQAIAT2tP94GfGcHLTNpMe2QIhAM3/JxdaIfq17XVEL7TWdlAWP8yCzMpfwtgHa6odLqDg"}]},"maintainers":[{"name":"anandsuresh","email":"anandsuresh@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/smart_stream_1.0.0_1522029048239_0.2605281869064495"},"_hasShrinkwrap":false}},"time":{"created":"2018-03-26T01:50:48.186Z","1.0.0":"2018-03-26T01:50:48.307Z","modified":"2022-04-04T13:55:16.293Z"},"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\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"}