nanomessage-rpc
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -9,2 +9,4 @@ # Changelog | ||
## 3.2.0 - 2021-02-04 [YANKED] | ||
## 3.1.0 - 2021-02-04 [YANKED] | ||
@@ -35,2 +37,2 @@ | ||
## 1.0.0 - 2020-03-11 [YANKED] | ||
[Unreleased]: https://github.com/geut/nanomessage-rpc/compare/v3.1.0...HEAD | ||
[Unreleased]: https://github.com/geut/nanomessage-rpc/compare/v3.2.0...HEAD |
{ | ||
"name": "nanomessage-rpc", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Tiny rpc on top of nanomessage", | ||
@@ -23,3 +23,3 @@ "main": "index.js", | ||
"nanoerror": "^1.1.0", | ||
"nanomessage": "^8.2.0", | ||
"nanomessage": "^8.3.0", | ||
"nanoresource-promise": "^2.0.0", | ||
@@ -26,0 +26,0 @@ "varint": "^5.0.0" |
@@ -131,3 +131,3 @@ # nanomessage-rpc (aka nrpc) | ||
#### `rpc.call(actionName, data) => Promise<Response>` | ||
#### `rpc.call(actionName, data, [opts]) => Promise<Response>` | ||
@@ -138,6 +138,8 @@ Call an action an wait for the response. | ||
- `data: (Buffer|Object|String)`: Request data. | ||
- `opts.timeout: number`: Define a custom timeout for the current request. | ||
- `opts.signal: AbortSignal`: Set an abort signal object to cancel the request. | ||
### Events | ||
#### `rpc.emit(eventName, data, [wait]) => Promise` | ||
#### `rpc.emit(eventName, data, [opts]) => Promise` | ||
@@ -148,3 +150,5 @@ Emit an event in the remote side. | ||
- `data: (Buffer|Object|String)`: Event data. | ||
- `wait: boolean = true`: Wait for the response event handler. | ||
- `opts.wait: boolean = true`: Wait for the response event handler. | ||
- `opts.timeout: number`: Define a custom timeout for the current request. | ||
- `opts.signal: AbortSignal`: Set an abort signal object to cancel the request. | ||
@@ -151,0 +155,0 @@ #### `rpc.on(eventName, handler) => unsubscribe` |
@@ -95,8 +95,8 @@ const { EventEmitter } = require('events') | ||
call (name, data) { | ||
return this[kCreateRequest]({ name, data }) | ||
call (name, data, opts = {}) { | ||
return this[kCreateRequest]({ name, data }, opts) | ||
} | ||
emit (name, data, wait = true) { | ||
return this[kCreateRequest]({ name, data, event: true }, wait) | ||
emit (name, data, opts = {}) { | ||
return this[kCreateRequest]({ name, data, event: true }, opts) | ||
} | ||
@@ -148,6 +148,6 @@ | ||
[kCreateRequest] (packet, wait = true) { | ||
[kCreateRequest] (packet, { timeout, signal, wait = true }) { | ||
assert(packet.name && typeof packet.name === 'string', 'name is required') | ||
if (!wait) { | ||
if (packet.event && !wait) { | ||
return this[kFastCheckOpen]().then(() => this[kNanomessage].send(packet)) | ||
@@ -161,3 +161,3 @@ } | ||
if (errCanceled) throw errCanceled | ||
request = this[kNanomessage].request(packet) | ||
request = this[kNanomessage].request(packet, { timeout, signal }) | ||
this.ee.emit('request-created', request, packet) | ||
@@ -164,0 +164,0 @@ return request |
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
20725
202
Updatednanomessage@^8.3.0