UNPKG

html-reporter

Version:

Html-reporter and GUI for viewing and managing results of a tests run. Currently supports Testplane and Hermione.

29 lines 1.04 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.EventSource = void 0; const json_stringify_safe_1 = __importDefault(require("json-stringify-safe")); const constants_1 = require("./constants"); class EventSource { constructor() { this._connections = []; } _write(connection, event, data) { connection.write('event: ' + event + '\n'); connection.write('data: ' + (0, json_stringify_safe_1.default)(data) + '\n'); connection.write('\n\n'); } addConnection(connection) { this._connections.push(connection); this._write(connection, constants_1.ClientEvents.CONNECTED, 1); } emit(event, data) { this._connections.forEach((connection) => { this._write(connection, event, data); }); } } exports.EventSource = EventSource; //# sourceMappingURL=event-source.js.map