fixed-length-stream

0.1.0 • Public • Published

Fixed Length Stream

This is a useful stream for parsing protocols. It will only pass through data until the specified length is reached, end(), and then pass any data past the specified length to a callback.

npm install fixed-length-stream

fixed(length[, cb])

var fixed = require('fixed-length-stream')
  , assert = require('assert')
  , f = fixed(10, function (err, tail) { assert.ok(tail.toString() === 'ok') })
  ;
f.write(new Buffer('0123456789ok'))
f.end()

You'll get an error if the stream is ended without satisfying the total length.

The stream takes care of ending itself and will also unpipe itself from any streams you've previously piped to it.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.0
    1

Package Sidebar

Install

npm i fixed-length-stream

Weekly Downloads

1

Version

0.1.0

License

ISC

Last publish

Collaborators

  • mikeal