From 7dddcc66611f51bd8998e02dbf287a156ff0dafd Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Sat, 8 Mar 2025 15:57:25 -0500 Subject: js: clean up scale a bit be explicit about the underlying storage for first/third/etc --- scale.mjs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scale.mjs b/scale.mjs index fe4e5f2..b781f14 100644 --- a/scale.mjs +++ b/scale.mjs @@ -39,26 +39,34 @@ class Scale { this.scale = scaleFromIntervals(root, intervals); return new Proxy(this, { get(target, prop) { - return target.scale[prop] || Reflect.get(...arguments); + if (prop in target) { + return target[prop]; + } else { + return target.scale[prop] || Reflect.get(...arguments); + } } }); } get root() { - return this[0]; + return this.scale[0]; } get third() { - return this[2]; + return this.scale[2]; } get fifth() { - return this[4]; + return this.scale[4]; } get length() { console.debug(`get length`, this.scale.length); - return this.intervals.length; + return this.scale.length; + } + + toString() { + return `[${this.scale.join(", ")}]`; } } -- cgit v1.2.3