From 9849fd84ec48d18bd5aaff5a41b8c35dcd4c8753 Mon Sep 17 00:00:00 2001 From: QLabs <55121845+Quantalabs@users.noreply.github.com> Date: Sun, 7 Apr 2024 19:14:56 -0700 Subject: [PATCH 1/6] fix: :bug: stop misinterpreting add chords Fix chords when notated as "Madd4" --- index.js | 6 +++--- test/chords.js | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 41e09be..d51833e 100644 --- a/index.js +++ b/index.js @@ -58,8 +58,9 @@ module.exports = function(symbol) { var sub2 = (i + 1) < len ? symbol.substr(i, 2).toLowerCase() : null; if (sub3 in SYMBOLS) name = sub3; - else if (sub2 in SYMBOLS) - name = sub2; + else if (sub2 in SYMBOLS && symbol.substr(i + 1, 3).toLowerCase() !== "add") + {name = sub2; + console.log(sub2);} else if (c in SYMBOLS) name = c; else @@ -71,7 +72,6 @@ module.exports = function(symbol) { if (name === 'M' || name === 'ma' || name === 'maj') explicitMajor = true; - i += name.length - 1; parsing = 'extension'; } else if (parsing === 'extension') { diff --git a/test/chords.js b/test/chords.js index fb2da8b..f365595 100644 --- a/test/chords.js +++ b/test/chords.js @@ -19,6 +19,8 @@ test('Parsing chops', function(t) { t.deepEqual(daccord('mi7'), ['P1', 'm3', 'P5', 'm7']); t.deepEqual(daccord('M'), ['P1', 'M3', 'P5']); t.deepEqual(daccord('Ma'), ['P1', 'M3', 'P5']); + t.deepEqual(daccord('Madd11'), ['P1', 'M3', 'P5', 'P11']); + t.deepEqual(daccord('madd11'), ['P1', 'm3', 'P5', 'P11']) t.deepEqual(daccord('M#5'), ['P1', 'M3', 'A5']); t.deepEqual(daccord('maj7'), ['P1', 'M3', 'P5', 'M7']); t.deepEqual(daccord('+'), ['P1', 'M3', 'A5']); From 9c43ad6dd2eb8edc57fe14fbac8aed0dab372bbd Mon Sep 17 00:00:00 2001 From: QLabs <55121845+Quantalabs@users.noreply.github.com> Date: Sun, 7 Apr 2024 20:07:01 -0700 Subject: [PATCH 2/6] style: :art: add missing semicolon --- test/chords.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/chords.js b/test/chords.js index f365595..0ee92a1 100644 --- a/test/chords.js +++ b/test/chords.js @@ -20,7 +20,7 @@ test('Parsing chops', function(t) { t.deepEqual(daccord('M'), ['P1', 'M3', 'P5']); t.deepEqual(daccord('Ma'), ['P1', 'M3', 'P5']); t.deepEqual(daccord('Madd11'), ['P1', 'M3', 'P5', 'P11']); - t.deepEqual(daccord('madd11'), ['P1', 'm3', 'P5', 'P11']) + t.deepEqual(daccord('madd11'), ['P1', 'm3', 'P5', 'P11']); t.deepEqual(daccord('M#5'), ['P1', 'M3', 'A5']); t.deepEqual(daccord('maj7'), ['P1', 'M3', 'P5', 'M7']); t.deepEqual(daccord('+'), ['P1', 'M3', 'A5']); From f913463eab7f089d0eaee11c7bcdda265c355727 Mon Sep 17 00:00:00 2001 From: QLabs <55121845+Quantalabs@users.noreply.github.com> Date: Sun, 7 Apr 2024 20:19:16 -0700 Subject: [PATCH 3/6] fix: :bug: use M7 instead of m7 by default --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index d51833e..ae28a2b 100644 --- a/index.js +++ b/index.js @@ -35,7 +35,7 @@ var SYMBOLS = { module.exports = function(symbol) { var c, parsing = 'quality', additionals = [], name, chordLength = 2 - var notes = ['P1', 'M3', 'P5', 'm7', 'M9', 'P11', 'M13']; + var notes = ['P1', 'M3', 'P5', 'M7', 'M9', 'P11', 'M13']; var explicitMajor = false; function setChord(name) { From e29b0adfcb5d44cd6c1362aae65680ca852fbf97 Mon Sep 17 00:00:00 2001 From: QLabs <55121845+Quantalabs@users.noreply.github.com> Date: Sun, 7 Apr 2024 20:20:34 -0700 Subject: [PATCH 4/6] refactor: remove extra console.log statement --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index ae28a2b..5ce9fee 100644 --- a/index.js +++ b/index.js @@ -59,8 +59,7 @@ module.exports = function(symbol) { if (sub3 in SYMBOLS) name = sub3; else if (sub2 in SYMBOLS && symbol.substr(i + 1, 3).toLowerCase() !== "add") - {name = sub2; - console.log(sub2);} + name = sub2; else if (c in SYMBOLS) name = c; else From d9ed1ff07b8031d57b002ee544eeb53ec5c8f420 Mon Sep 17 00:00:00 2001 From: QLabs <55121845+Quantalabs@users.noreply.github.com> Date: Sun, 7 Apr 2024 20:25:07 -0700 Subject: [PATCH 5/6] feat: :sparkles: include add2 and add4 chords --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 5ce9fee..2966f25 100644 --- a/index.js +++ b/index.js @@ -150,6 +150,10 @@ module.exports = function(symbol) { additionals.push('P11'); else if (next === '13') additionals.push('M13'); + else if (next === '4') + additionals.push('P4'); + else if (next === '2') + additionals.push('M2'); else { throw ParseError({ title: 'Invalid token', From 7b75248c47ee70a3147683f29e37dc34ab68fc63 Mon Sep 17 00:00:00 2001 From: QLabs <55121845+Quantalabs@users.noreply.github.com> Date: Sun, 7 Apr 2024 20:36:27 -0700 Subject: [PATCH 6/6] revert: :rewind: f913463eab7f089d0eaee11c7bcdda265c355727 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 2966f25..2290e57 100644 --- a/index.js +++ b/index.js @@ -35,7 +35,7 @@ var SYMBOLS = { module.exports = function(symbol) { var c, parsing = 'quality', additionals = [], name, chordLength = 2 - var notes = ['P1', 'M3', 'P5', 'M7', 'M9', 'P11', 'M13']; + var notes = ['P1', 'M3', 'P5', 'm7', 'M9', 'P11', 'M13']; var explicitMajor = false; function setChord(name) {