std/jscore (original) (raw)

func copyWithin[T](self: openArray[T]; target, start, ends: int): seq[T] {. importjs: "#.copyWithin(#, #, #)", ...raises: [], tags: [], forbids: [].}

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: [], forbids: [].}

Source Edit

func copyWithin[T](self: openArray[T]; target: int): seq[T] {. importjs: "#.copyWithin(#)", ...raises: [], tags: [], forbids: [].}

Source Edit

proc newDate(): DateTime {.importcpp: "new Date()", ...raises: [], tags: [], forbids: [].}

Source Edit

proc newDate(year, month, day, hours, minutes, seconds, milliseconds: int): DateTime {. importcpp: "new Date(#,#,#,#,#,#,#)", ...raises: [], tags: [], forbids: [].}

Source Edit