discrete-stream

0.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i discrete-stream

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • tellnes