summary refs log tree commit diff stats
path: root/lib/std
diff options
context:
space:
mode:
authorflywind <xzsflywind@gmail.com>2021-03-19 23:54:10 +0800
committerGitHub <noreply@github.com>2021-03-19 16:54:10 +0100
commite332c20ba7f0fffc0ad42751a99e11232973f27f (patch)
treeb57e29a8f4352ce1f655bc01066a5924673bf536 /lib/std
parent6c1c8f51b38c9bc570a70ec8d2836b823d3584cc (diff)
downloadNim-e332c20ba7f0fffc0ad42751a99e11232973f27f.tar.gz
follow up #17276 (#17355)
* improve test coverage for isolation

* a bit better

* rename channels to channels_builtin

* follow up #17276

* fix

* Update lib/std/private/jsutils.nim
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/private/jsutils.nim12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/std/private/jsutils.nim b/lib/std/private/jsutils.nim
index cf58b3b81..32c717c56 100644
--- a/lib/std/private/jsutils.nim
+++ b/lib/std/private/jsutils.nim
@@ -1,4 +1,4 @@
-when defined(js):
+when defined(js) or defined(nimdoc):
   import std/jsbigints
 
   type
@@ -40,4 +40,12 @@ when defined(js):
 
   proc isInteger*[T](x: T): bool {.importjs: "Number.isInteger(#)".}
 
-  proc isSafeInteger*[T](x: T): bool {.importjs: "Number.isSafeInteger(#)".}
+  proc isSafeInteger*[T](x: T): bool {.importjs: "Number.isSafeInteger(#)".} =
+    runnableExamples:
+      import std/jsffi
+      assert not "123".toJs.isSafeInteger
+      assert 123.toJs.isSafeInteger
+      assert 9007199254740991.toJs.isSafeInteger
+      assert not 9007199254740992.toJs.isSafeInteger
+
+  let maxSafeInteger* {.importjs: "Number.MAX_SAFE_INTEGER".} : int64