Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

json-lpduplex-stream

rt2zz3MIT2.0.1

A duplex stream wrapper for json

stream, duplex, duplexify

readme

json-duplex-stream

Given a regular duplex stream, this module will return a duplex stream optimised for sending and receiving json strings.

Usage

var net = require('net')
var jsonStream = require('json-duplex-stream')

var server = net.createServer(function (socket) {
  var dup = jsonStream(socket)

  dup.on('data', function (obj) {
    console.log(obj) // { hello: 'world' }
  })
})

server.listen(3000, function () {
  var dup = jsonStream(net.connect(3000))
  dup.write({hello: 'world'})
})

License

MIT