mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-17 03:22:15 +00:00
27 lines
492 B
JavaScript
27 lines
492 B
JavaScript
'use strict';
|
|
|
|
const TextRun = require('./TextRun');
|
|
const EmojiRun = require('./EmojiRun');
|
|
|
|
class Text {
|
|
text;
|
|
|
|
constructor(data) {
|
|
if (data?.hasOwnProperty('runs')) {
|
|
this.runs = data.runs.map((run) => 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;
|
|
}
|
|
}
|
|
|
|
module.exports = Text; |