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

Version Path
learn_create-0.0.22 lib/templates/javascript_lab_template/node_modules/jsdom/lib/jsdom/virtual-console.js
lanes-0.8.0 node_modules/jsdom/lib/jsdom/virtual-console.js
select_all-rails-0.3.1 node_modules/jsdom/lib/jsdom/virtual-console.js