js/jsconsole

  Source   Edit

Wrapper for the console object for the JavaScript backend.

Styled Messages

CSS-styled messages in the browser are useful for debugging purposes. To use them, prefix the message with one or more %c, and provide the CSS style as the last argument. The amount of %c's must match the amount of CSS-styled strings.

Example: cmd: -r:off

import js/jsconsole
console.log "%c My Debug Message", "color: red" # Notice the "%c"
console.log "%c My Debug %c Message", "color: red", "font-size: 2em"

Types

Console = ref object of JsRoot
  Source   Edit

Procs

proc clear(console: Console) {.importjs, varargs, ...raises: [], tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/clear   Source   Edit
proc count(console: Console; label = "".cstring) {.importjs, ...raises: [],
    tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/count   Source   Edit
proc countReset(console: Console; label = "".cstring) {.importjs, ...raises: [],
    tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/countReset   Source   Edit
proc debug(console: Console) {.importjs, varargs, ...raises: [], tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/debug   Source   Edit
func dir(console: Console; obj: auto) {.importjs, ...raises: [], tags: [].}
https://developer.mozilla.org/en-US/docs/Web/API/Console/dir   Source   Edit
func dirxml(console: Console; obj: auto) {.importjs, ...raises: [], tags: [].}
https://developer.mozilla.org/en-US/docs/Web/API/Console/dirxml   Source   Edit
proc error(console: Console) {.importjs, varargs, ...raises: [], tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/error   Source   Edit
proc group(console: Console; label = "".cstring) {.importjs, ...raises: [],
    tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/group   Source   Edit
proc groupCollapsed(console: Console; label = "".cstring) {.importjs,
    ...raises: [], tags: [].}
https://developer.mozilla.org/en-US/docs/Web/API/Console/groupCollapsed   Source   Edit
proc groupEnd(console: Console) {.importjs, ...raises: [], tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/groupEnd   Source   Edit
proc info(console: Console) {.importjs, varargs, ...raises: [], tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/info   Source   Edit
proc log(console: Console) {.importjs, varargs, ...raises: [], tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/log   Source   Edit
proc table(console: Console) {.importjs, varargs, ...raises: [], tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/table   Source   Edit
proc time(console: Console; label = "".cstring) {.importjs, ...raises: [], tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/time   Source   Edit
proc timeEnd(console: Console; label = "".cstring) {.importjs, ...raises: [],
    tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/timeEnd   Source   Edit
proc timeLog(console: Console; label = "".cstring) {.importjs, ...raises: [],
    tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/timeLog   Source   Edit
func timeStamp(console: Console; label: cstring) {.importjs, ...raises: [],
    tags: [].}

https://developer.mozilla.org/en-US/docs/Web/API/Console/timeStamp

..warning:: non-standard

  Source   Edit
proc trace(console: Console) {.importjs, varargs, ...raises: [], tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/trace   Source   Edit
proc warn(console: Console) {.importjs, varargs, ...raises: [], tags: [].}
https://developer.mozilla.org/docs/Web/API/Console/warn   Source   Edit

Templates

template exception(console: Console; args: varargs[untyped])
Alias for console.error().   Source   Edit
template jsAssert(console: Console; assertion)
JavaScript console.assert, for NodeJS this prints to stderr, assert failure just prints to console and do not quit the program, this is not meant to be better or even equal than normal assertions, is just for when you need faster performance and assertions, otherwise use the normal assertions for better user experience. https://developer.mozilla.org/en-US/docs/Web/API/Console/assert

Example:

console.jsAssert(42 == 42) # OK
console.jsAssert(42 != 42) # Fail, prints "Assertion failed" and continues
console.jsAssert('`' == '\n' and '\t' == '\0') # Message correctly formatted
assert 42 == 42  # Normal assertions keep working
  Source   Edit