summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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'"""
+