MCPcopy Create free account
hub / github.com/Distributive-Network/PythonMonkey / Console

Class Console

python/pythonmonkey/builtin_modules/console.js:17–209  ·  view source on GitHub ↗

* @see https://developer.mozilla.org/en-US/docs/Web/API/Console_API * @see https://console.spec.whatwg.org/

Source from the content-addressed store, hash-verified

15 * @see https://console.spec.whatwg.org/
16 */
17class Console
18{
19 /** @type {WriteFn} */
20 #writeToStdout;
21 /** @type {WriteFn} */
22 #writeToStderr;
23
24 /**
25 * @type {{ [label: string]: number; }}
26 * @see https://console.spec.whatwg.org/#counting
27 */
28 #countMap = {};
29
30 #groupLevel = 0;
31
32 /**
33 * @type {{ [label: string]: number; }}
34 * @see https://console.spec.whatwg.org/#timing
35 */
36 #timerTable = {};
37
38 /**
39 * Console constructor, form 1
40 * @overload
41 * @param {IOWriter} stdout - object with write method
42 * @param {IOWriter} stderr - object with write method
43 * @param {boolean=} ignoreErrors - currently unused in PythonMonkey
44 * @see https://nodejs.org/api/console.html#new-consolestdout-stderr-ignoreerrors
45 */
46 /**
47 * Console constructor, form 2
48 * @overload
49 * @param {ConsoleConstructorOptions} options - options object
50 * @typedef {object} ConsoleConstructorOptions
51 * @property {IOWriter} stdout - object with write method
52 * @property {IOWriter} stderr - object with write method
53 * @property {boolean=} ignoreErrors - currently unused in PythonMonkey
54 */
55 constructor(stdout, stderr, ignoreErrors)
56 {
57 var options;
58
59 if (arguments.length === 1)
60 options = stdout;
61 else
62 {
63 if (typeof ignoreErrors === 'undefined')
64 ignoreErrors = true;
65 options = { stdout, stderr, ignoreErrors };
66 }
67
68 this.#writeToStdout = options.stdout.write;
69 this.#writeToStderr = options.stderr.write;
70
71 this.log = (...args) => void this.#writeToStdout(this.#formatToStr(...args));
72 this.debug = (...args) => void this.#writeToStdout(this.#formatToStr(...args));
73 this.info = (...args) => void this.#writeToStdout(this.#formatToStr(...args));
74 this.warn = (...args) => void this.#writeToStderr(this.#formatToStr(...args));

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected