Allow calling get
and set
without property name
This commit is contained in:
parent
5726b8c2b9
commit
69a2aa1ca3
1 changed files with 11 additions and 2 deletions
13
state.js
13
state.js
|
@ -146,13 +146,22 @@ export class State extends SimpleState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set(prop, value) {
|
set(...args) {
|
||||||
|
if (args.length === 1) return this.set("value", ...args)
|
||||||
|
|
||||||
|
const [prop, value] = args
|
||||||
this.#target[prop] = value
|
this.#target[prop] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
get(prop) {
|
get(...args) {
|
||||||
|
if (args.length === 0) return this.get("value")
|
||||||
|
|
||||||
|
const prop = args[0]
|
||||||
return this.#target[prop]
|
return this.#target[prop]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Backwards compatibility
|
||||||
|
get proxy() { return this.values }
|
||||||
}
|
}
|
||||||
|
|
||||||
const forwardFinalizationRegistry = new FinalizationRegistry(([cache, name]) => {
|
const forwardFinalizationRegistry = new FinalizationRegistry(([cache, name]) => {
|
||||||
|
|
Loading…
Reference in a new issue