MCPcopy
hub / github.com/scribbletune/scribbletune / romanByDigit

Function romanByDigit

src/cli.ts:66–87  ·  view source on GitHub ↗
(
  progDigits: string,
  mode: string
)

Source from the content-addressed store, hash-verified

64`;
65
66const 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
89const parseProgression = (
90 root: string,

Callers 1

parseProgressionFunction · 0.85

Calls 1

getChordDegreesFunction · 0.90

Tested by

no test coverage detected