mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
js: fix printing, make builtins for result and option types behave correctly (#11336)
This commit is contained in:
parent
f33f216698
commit
a9b705bfd8
6 changed files with 382 additions and 244 deletions
|
@ -136,7 +136,7 @@ pub fn (a array) str() string {
|
|||
}
|
||||
|
||||
#array.prototype[Symbol.iterator] = function () { return this.arr[Symbol.iterator](); }
|
||||
#array.prototype.entries = function () { return this.arr.entries(); }
|
||||
#array.prototype.entries = function () { let result = []; for (const [key,val] of this.arr.entries()) { result.push([new int(key), val]); } return result[Symbol.iterator](); }
|
||||
#array.prototype.map = function(callback) { return new builtin.array(this.arr.map(callback)); }
|
||||
#array.prototype.filter = function(callback) { return new array(this.arr.filter( function (it) { return (+callback(it)) != 0; } )); }
|
||||
#Object.defineProperty(array.prototype,'cap',{ get: function () { return this.len; } })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue