@ironiumstudios/rpc-node
Advanced tools
Comparing version 2.0.7 to 2.0.8
@@ -35,3 +35,3 @@ "use strict"; | ||
throw new Error('Invalid MessagePort.'); | ||
return new worker_receiver_1.WorkerReceiver(this.name, port !== null && port !== void 0 ? port : worker_threads_1.parentPort); | ||
return new worker_receiver_1.WorkerReceiver(this.name, port ?? worker_threads_1.parentPort); | ||
} | ||
@@ -38,0 +38,0 @@ } |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -21,7 +12,7 @@ exports.WorkerReceiver = void 0; | ||
this.port = port; | ||
this.onMessage = (e) => __awaiter(this, void 0, void 0, function* () { | ||
this.onMessage = async (e) => { | ||
if (this.name !== e.name) | ||
return; | ||
const caller = this.createCaller(e.method, e, ...e.args); | ||
const { res, error } = yield this.invokeRemoteHandler(caller); | ||
const { res, error } = await this.invokeRemoteHandler(caller); | ||
this.port.postMessage({ | ||
@@ -33,3 +24,3 @@ id: e.id, | ||
this.observers.notify(caller); | ||
}); | ||
}; | ||
port.on('message', this.onMessage); | ||
@@ -36,0 +27,0 @@ } |
{ | ||
"name": "@ironiumstudios/rpc-node", | ||
"version": "2.0.7", | ||
"version": "2.0.8", | ||
"description": "Type-safe communication between message ports from Node.js worker_threads module", | ||
@@ -10,6 +10,6 @@ "main": "build/index.js", | ||
], | ||
"homepage": "https://github.com/IroniumStudios/base-rpc/blob/master/README.md", | ||
"homepage": "https://github.com/IroniumStudios/ironiumstudios-rpc/blob/master/README.md", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/IroniumStudios/base-rpc.git" | ||
"url": "git+https://github.com/IroniumStudios/ironiumstudios-rpc.git" | ||
}, | ||
@@ -16,0 +16,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
9936
14
107