🚀 Launch Week Day 2:Introducing Custom Tabs for Org Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

duplex-json-stream

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

duplex-json-stream

Turn a transport stream into an object stream that parses from / serializes to json

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

duplex-json-stream

Turn a transport stream into an duplex stream that parses from / serializes to json

npm install duplex-json-stream

build status

Usage

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

var server = net.createServer(function (socket) {
  socket = jsonStream(socket) // turn the transport stream into an object stream
  socket.on('data', function (data) {
    socket.write({echo: data}) // echo back the messages
  })
})

server.listen(10000)

var client = jsonStream(net.connect(10000))

client.write({hello: 'world'})
client.on('data', function (data) {
  console.log(data) // will print {echo: {hello: 'world'}}
})

License

MIT

FAQs

Package last updated on 08 Oct 2015

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