UNPKG

expressmultithread

Version:

Fast, light-weight and low dependency [Express.js](https://www.npmjs.com/package/express) multithreaded router.

46 lines 1.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.overrideRes = void 0; const strings_1 = require("../constants/strings"); const types_1 = require("../types"); const postMessage_1 = require("./utils/postMessage"); const handler = { get(target, prop, receiver) { if (prop === "_id" || prop === "_tid") { return target[prop]; } if (prop === "transferCall") { return function (call, ...args) { (0, postMessage_1.postParent)({ cmd: types_1.ChildCmd.response, call, args, id: target._id, tid: target._tid }); return receiver; }; } const notImpl = ["format", "get"]; if (notImpl.includes(prop)) { return function () { throw new Error(strings_1.notImplemented); }; } return function (...args) { return receiver.transferCall(prop, ...args); }; }, set(target, prop, value) { if (prop === "_id" || prop === "_tid") { target[prop] = value; } return value; } }; function overrideRes(_id, _tid) { const target = { _id, _tid }; return new Proxy(target, handler); } exports.overrideRes = overrideRes; //# sourceMappingURL=overrideRes.js.map