2021-07-15 16:36:53 +02:00
|
|
|
module builtin
|
|
|
|
|
|
|
|
struct map {
|
|
|
|
m JS.Map
|
|
|
|
len int
|
|
|
|
}
|
|
|
|
|
|
|
|
// Removes the mapping of a particular key from the map.
|
|
|
|
[unsafe]
|
|
|
|
pub fn (mut m map) delete(key voidptr) {
|
2021-07-24 14:35:17 +02:00
|
|
|
#m.map.delete(key)
|
2021-07-15 16:36:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (m &map) free() {}
|
2021-07-24 14:35:17 +02:00
|
|
|
|
|
|
|
#map.prototype[Symbol.iterator] = function () { return this.map[Symbol.iterator](); }
|
2021-08-07 16:58:49 +02:00
|
|
|
|
|
|
|
#map.prototype.toString = function () {
|
|
|
|
#function fmtKey(key) { return typeof key == 'string' ? '\'' + key + '\'' : key}
|
|
|
|
#let res = '{'
|
|
|
|
#for (const entry of this) {
|
|
|
|
#res += fmtKey(entry[0]) + ': ' + entry[0];
|
|
|
|
#}
|
|
|
|
#res += '}'
|
|
|
|
#return res;
|
|
|
|
#}
|