Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

discrete-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

discrete-stream

discrete-stream

latest
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

discrete-stream

discrete-stream ensures that the chunks you put in on one end will come out in the same size on the other side.

Example

Node 1

var en = discrete.Encoder()
en.pipe(socket)
en.write('Hello World')

Node 2

var de = discrete.Decoder()
socket.pipe(de)
de.on('readable', function () {
  var message
  while((message = de.read()) !== null)
    console.log(message)
})

Install

$ npm install discrete-stream

API

discrete.Encoder(options)

discrete.Decoder(options)

Inherits from transform stream.

The encoder transforms an input stream to the discrete protocol. The decoder transforms a discrete stream back to correctly sliced buffers.

options (object)

  • prefixBytes How many bytes the size prefix header should use. Defaults to 4
  • prefixEndian If we should use big or little endians. Defaults to big endians.
  • Other options in transform stream

License

MIT

FAQs

Package last updated on 15 Mar 2013

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