@platformatic/itc
Advanced tools
Comparing version 2.0.0-alpha.3 to 2.0.0-alpha.4
@@ -41,4 +41,5 @@ 'use strict' | ||
const request = this.#generateRequest(name, message) | ||
this.port.postMessage(request) | ||
this._send(request) | ||
const responsePromise = once(this.#requestEmitter, request.reqId).then(([response]) => response) | ||
@@ -53,3 +54,3 @@ | ||
async notify (name, message) { | ||
this.port.postMessage(this.#generateNotification(name, message)) | ||
this._send(this.#generateNotification(name, message)) | ||
} | ||
@@ -67,3 +68,3 @@ | ||
this.port.on('message', message => { | ||
this._setupListener(message => { | ||
const messageType = message.type | ||
@@ -86,3 +87,3 @@ if (messageType === PLT_ITC_REQUEST_TYPE) { | ||
this.#closePromise = once(this.port, 'close').then(() => { | ||
this.#closePromise = this._createClosePromise().then(() => { | ||
this.#listening = false | ||
@@ -100,2 +101,18 @@ const error = new errors.MessagePortClosed() | ||
this._close() | ||
} | ||
_setupListener (listener) { | ||
this.port.on('message', listener) | ||
} | ||
_send (request) { | ||
this.port.postMessage(request) | ||
} | ||
_createClosePromise () { | ||
return once(this.port, 'close') | ||
} | ||
_close () { | ||
this.port.close() | ||
@@ -138,3 +155,3 @@ } | ||
this.port.postMessage(response) | ||
this._send(response) | ||
@@ -164,3 +181,3 @@ if (this.#closeAfterCurrentRequest) { | ||
response = this.#generateUnhandledErrorResponse(error) | ||
this.port.postMessage(response) | ||
this._send(response) | ||
return | ||
@@ -167,0 +184,0 @@ } |
{ | ||
"name": "@platformatic/itc", | ||
"version": "2.0.0-alpha.3", | ||
"version": "2.0.0-alpha.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
34447
675