UNPKG

expressmultithread

Version:

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

41 lines 1.25 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 internalProps = ["_id", "_tid"]; const notImplementedProps = ["format", "get"]; const handler = { get(target, prop, receiver) { if (internalProps.includes(prop)) { return target[prop]; } if (notImplementedProps.includes(prop)) { return function () { throw new Error(strings_1.notImplemented); }; } return function (...args) { (0, postMessage_1.postParent)({ cmd: types_1.ChildCmd.response, call: prop, args, id: target._id, tid: target._tid }); return receiver; }; }, set(target, prop, value) { if (internalProps.includes(prop)) { target[prop] = value; } return value; } }; function overrideRes(_id, _tid) { return new Proxy({ _id, _tid }, handler); } exports.overrideRes = overrideRes; //# sourceMappingURL=overrideRes.js.map