From f6e7c009444f5d56fd308cd99efa12ff8010ed07 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 22 Jan 2024 10:32:35 +0100 Subject: [PATCH] [WIP] Refactor get/set with `arguments` --- state.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/state.js b/state.js index 6b8c072..e054627 100644 --- a/state.js +++ b/state.js @@ -164,17 +164,13 @@ export class State extends SimpleState { } } - set(...args) { - if (args.length === 1) return this.set("value", ...args) - - const [prop, value] = args + set(prop, value) { + if (arguments.length === 1) return this.set("value", prop) this.#target[prop] = value } - get(...args) { - if (args.length === 0) return this.get("value") - - const prop = args[0] + get(prop) { + if (arguments.length === 0) return this.get("value") return this.#target[prop] } }