UNPKG

4.19 kBJavaScriptView Raw
1var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2 return new (P || (P = Promise))(function (resolve, reject) {
3 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
5 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
6 step((generator = generator.apply(thisArg, _arguments || [])).next());
7 });
8};
9var __generator = (this && this.__generator) || function (thisArg, body) {
10 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
11 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12 function verb(n) { return function (v) { return step([n, v]); }; }
13 function step(op) {
14 if (f) throw new TypeError("Generator is already executing.");
15 while (_) try {
16 if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
17 if (y = 0, t) op = [0, t.value];
18 switch (op[0]) {
19 case 0: case 1: t = op; break;
20 case 4: _.label++; return { value: op[1], done: false };
21 case 5: _.label++; y = op[1]; op = [0]; continue;
22 case 7: op = _.ops.pop(); _.trys.pop(); continue;
23 default:
24 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
25 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
26 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
27 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
28 if (t[2]) _.ops.pop();
29 _.trys.pop(); continue;
30 }
31 op = body.call(thisArg, _);
32 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
33 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
34 }
35};
36Object.defineProperty(exports, "__esModule", { value: true });
37var process_1 = require("process");
38var exception_1 = require("../exception");
39var InterprocessOutput = (function () {
40 function InterprocessOutput(options) {
41 }
42 InterprocessOutput.prototype.initialize = function () {
43 if (process_1.connected === false) {
44 throw new exception_1.RuntimeException('This application is not connected to a parent application and therefore cannot use the IPC functionality');
45 }
46 };
47 InterprocessOutput.prototype.write = function (snapshot) {
48 return __awaiter(this, void 0, void 0, function () {
49 return __generator(this, function (_a) {
50 this.send(snapshot);
51 return [2 /*return*/];
52 });
53 });
54 };
55 InterprocessOutput.prototype.exception = function (exception) {
56 return __awaiter(this, void 0, void 0, function () {
57 return __generator(this, function (_a) {
58 this.send({
59 exception: {
60 name: exception.name,
61 message: exception.message,
62 stack: exception.stack,
63 originalStack: exception.originalStack,
64 zoneAwareStack: exception.zoneAwareStack
65 }
66 });
67 return [2 /*return*/];
68 });
69 });
70 };
71 InterprocessOutput.prototype.send = function (message) {
72 if (process.send == null) {
73 throw new exception_1.RuntimeException("Process (" + process.pid + ") is not connected to a parent process");
74 }
75 return Promise.resolve(process.send(message));
76 };
77 return InterprocessOutput;
78}());
79exports.InterprocessOutput = InterprocessOutput;
80//# sourceMappingURL=interprocess.js.map
\No newline at end of file