* @see https://developer.mozilla.org/en-US/docs/Web/API/Console_API * @see https://console.spec.whatwg.org/
| 15 | * @see https://console.spec.whatwg.org/ |
| 16 | */ |
| 17 | class 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)); |
nothing calls this directly
no outgoing calls
no test coverage detected