diff options
Diffstat (limited to 'lib/std')
-rw-r--r-- | lib/std/exitprocs.nim | 2 | ||||
-rw-r--r-- | lib/std/jsbigints.nim | 4 | ||||
-rw-r--r-- | lib/std/private/jsutils.nim | 17 |
3 files changed, 19 insertions, 4 deletions
diff --git a/lib/std/exitprocs.nim b/lib/std/exitprocs.nim index 48b4fca7f..36f22a5d1 100644 --- a/lib/std/exitprocs.nim +++ b/lib/std/exitprocs.nim @@ -10,6 +10,8 @@ ## This module allows adding hooks to program exit. import locks +when defined(js) and not defined(nodejs): + import std/assertions type FunKind = enum kClosure, kNoconv # extend as needed diff --git a/lib/std/jsbigints.nim b/lib/std/jsbigints.nim index 04578fc87..fda299e7b 100644 --- a/lib/std/jsbigints.nim +++ b/lib/std/jsbigints.nim @@ -64,10 +64,10 @@ func wrapToUint*(this: JsBigInt; bits: Natural): JsBigInt {.importjs: runnableExamples: doAssert (big("3") + big("2") ** big("66")).wrapToUint(66) == big("3") -func toNumber*(this: JsBigInt): BiggestInt {.importjs: "Number(#)".} = +func toNumber*(this: JsBigInt): int {.importjs: "Number(#)".} = ## Does not do any bounds check and may or may not return an inexact representation. runnableExamples: - doAssert toNumber(big"2147483647") == 2147483647.BiggestInt + doAssert toNumber(big"2147483647") == 2147483647.int func `+`*(x, y: JsBigInt): JsBigInt {.importjs: "(# $1 #)".} = runnableExamples: diff --git a/lib/std/private/jsutils.nim b/lib/std/private/jsutils.nim index 836b3512a..fd1f395f3 100644 --- a/lib/std/private/jsutils.nim +++ b/lib/std/private/jsutils.nim @@ -79,5 +79,18 @@ when defined(js): assert not "123".toJs.isSafeInteger assert 123.isSafeInteger assert 123.toJs.isSafeInteger - assert 9007199254740991.toJs.isSafeInteger - assert not 9007199254740992.toJs.isSafeInteger + when false: + assert 9007199254740991.toJs.isSafeInteger + assert not 9007199254740992.toJs.isSafeInteger + +template whenJsNoBigInt64*(no64, yes64): untyped = + when defined(js): + when compiles(compileOption("jsbigint64")): + when compileOption("jsbigint64"): + yes64 + else: + no64 + else: + no64 + else: + no64 |