Sha256: b65a398845036b4f84ac480b52a39a35ba269f1a3da7f1c86db32ac61ac5ae7d
Contents?: true
Size: 782 Bytes
Versions: 3
Compression:
Stored size: 782 Bytes
Contents
"use strict"; const EventEmitter = require("events").EventEmitter; module.exports = class VirtualConsole extends EventEmitter { constructor() { super(); this.on("error", () => { // If "error" event has no listeners, // EventEmitter throws an exception }); } sendTo(anyConsole, options) { if (options === undefined) { options = {}; } for (const method of Object.keys(anyConsole)) { if (typeof anyConsole[method] === "function") { function onMethodCall() { anyConsole[method].apply(anyConsole, arguments); } this.on(method, onMethodCall); } } if (!options.omitJsdomErrors) { this.on("jsdomError", e => anyConsole.error(e.stack, e.detail)); } return this; } };
Version data entries
3 entries across 3 versions & 3 rubygems