lrc-kit
Version:
lrc parser, maker, runner
51 lines (50 loc) • 1.28 kB
TypeScript
export interface Lyric {
timestamp: number;
wordTimestamps?: {
timestamp: number;
content: string;
}[];
rawContent: string;
content: string;
}
export interface CombineLyric {
timestamps: number[];
rawContent: string;
content: string;
}
export type Info = Record<string, string>;
/**
* get lrc time string
* @example
* Lrc.timestampToString(143.54)
* // return '02:23.54':
* @param timestamp second timestamp
*/
export declare function timestampToString(timestamp: number): string;
export type LineFormat = '\r\n' | '\r' | '\n';
export type ParseOptions = {
enhanced?: boolean;
};
export interface ToStringOptions {
combine: boolean;
sort: boolean;
lineFormat: LineFormat;
}
export declare class Lrc {
info: Info;
lyrics: Lyric[];
plain: string;
/**
* parse lrc text and return a Lrc object
*/
static parse(text: string, options?: ParseOptions): Lrc;
offset(offsetTime: number): void;
clone(): Lrc;
/**
* get lrc text
* @param opts.combine lyrics combine by same content
* @param opts.sort lyrics sort by timestamp
* @param opts.lineFormat newline format
*/
toString({ combine, lineFormat, sort, }?: Partial<ToStringOptions>): string;
}