json-rpc-middleware-stream
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -7,5 +7,11 @@ const DuplexStream = require('readable-stream').Duplex | ||
if (!engine) throw new Error('Missing engine parameter!') | ||
const stream = new DuplexStream({ objectMode: true, read, write }) | ||
// forward notifications | ||
if (engine.on) { | ||
engine.on('notification', (message) => { | ||
stream.push(message) | ||
}) | ||
} | ||
return stream | ||
return new DuplexStream({ objectMode: true, read, write }) | ||
function read () { | ||
@@ -20,2 +26,2 @@ return false | ||
} | ||
} | ||
} |
{ | ||
"name": "json-rpc-middleware-stream", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "", | ||
@@ -13,3 +13,3 @@ "main": "index.js", | ||
"ethjs-query": "^0.2.9", | ||
"json-rpc-engine": "^3.0.1", | ||
"json-rpc-engine": "^3.8.0", | ||
"readable-stream": "^2.3.3", | ||
@@ -16,0 +16,0 @@ "safe-event-emitter": "^1.0.1" |
@@ -104,1 +104,21 @@ const test = require('tape') | ||
}) | ||
test('server notification in stream', (t) => { | ||
const engine = new RpcEngine() | ||
const stream = createEngineStream({ engine }) | ||
const notif = { jsonrpc: '2.0', method: 'test_notif' } | ||
// listen for incomming requests | ||
stream.once('data', (_notif) => { | ||
t.deepEqual(notif, _notif, 'got the expected notification') | ||
t.end() | ||
}) | ||
stream.on('error', (err) => { | ||
t.fail(error.message) | ||
}) | ||
engine.emit('notification', notif) | ||
}) |
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
5957
165
+ Addedelectron-to-chromium@1.5.23(transitive)
- Removedelectron-to-chromium@1.5.25(transitive)
Updatedjson-rpc-engine@^3.8.0