summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAndrea Ferretti <ferrettiandrea@gmail.com>2016-09-21 17:35:45 +0200
committerAndrea Ferretti <ferrettiandrea@gmail.com>2016-09-21 17:35:45 +0200
commit693b2b0f5d809570d684fc2a93c9f25ac7f6467d (patch)
treefb3e710abe6f0f98b3d5aad0cfc2b863ab060013 /lib
parent723bc158cea494d3479573819f3e86ce0667409e (diff)
downloadNim-693b2b0f5d809570d684fc2a93c9f25ac7f6467d.tar.gz
Added js console object
Diffstat (limited to 'lib')
-rw-r--r--lib/js/jsconsole.nim32
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