diff options
-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(", ")}]`; } } |