Files
YouTube.js/lib/parser/classes/Text.js
LuanRT 68cb841c00 refactor!: finish parser migration
Finally! :)

This removes all code related to the old parser.

#65
2022-07-11 06:19:10 -03:00

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;