diff options
Diffstat (limited to 'src/app/game/game.utils.ts')
| -rw-r--r-- | src/app/game/game.utils.ts | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/app/game/game.utils.ts b/src/app/game/game.utils.ts index 4c99c55..9164dc9 100644 --- a/src/app/game/game.utils.ts +++ b/src/app/game/game.utils.ts @@ -3,9 +3,13 @@ export interface GameLine { content: string; } -export function parseLrcLines(lrcText: string): GameLine[] { +export function parseLrcLines( + lrcText: string, + options?: { skipBacking?: boolean } +): GameLine[] { const result: GameLine[] = []; const lineRegex = /\[(\d{2,3}):(\d{2})\.(\d{2,3})\]/g; + const { skipBacking = false } = options ?? {}; for (const rawLine of lrcText.split("\n")) { const timestamps: number[] = []; @@ -27,10 +31,10 @@ export function parseLrcLines(lrcText: string): GameLine[] { if (timestamps.length === 0) continue; - const content = rawLine - .slice(lastIndex) - .replace(/\([^)]*\)/g, "") - .trim(); + const content = (skipBacking + ? rawLine.slice(lastIndex).replace(/\([^)]*\)/g, "") + : rawLine.slice(lastIndex) + ).trim(); if (!content) continue; for (const ms of timestamps) { |
