Comparing version 0.4.0 to 0.4.1
@@ -6,12 +6,17 @@ #!/usr/bin/env node | ||
// dummy socket | ||
var socket = new stream.PassThrough(); | ||
// dummy i/o | ||
var dummy = new stream.PassThrough(); | ||
// wrap! auto encode/decode json frames | ||
var gladOS = burro.wrap(socket); | ||
var socket = burro.wrap(dummy); | ||
// send data | ||
socket.write({message: "どもうありがとう!", from: "japan", to: "usa"}); | ||
socket.write({message: "thank you!", from: "usa", to: "japan"}); | ||
// dummy parser; extracts message from payload | ||
var parser = new stream.Transform(); | ||
var parser = new stream.Transform({objectMode: true}); | ||
parser._transform = function _transform (obj, output, done) { | ||
output(new Buffer(obj.from + " says: " + obj.message + "\n")); | ||
var str = obj.from + " says: " + obj.message + "\n"; | ||
output(str); | ||
done(); | ||
@@ -21,10 +26,6 @@ }; | ||
// cross the streams! | ||
gladOS.pipe(parser).pipe(process.stdout); | ||
socket.pipe(parser).pipe(process.stdout); | ||
// send data | ||
gladOS.write({message: "どもうありがとう!", from: "japan", to: "usa"}); | ||
gladOS.write({message: "thank you!", from: "usa", to: "japan"}); | ||
// output | ||
// japan says: どもうありがとう! | ||
// usa says: thank you! |
{ | ||
"name": "burro", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "auto-packaged, length-prefixed JSON byte streams", | ||
@@ -5,0 +5,0 @@ "main": "lib/burro", |
@@ -13,12 +13,17 @@ Burro | ||
// dummy socket | ||
var socket = new stream.PassThrough(); | ||
// dummy i/o | ||
var dummy = new stream.PassThrough(); | ||
// wrap! auto encode/decode json frames | ||
var gladOS = burro.wrap(socket); | ||
var socket = burro.wrap(dummy); | ||
// send data | ||
socket.write({message: "どもうありがとう!", from: "japan", to: "usa"}); | ||
socket.write({message: "thank you!", from: "usa", to: "japan"}); | ||
// dummy parser; extracts message from payload | ||
var parser = new stream.Transform(); | ||
var parser = new stream.Transform({objectMode: true}); | ||
parser._transform = function _transform (obj, output, done) { | ||
output(new Buffer(obj.from + " says: " + obj.message + "\n")); | ||
var str = obj.from + " says: " + obj.message + "\n"; | ||
output(str); | ||
done(); | ||
@@ -28,7 +33,3 @@ }; | ||
// cross the streams! | ||
gladOS.pipe(parser).pipe(process.stdout); | ||
// send data | ||
gladOS.write({message: "どもうありがとう!", from: "japan", to: "usa"}); | ||
gladOS.write({message: "thank you!", from: "usa", to: "japan"}); | ||
socket.pipe(parser).pipe(process.stdout); | ||
``` | ||
@@ -52,2 +53,4 @@ | ||
Burro is a pretty versatile beast and can even handle very large payloads. | ||
See `test/burro_test.js` for more details. | ||
See the [tests][1] for more details. | ||
[1]: https://github.com/naomik/burro/tree/master/test |
@@ -11,3 +11,3 @@ var assert = require("assert"), | ||
decoder = new burro.Decoder(); | ||
writable = new stream.Writable(); | ||
writable = new stream.Writable({objectMode: true}); | ||
decoder.pipe(writable); | ||
@@ -19,3 +19,3 @@ }); | ||
writable._write = function(chunk, _) { | ||
assert.equal(chunk, expected); | ||
assert.strictEqual(chunk, expected); | ||
done(); | ||
@@ -22,0 +22,0 @@ }; |
@@ -11,3 +11,3 @@ var assert = require("assert"), | ||
encoder = new burro.Encoder(); | ||
writable = new stream.Writable(); | ||
writable = new stream.Writable({objectMode: true}); | ||
encoder.pipe(writable); | ||
@@ -19,3 +19,3 @@ }); | ||
writable._write = function(chunk, _) { | ||
assert.equal(chunk, JSON.stringify(expected)); | ||
assert.strictEqual(chunk, JSON.stringify(expected)); | ||
done(); | ||
@@ -29,3 +29,3 @@ }; | ||
writable._write = function(chunk, _) { | ||
assert.equal(chunk, JSON.stringify(expected)); | ||
assert.strictEqual(chunk, JSON.stringify(expected)); | ||
done(); | ||
@@ -32,0 +32,0 @@ }; |
@@ -12,3 +12,3 @@ var assert = require("assert"), | ||
bob._read = function _read() {}; | ||
alice = new stream.Writable(); | ||
alice = new stream.Writable({objectMode: true}); | ||
socket = burro.wrap(new stream.PassThrough()); | ||
@@ -20,4 +20,4 @@ bob.pipe(socket).pipe(alice); | ||
var expected = "hello world"; | ||
alice._write = function(chunk, _) { | ||
assert.equal(chunk, expected); | ||
alice._write = function(obj, _) { | ||
assert.strictEqual(obj, expected); | ||
done(); | ||
@@ -30,4 +30,4 @@ }; | ||
var expected = {a: "a", b: "b"}; | ||
alice._write = function(chunk, _) { | ||
assert.deepEqual(chunk, expected); | ||
alice._write = function(obj, _) { | ||
assert.deepEqual(obj, expected); | ||
done(); | ||
@@ -46,4 +46,4 @@ }; | ||
}; | ||
alice._write = function(chunk, _) { | ||
assert.deepEqual(chunk, expected); | ||
alice._write = function(obj, _) { | ||
assert.deepEqual(obj, expected); | ||
done(); | ||
@@ -60,4 +60,4 @@ }; | ||
]; | ||
alice._write = function(chunk, _) { | ||
assert.deepEqual(chunk, expected.shift()); | ||
alice._write = function(obj, _) { | ||
assert.deepEqual(obj, expected.shift()); | ||
_(); | ||
@@ -75,4 +75,4 @@ if (expected.length === 0) { | ||
var expected = "どうもありがとう"; | ||
alice._write = function(chunk, _) { | ||
assert.equal(chunk, expected); | ||
alice._write = function(obj, _) { | ||
assert.strictEqual(obj, expected); | ||
done(); | ||
@@ -85,4 +85,4 @@ }; | ||
var expected; | ||
alice._write = function(chunk, _) { | ||
assert.equal(chunk, expected); | ||
alice._write = function(obj, _) { | ||
assert.strictEqual(obj, expected); | ||
done(); | ||
@@ -89,0 +89,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
13695
391
54
1