Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("notesSame", function() {
expect(notesSame("C5", "C6")).toBe(true);
expect(notesSame("C5", "C5")).toBe(true);
expect(notesSame("C5", "D5")).toBe(false);
expect(notesSame("C#5", "C5")).toBe(false);
expect(notesSame("Ab5", "A3")).toBe(false);
expect(notesSame("Db5", "Db6")).toBe(true);
expect(notesSame("G#5", "G#7")).toBe(true);
// wrapping
expect(notesSame("B#5", "C6")).toBe(true);
expect(notesSame("B#5", "C7")).toBe(true);
expect(notesSame("B3", "Cb5")).toBe(true);
expect(notesSame("B5", "Cb3")).toBe(true);
});
it("notesSame", function() {
expect(notesSame("C5", "C6")).toBe(true);
expect(notesSame("C5", "C5")).toBe(true);
expect(notesSame("C5", "D5")).toBe(false);
expect(notesSame("C#5", "C5")).toBe(false);
expect(notesSame("Ab5", "A3")).toBe(false);
expect(notesSame("Db5", "Db6")).toBe(true);
expect(notesSame("G#5", "G#7")).toBe(true);
// wrapping
expect(notesSame("B#5", "C6")).toBe(true);
expect(notesSame("B#5", "C7")).toBe(true);
expect(notesSame("B3", "Cb5")).toBe(true);
expect(notesSame("B5", "Cb3")).toBe(true);
});
it("notesSame", function() {
expect(notesSame("C5", "C6")).toBe(true);
expect(notesSame("C5", "C5")).toBe(true);
expect(notesSame("C5", "D5")).toBe(false);
expect(notesSame("C#5", "C5")).toBe(false);
expect(notesSame("Ab5", "A3")).toBe(false);
expect(notesSame("Db5", "Db6")).toBe(true);
expect(notesSame("G#5", "G#7")).toBe(true);
// wrapping
expect(notesSame("B#5", "C6")).toBe(true);
expect(notesSame("B#5", "C7")).toBe(true);
expect(notesSame("B3", "Cb5")).toBe(true);
expect(notesSame("B5", "Cb3")).toBe(true);
});
it("notesSame", function() {
expect(notesSame("C5", "C6")).toBe(true);
expect(notesSame("C5", "C5")).toBe(true);
expect(notesSame("C5", "D5")).toBe(false);
expect(notesSame("C#5", "C5")).toBe(false);
expect(notesSame("Ab5", "A3")).toBe(false);
expect(notesSame("Db5", "Db6")).toBe(true);
expect(notesSame("G#5", "G#7")).toBe(true);
// wrapping
expect(notesSame("B#5", "C6")).toBe(true);
expect(notesSame("B#5", "C7")).toBe(true);
expect(notesSame("B3", "Cb5")).toBe(true);
expect(notesSame("B5", "Cb3")).toBe(true);
});
it("notesSame", function() {
expect(notesSame("C5", "C6")).toBe(true);
expect(notesSame("C5", "C5")).toBe(true);
expect(notesSame("C5", "D5")).toBe(false);
expect(notesSame("C#5", "C5")).toBe(false);
expect(notesSame("Ab5", "A3")).toBe(false);
expect(notesSame("Db5", "Db6")).toBe(true);
expect(notesSame("G#5", "G#7")).toBe(true);
// wrapping
expect(notesSame("B#5", "C6")).toBe(true);
expect(notesSame("B#5", "C7")).toBe(true);
expect(notesSame("B3", "Cb5")).toBe(true);
expect(notesSame("B5", "Cb3")).toBe(true);
});
it("notesSame", function() {
expect(notesSame("C5", "C6")).toBe(true);
expect(notesSame("C5", "C5")).toBe(true);
expect(notesSame("C5", "D5")).toBe(false);
expect(notesSame("C#5", "C5")).toBe(false);
expect(notesSame("Ab5", "A3")).toBe(false);
expect(notesSame("Db5", "Db6")).toBe(true);
expect(notesSame("G#5", "G#7")).toBe(true);
// wrapping
expect(notesSame("B#5", "C6")).toBe(true);
expect(notesSame("B#5", "C7")).toBe(true);
expect(notesSame("B3", "Cb5")).toBe(true);
expect(notesSame("B5", "Cb3")).toBe(true);
});
it("notesSame", function() {
expect(notesSame("C5", "C6")).toBe(true);
expect(notesSame("C5", "C5")).toBe(true);
expect(notesSame("C5", "D5")).toBe(false);
expect(notesSame("C#5", "C5")).toBe(false);
expect(notesSame("Ab5", "A3")).toBe(false);
expect(notesSame("Db5", "Db6")).toBe(true);
expect(notesSame("G#5", "G#7")).toBe(true);
// wrapping
expect(notesSame("B#5", "C6")).toBe(true);
expect(notesSame("B#5", "C7")).toBe(true);
expect(notesSame("B3", "Cb5")).toBe(true);
expect(notesSame("B5", "Cb3")).toBe(true);
});
it("notesSame", function() {
expect(notesSame("C5", "C6")).toBe(true);
expect(notesSame("C5", "C5")).toBe(true);
expect(notesSame("C5", "D5")).toBe(false);
expect(notesSame("C#5", "C5")).toBe(false);
expect(notesSame("Ab5", "A3")).toBe(false);
expect(notesSame("Db5", "Db6")).toBe(true);
expect(notesSame("G#5", "G#7")).toBe(true);
// wrapping
expect(notesSame("B#5", "C6")).toBe(true);
expect(notesSame("B#5", "C7")).toBe(true);
expect(notesSame("B3", "Cb5")).toBe(true);
expect(notesSame("B5", "Cb3")).toBe(true);
});
it("notesSame", function() {
expect(notesSame("C5", "C6")).toBe(true);
expect(notesSame("C5", "C5")).toBe(true);
expect(notesSame("C5", "D5")).toBe(false);
expect(notesSame("C#5", "C5")).toBe(false);
expect(notesSame("Ab5", "A3")).toBe(false);
expect(notesSame("Db5", "Db6")).toBe(true);
expect(notesSame("G#5", "G#7")).toBe(true);
// wrapping
expect(notesSame("B#5", "C6")).toBe(true);
expect(notesSame("B#5", "C7")).toBe(true);
expect(notesSame("B3", "Cb5")).toBe(true);
expect(notesSame("B5", "Cb3")).toBe(true);
});
if (Array.isArray(first)) {
if (first.length != notes.length) {
return false;
}
if (anyOctave) {
let noteSet = {}
notes.forEach((n) => noteSet[n.replace(/\d+$/, "")] = true)
return first.every((n) => noteSet[n.replace(/\d+$/, "")])
} else {
const pitches = notes.map(parseNote)
return first.map(parseNote).every((n) => pitches.indexOf(n) >= 0)
}
} else {
if (anyOctave) {
return notes.length == 1 && notesSame(notes[0], first)
} else {
return notes.length == 1 && parseNote(notes[0]) == parseNote(first)
}
}
}