19 lines
468 B
TypeScript
19 lines
468 B
TypeScript
import type { Song } from "./types";
|
|
|
|
export function previewChords(song: Song): string[] {
|
|
const seen = new Set<string>();
|
|
const result: string[] = [];
|
|
for (const section of song.sections) {
|
|
for (const line of section.lines) {
|
|
for (const cp of line.chords) {
|
|
if (!seen.has(cp.chord)) {
|
|
seen.add(cp.chord);
|
|
result.push(cp.chord);
|
|
}
|
|
}
|
|
}
|
|
if (result.length >= 5) break;
|
|
}
|
|
return result.slice(0, 5);
|
|
}
|