( progDigits: string, mode: string )
| 64 | `; |
| 65 | |
| 66 | const romanByDigit = ( |
| 67 | progDigits: string, |
| 68 | mode: string |
| 69 | ): { chordDegrees: string; raw: string } => { |
| 70 | const modeForDegrees = mode.toLowerCase(); |
| 71 | const chordDegrees = getChordDegrees(modeForDegrees); |
| 72 | if (!chordDegrees.length) { |
| 73 | throw new TypeError(`Unsupported mode "${mode}" for progression digits`); |
| 74 | } |
| 75 | |
| 76 | const romans = progDigits.split('').map(digit => { |
| 77 | const idx = Number(digit) - 1; |
| 78 | if (idx < 0 || idx >= chordDegrees.length) { |
| 79 | throw new TypeError( |
| 80 | `Invalid progression digit "${digit}" in "${progDigits}"` |
| 81 | ); |
| 82 | } |
| 83 | return chordDegrees[idx]; |
| 84 | }); |
| 85 | |
| 86 | return { chordDegrees: romans.join(' '), raw: progDigits }; |
| 87 | }; |
| 88 | |
| 89 | const parseProgression = ( |
| 90 | root: string, |
no test coverage detected