This module wraps core JavaScript functions.
Unless your application has very specific requirements and solely targets JavaScript, you should be using the relevant functions in the math, json, and times stdlib modules instead.
Procs
proc abs(m: MathLib; a: SomeNumber): SomeNumber {.importcpp, ...raises: [], tags: [].}
- Source Edit
func copyWithin[T](self: openArray[T]; target, start, ends: int): seq[T] {. importjs: "#.copyWithin(#, #, #)", ...raises: [], tags: [].}
-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin copyWithin uses shallow copy.
Example:
assert ['a', 'b', 'c', 'd', 'e'].copyWithin(0, 3, 4) == @['d', 'b', 'c', 'd', 'e'] assert ['a', 'b', 'c', 'd', 'e'].copyWithin(1, 3) == @['a', 'd', 'e', 'd', 'e'] assert [1, 2, 3, 4, 5].copyWithin(-2) == @[1, 2, 3, 1, 2] assert [1, 2, 3, 4, 5].copyWithin(0, 3) == @[4, 5, 3, 4, 5] assert [1, 2, 3, 4, 5].copyWithin(0, 3, 4) == @[4, 2, 3, 4, 5] assert [1, 2, 3, 4, 5].copyWithin(-2, -3, -1) == @[1, 2, 3, 3, 4]
Source Edit func copyWithin[T](self: openArray[T]; target, start: int): seq[T] {. importjs: "#.copyWithin(#, #)", ...raises: [], tags: [].}
- Source Edit
func copyWithin[T](self: openArray[T]; target: int): seq[T] {. importjs: "#.copyWithin(#)", ...raises: [], tags: [].}
- Source Edit
func debugger() {.importjs: "debugger@", ...raises: [], tags: [].}
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger Source Edit
proc getFullYear(d: DateTime): int {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc getMilliseconds(d: DateTime): int {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc getMinutes(d: DateTime): int {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc getSeconds(d: DateTime): int {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc getTimezoneOffset(d: DateTime): int {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc getUTCDate(d: DateTime): int {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc getUTCFullYear(d: DateTime): int {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc getUTCHours(d: DateTime): int {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc getUTCMilliseconds(d: DateTime): int {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc getUTCMinutes(d: DateTime): int {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc getUTCMonth(d: DateTime): int {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc getUTCSeconds(d: DateTime): int {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc hypot(m: MathLib; args: varargs[distinct SomeNumber]): float {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc max(m: MathLib; a, b: SomeNumber): SomeNumber {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc min[T: SomeNumber | JsRoot](m: MathLib; a, b: T): T {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc newDate(date: int | int64 | string): DateTime {.importcpp: "new Date(#)", ...raises: [], tags: [].}
- Source Edit
proc newDate(year, month, day, hours, minutes, seconds, milliseconds: int): DateTime {. importcpp: "new Date(#,#,#,#,#,#,#)", ...raises: [], tags: [].}
- Source Edit
proc pow(m: MathLib; a, b: distinct SomeNumber): float {.importcpp, ...raises: [], tags: [].}
- Source Edit
proc setFullYear(d: DateTime; year: int) {.importcpp, ...raises: [], tags: [].}
- Source Edit