Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

burro

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

burro - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

test/event_test.js

1

lib/burro.js

@@ -16,2 +16,3 @@ var Encoder = exports.Encoder = require("./encoder"),

enc.pipe = function(dest) {
delete this.pipe;
return dec.pipe(dest);

@@ -18,0 +19,0 @@ };

2

package.json
{
"name": "burro",
"version": "0.4.1",
"version": "0.4.2",
"description": "auto-packaged, length-prefixed JSON byte streams",

@@ -5,0 +5,0 @@ "main": "lib/burro",

@@ -10,31 +10,28 @@ var stream = require("stream"),

var Server = function Server() {
stream.Duplex.call(this, {
objectMode: true
});
var SuperPod = function SuperPod() {
stream.Duplex.call(this, {objectMode: true});
};
util.inherits(Server, stream.Duplex);
util.inherits(SuperPod, stream.Duplex);
Server.prototype._write = function _write(chunk, callback) {
console.log("server", "<<", chunk.toString());
SuperPod.prototype._write = function _write(msg, callback) {
console.log("superpod", "<<", msg);
// just echo for now
this.push({command: "echo", message: chunk.toString()});
this.push({command: "echo", message: msg.message});
};
Server.prototype._read = function _read(_, done) {};
SuperPod.prototype._read = function _read(_, done) {};
var superpod = new SuperPod();
var server = new Server();
var service = net.createServer(function(clientSocket) {
var server = net.createServer(function(socket) {
clientSocket.on("end", function() {
socket.on("end", function() {
console.log("server log: client disconnected");
});
clientSocket.pipe(burro.decoder()).pipe(server).pipe(burro.encoder()).pipe(clientSocket);
superpod.pipe(burro.wrap(socket)).pipe(superpod);
});
service.listen(9999, function() {
server.listen(9999, function() {
console.log("server listening on port 9999", this.address());

@@ -50,10 +47,8 @@ });

this.name = name;
stream.Duplex.call(this, {
objectMode: true
});
stream.Duplex.call(this, {objectMode: true});
};
util.inherits(Client, stream.Duplex);
Client.prototype._write = function _write(chunk, callback) {
console.log(this.name, "<<", chunk.toString());
Client.prototype._write = function _write(msg, callback) {
console.log(this.name, "<<", msg);
};

@@ -67,10 +62,16 @@

var clienta = new Client("a");
var dummies = [];
var socka = net.connect(9999, function() {
console.log("client connected:");
['a', 'b', 'c'].forEach(function(id) {
var _client = new Client(id);
var _socket = net.connect(9999, function() {
console.log("client " + id + " connected");
});
_client.pipe(burro.wrap(_socket)).pipe(_client);
dummies.push({
client: _client,
socket: _socket
});
});
socka.pipe(burro.decoder()).pipe(clienta).pipe(burro.encoder()).pipe(socka);
clienta.chat("hello server!");
dummies[0].client.chat("hello server!");

@@ -56,5 +56,5 @@ var assert = require("assert"),

];
alice._write = function(obj, _) {
alice._write = function(obj, _done) {
assert.deepEqual(obj, expected.shift());
_();
_done();
if (expected.length === 0) {

@@ -89,3 +89,3 @@ done();

});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc