mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-16 19:12:24 +00:00
23 lines
526 B
TypeScript
23 lines
526 B
TypeScript
import TextRun from './TextRun';
|
|
import EmojiRun from '../EmojiRun';
|
|
|
|
class Text {
|
|
text: string;
|
|
runs;
|
|
constructor(data: any) {
|
|
if (data?.hasOwnProperty('runs') && Array.isArray(data.runs)) {
|
|
this.runs = (data.runs as any[]).map((run: any) => run.emoji ?
|
|
new EmojiRun(run) :
|
|
new TextRun(run)
|
|
);
|
|
this.text = this.runs.map((run) => run.text).join('');
|
|
} else {
|
|
this.text = data?.simpleText || 'N/A';
|
|
}
|
|
}
|
|
toString() {
|
|
return this.text;
|
|
}
|
|
}
|
|
export default Text;
|