summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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(", ")}]`;
}
}