summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Cully <bjc@spork.org>2025-03-08 15:57:25 -0500
committerBrian Cully <bjc@spork.org>2025-03-08 15:57:25 -0500
commit7dddcc66611f51bd8998e02dbf287a156ff0dafd (patch)
treebc7d72be0e1a95a2897f2d58986d093b45526726
parentc2d1932a24793c85397e3cced8717d6b7586cbd9 (diff)
downloadchords-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.mjs18
1 files 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(", ")}]`;
}
}