package
Turn any binary stream into an object stream
npm install net-object-streamGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.

Turn any binary stream into an object stream, with multiple codec support
'use strict'
var net = require('net')
var nos = require('net-object-stream')
var through2 = require('through2')
var pump = require('pump')
var server = net.createServer(function (original) {
var stream = nos(original)
pump(stream, through2.obj(), stream)
})
server.listen(4200, function () {
var stream = nos
netObjectStream(stream, [opts])Wraps stream into a Duplex object stream, recognized opts:
codec: an object with a encode and decode method, which will
be used to encode messages. Valid encoding libraries are
protocol-buffers and
msgpack5. The default one is JSON.netObjectStream.encoder([opts])Creates an encoder for the netObjectStream protocol, recognized opts:
codec: an object with a encode and decode method, which will
be used to encode messages. Valid encoding libraries are
protocol-buffers and
msgpack5. The default one is JSON.netObjectStream.decoder([opts])Creates a decoder for the netObjectStream protocol, recognized opts:
codec: an object with a encode and decode method, which will
be used to encode messages. Valid encoding libraries are
protocol-buffers and
msgpack5. The default one is JSON.netObjectStream.parser([opts])Creates a parser for the netObjectStream protocol, recognized opts:
codec: an object with a encode and decode method, which will
be used to encode messages. Valid encoding libraries are
protocol-buffers and
msgpack5. The default one is JSON.The parser have a parser.parse(buf) function to add data to id.
It will emit 'message' events when it is able to parse an object.
netObjectStream.writeToStream(msg, [opts], stream, [callback])Write msg to the given stream, recognized options:
codec: an object with a encode and decode method, which will
be used to encode messages. Valid encoding libraries are
protocol-buffers and
msgpack5. The default one is JSON.This project is kindly sponsored by nearForm.
MIT
Estimated unpacked size across 19 packages.
738.3 kB
Includes dependencies.