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.
func copyWithin[T](self: openArray[T]; target, start, ends: int): seq[T] {.
importjs: "#.copyWithin(#, #, #)", ...raises: [], tags: [], forbids: [].}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 debugger() {.importjs: "debugger@", ...raises: [], tags: [], forbids: [].}proc newDate(): DateTime {.importcpp: "new Date()", ...raises: [], tags: [],
forbids: [].}proc newDate(date: int | string): DateTime {.importcpp: "new Date(#)",
...raises: [], tags: [], forbids: [].}func queueMicrotask(function: proc) {.importjs: "$1(#)", ...raises: [], tags: [],
forbids: [].}Example: cmd: -r:off
queueMicrotask(proc() = echo "Microtask")Source Edit
func shift[T](self: seq[T]): T {.importjs: "#.$1()", ...raises: [], tags: [],
forbids: [].}Example:
var arrai = @[1, 2, 3] assert arrai.shift() == 1 assert arrai == @[2, 3]Source Edit
© 2006–2024 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/jscore.html