summary refs log tree commit diff stats
path: root/lib/std
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2021-02-15 04:28:11 -0600
committerGitHub <noreply@github.com>2021-02-15 11:28:11 +0100
commit240879bf3d746059accd73deacc7405c53aa0704 (patch)
treea1466ff3fb67d66316604e4de95303c7e6863345 /lib/std
parentc8d99631503b03266db14967495c0a1b250ab327 (diff)
downloadNim-240879bf3d746059accd73deacc7405c53aa0704.tar.gz
array literals uses typed arrays; fix a jsgen bug (#16850)
* array litterals uses typed arrays
* Update compiler/jsgen.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/private/jsutils.nim8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/std/private/jsutils.nim b/lib/std/private/jsutils.nim
index aa2e984ff..14104261e 100644
--- a/lib/std/private/jsutils.nim
+++ b/lib/std/private/jsutils.nim
@@ -23,8 +23,16 @@ when defined(js):
   func `[]=`*(arr: Float64Array, i: int, v: float) {.importjs: "#[#] = #".}
 
 
+  proc jsTypeOf*[T](x: T): cstring {.importjs: "typeof(#)".}
+  ## Returns the name of the JsObject's JavaScript type as a cstring.
+  # xxx replace jsffi.jsTypeOf with this definition and add tests
+
+  proc jsConstructorName*[T](a: T): cstring =
+    asm """`result` = `a`.constructor.name"""
+
   proc hasJsBigInt*(): bool =
     asm """`result` = typeof BigInt != 'undefined'"""
 
   proc hasBigUint64Array*(): bool =
     asm """`result` = typeof BigUint64Array != 'undefined'"""
+