Add Array.shift (#19811)

* Add Array.shift for JavaScript targets

* Add Array.shift for JavaScript targets
This commit is contained in:
Juan Carlos 2022-05-24 12:37:19 -03:00 • committed by GitHub
commit b1b5e3ab10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -123,3 +123,12 @@ since (1, 5):
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]
since (1, 7):
func shift*[T](self: seq[T]): T {.importjs: "#.$1()".} =
## https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
runnableExamples:
var arrai = @[1, 2, 3]
assert arrai.shift() == 1
assert arrai == @[2, 3]