UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

48 lines (47 loc) 2.06 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var Common_js_1 = require("../../../generic/util/Common.js"); var ChannelEndPoint_js_1 = require("../../../generic/channel/ChannelEndPoint.js"); var NodeJsLogger_js_1 = require("../../util/role/NodeJsLogger.js"); exports.ParentEndPoint = /** @class */ (function (_super) { __extends(class_1, _super); function class_1() { return _super !== null && _super.apply(this, arguments) || this; } class_1.prototype.doConnect = function (channel) { var _this = this; var childProcess = this.childProcess = channel; childProcess.addListener('message', this.messageListener = this.onRawChannelMessage.bind(this)); childProcess.on('exit', function () { _this.debug('NodeJS worker process exit'); _this.doDisconnect(); }); return Promise.resolve(); }; class_1.prototype.doDisconnect = function () { this.messageListener && this.childProcess.removeListener('message', this.messageListener); }; class_1.prototype.sendMessage = function (message) { this.childProcess.send(message); }; class_1.prototype.messageToEnvelop = function (message) { return message; }; class_1.prototype.envelopToMessage = function (envelop) { return envelop; }; return class_1; }(ChannelEndPoint_js_1.ChannelEndPoint(NodeJsLogger_js_1.NodeJsLogger(Common_js_1.Base))));