Added functionality and dark mode to doctests. And other changes in maps.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
export class MapList {
|
||||
constructor(active, maps) {
|
||||
constructor(active = null, maps = {}) {
|
||||
this.maps = maps
|
||||
this.active = active
|
||||
|
||||
@@ -40,6 +40,16 @@ export class MapList {
|
||||
return map
|
||||
}
|
||||
|
||||
clone() {
|
||||
let maps = {}
|
||||
|
||||
for (let name of Object.keys(this.maps)) {
|
||||
maps[name] = this.maps[name].clone()
|
||||
}
|
||||
|
||||
return new MapList(this.active, maps)
|
||||
}
|
||||
|
||||
add(key, map) {
|
||||
if (this.maps[key] != null) consol.warn('Key already in mapList. The existing key was overwritten.')
|
||||
map.name = key
|
||||
@@ -47,15 +57,14 @@ export class MapList {
|
||||
}
|
||||
|
||||
get map() {
|
||||
console.log(this.maps, this.active)
|
||||
return this.maps[this.active]
|
||||
return this.maps && this.maps[this.active] ? this.maps[this.active] : null
|
||||
}
|
||||
|
||||
next() {
|
||||
let keys = Object.keys(this.maps)
|
||||
let idx = keys.indexOf(this.active)
|
||||
|
||||
let next = idx + 1 < key.length ? keys[idx + 1] : keys[0]
|
||||
let next = idx + 1 < keys.length ? keys[idx + 1] : keys[0]
|
||||
console.log(keys, idx, next)
|
||||
return next
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user