mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-26 00:02:09 +00:00
refactor!: finish parser migration
Finally! :) This removes all code related to the old parser. #65
This commit is contained in:
27
lib/parser/classes/Text.js
Normal file
27
lib/parser/classes/Text.js
Normal file
@@ -0,0 +1,27 @@
|
||||
'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;
|
||||
Reference in New Issue
Block a user