diff options
author | Brian Cully <bjc@spork.org> | 2025-03-08 15:57:25 -0500 |
---|---|---|
committer | Brian Cully <bjc@spork.org> | 2025-03-08 15:57:25 -0500 |
commit | 7dddcc66611f51bd8998e02dbf287a156ff0dafd (patch) | |
tree | bc7d72be0e1a95a2897f2d58986d093b45526726 | |
parent | c2d1932a24793c85397e3cced8717d6b7586cbd9 (diff) | |
download | chords-7dddcc66611f51bd8998e02dbf287a156ff0dafd.tar.gz chords-7dddcc66611f51bd8998e02dbf287a156ff0dafd.zip |
js: clean up scale a bit
be explicit about the underlying storage for first/third/etc
-rw-r--r-- | scale.mjs | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -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(", ")}]`; } } |