mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-19 04:21:35 +00:00
chore: clean up build steps
This commit is contained in:
22
src/parser/classes/misc/Text.ts
Normal file
22
src/parser/classes/misc/Text.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user