Socket
Socket
Sign inDemoInstall

size-limit-stream

Package Overview
Dependencies
7
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    size-limit-stream

a through stream that destroys itself if an overall size limit for the combined stream throughput is exceeded


Version published
Maintainers
1
Install size
122 kB
Created

Readme

Source

size-limit-stream

NPM

js-standard-style

Build Status

a through stream that destroys itself if an overall size limit for the combined stream throughput is exceeded. useful for e.g. limiting HTTP upload size

usage

limitStream(limit)

returns a through stream

example:

var limiter = limitStream(1024 * 5) // 5kb max

example

create a stream that concatenates input, but only if input is less than the limit:

var pumpify = require('pumpify')
var concat = require('concat-stream')
var limitStream = require('size-limit-stream')

function uploadStream (cb) {
  var limiter = limitStream(1024 * 5) // 5kb max
  var concatter = concat(function concatted (buff) {
    cb(null, buff)
  })

  var combined = pumpify(limiter, concatter)
  combined.on('error', cb)
  
  return combined
}

Keywords

FAQs

Last updated on 27 Mar 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc