[WIP] Refactor get/set with arguments
This commit is contained in:
parent
2b8ba6e7d6
commit
f6e7c00944
1 changed files with 4 additions and 8 deletions
12
state.js
12
state.js
|
@ -164,17 +164,13 @@ export class State extends SimpleState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set(...args) {
|
set(prop, value) {
|
||||||
if (args.length === 1) return this.set("value", ...args)
|
if (arguments.length === 1) return this.set("value", prop)
|
||||||
|
|
||||||
const [prop, value] = args
|
|
||||||
this.#target[prop] = value
|
this.#target[prop] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
get(...args) {
|
get(prop) {
|
||||||
if (args.length === 0) return this.get("value")
|
if (arguments.length === 0) return this.get("value")
|
||||||
|
|
||||||
const prop = args[0]
|
|
||||||
return this.#target[prop]
|
return this.#target[prop]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue