size-limit-stream

1.0.0 • Public • Published

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
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    67
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    67

Package Sidebar

Install

npm i size-limit-stream

Weekly Downloads

67

Version

1.0.0

License

BSD

Last publish

Collaborators

  • maxogden