Socket
Socket
Sign inDemoInstall

@anandsuresh/smart-stream

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anandsuresh/smart-stream

A smart stream implementation


Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

smart-stream

node (scoped) npm (scoped) npm Travis license GitHub followers Twitter Follow

A smart stream provides the abstraction of a stream of bytes. It has the following properties:

  • contentType: representing the MIME type of that the stream of bytes represent
  • contentEncoding: representing the type of encoding (gzip, deflate, identity)
  • contentLength: the length of the stream, in bytes. Not always available.

Usage

const {fromFile, fromHttpRequest} = require('smart_stream')

async function handleRequest(req, res) {
  try {
    const inStream = fromHttpRequest(req)
    if (!inStream.isDeserializable) {
      res.statusCode = 400
      return res.end()
    }

    const obj = await stream.toObject()

    // Do something with the object
    // Then respond with a file

    fromFile('/path/to/file.jpg', {contentType: 'image/jpeg'}).pipe(res)
  } catch (err) {
    res.statusCode = 500
    res.end(err.stack)
  }
}

FAQs

Package last updated on 13 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc