js: add more tests & add array prepend codegen (#10988)

This commit is contained in:
playX 2021-07-29 11:39:36 +03:00 committed by GitHub
parent 08aa6c08f6
commit 75c41252d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 217 additions and 3 deletions

View file

@ -149,3 +149,14 @@ pub fn (mut a array) delete(i int) {
pub fn (mut a array) delete_many(i int, size int) {
#a.arr.splice(i.valueOf(),size.valueOf())
}
// prepend prepends one value to the array.
pub fn (mut a array) prepend(val voidptr) {
a.insert(0, val)
}
// prepend_many prepends another array to this array.
[unsafe]
pub fn (mut a array) prepend_many(val voidptr, size int) {
unsafe { a.insert_many(0, val, size) }
}