1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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
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) }
}