INNER CODE UNIT · TypeScript

countPatternSteps

scribbletune/scribbletune · src/cli.ts:160

const countPatternSteps = (pattern: string): number =>
  (pattern.match(/[xR]/g) || []).length;

const fitPatternToNoteCount = (pattern: string, noteCount: number): string => {
  const stepCount = countPatternSteps(pattern);
  if (!stepCount || stepCount >= noteCount) {
    return pattern;
  }
  const reps = Math.ceil(noteCount / stepCount);
  return pattern.repeat(reps);
};

const resolvePattern = (
  rawPattern: string,
  noteCount: number,
  fitPattern = false
): string => {
  const expanded = expandPatternSyntax(rawPattern);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…