@dsebastien/music-notation 0.26.0 → 0.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,5 +4,11 @@
4
4
  * parentheses or commas don't form such groups (`C,`, `C()`, `C(b9`): that isn't a chord symbol.
5
5
  */
6
6
  export declare function withoutParentheses(suffix: string): string | null;
7
+ /**
8
+ * Lead sheets write minor as `mi` and major as `ma`, in capitals too (Cmi7, CMA7): the suffix with
9
+ * `m` and `maj` instead, so they read and draw like the other spellings (#157). `min` before an
10
+ * alteration reads the same way (Cmin7b5 = Cm7b5).
11
+ */
12
+ export declare const leadSheetSuffix: (suffix: string) => string;
7
13
  /** The canonical suffix (m(maj7) has its own entry; other parentheses are dropped first). */
8
14
  export declare function canonicalSuffix(suffix: string): string;
@@ -104,7 +104,11 @@ function withoutParentheses(suffix) {
104
104
  return null;
105
105
  return suffix.replace(/[(),\s]/g, "");
106
106
  }
107
+ var leadSheetSuffix = (suffix) => suffix.replace(/^(?:mi|MI|min|MIN)(?![A-Za-z])/, "m").replace(/^(?:ma|MA)(?![A-Za-z])/, "maj");
107
108
  function canonicalSuffix(suffix) {
109
+ const lead = leadSheetSuffix(suffix);
110
+ if (lead !== suffix)
111
+ return canonicalSuffix(lead);
108
112
  const direct = CANONICAL.get(suffix);
109
113
  if (direct !== undefined)
110
114
  return direct;
@@ -1532,9 +1536,10 @@ function parseChord(symbol) {
1532
1536
  return null;
1533
1537
  const trimmed = symbol.trim();
1534
1538
  const { root, bass } = parts;
1535
- const suffix = withoutParentheses(parts.suffix);
1539
+ const lead = leadSheetSuffix(parts.suffix);
1540
+ const suffix = withoutParentheses(lead);
1536
1541
  let quality = null;
1537
- for (const written of suffix === null || suffix === parts.suffix ? [parts.suffix] : [parts.suffix, suffix]) {
1542
+ for (const written of suffix === null || suffix === lead ? [lead] : [lead, suffix]) {
1538
1543
  for (const [re, label] of QUALITY_SUFFIXES) {
1539
1544
  const hit = re.exec(written);
1540
1545
  if (hit) {
@@ -3704,5 +3709,5 @@ export {
3704
3709
  voicingCount
3705
3710
  };
3706
3711
 
3707
- //# debugId=101B147722F3B32164756E2164756E21
3712
+ //# debugId=3165804919086D5E64756E2164756E21
3708
3713
  //# sourceMappingURL=index.js.map