diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/js/jsconsole.nim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/js/jsconsole.nim b/lib/js/jsconsole.nim new file mode 100644 index 000000000..7bdc8922e --- /dev/null +++ b/lib/js/jsconsole.nim @@ -0,0 +1,32 @@ +# +# +# Nim's Runtime Library +# (c) Copyright 2012 Andreas Rumpf +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +## Wrapper for the `console` object for the `JavaScript backend +## <backends.html#the-javascript-target>`_. + +when not defined(js) and not defined(Nimdoc): + {.error: "This module only works on the JavaScript platform".} + +type Console* {.importc.} = ref object of RootObj + +{.push importcpp .} + +proc log*[A](console: Console, a: A) +proc debug*[A](console: Console, a: A) +proc info*[A](console: Console, a: A) +proc error*[A](console: Console, a: A) + +{.pop.} + +proc log*(console: Console, a: string) = console.log(cstring(a)) +proc debug*(console: Console, a: string) = console.log(cstring(a)) +proc info*(console: Console, a: string) = console.log(cstring(a)) +proc error*(console: Console, a: string) = console.log(cstring(a)) + +var console* {.importc, nodecl.}: Console \ No newline at end of file |