refactor: fix

This commit is contained in:
xiaojunnuo
2021-02-07 10:54:55 +08:00
parent b9d5d33aaa
commit 6eb9817296
5 changed files with 1535 additions and 112 deletions
+8 -4
View File
@@ -1,6 +1,6 @@
export class Registry {
constructor () {
this.collection = {}
this.collection = new Map()
}
install (target) {
@@ -8,7 +8,7 @@ export class Registry {
return
}
if (this.collection == null) {
this.collection = {}
this.collection = new Map()
}
let defineName = target.define ? target.define().name : null
if (defineName == null) {
@@ -22,14 +22,18 @@ export class Registry {
if (!key || value == null) {
return
}
this.collection[key] = value
this.collection.set(key, value)
}
get (name) {
if (name) {
return this.collection[name]
return this.collection.get(name)
}
throw new Error(`${name} not found`)
}
getCollection () {
return this.collection
}
}