Socket
Book a DemoInstallSign in
Socket

fixed-length-stream

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fixed-length-stream

A useful stream when parsing protocols.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

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.

Keywords

stream

FAQs

Package last updated on 11 May 2014

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