mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-16 11:02:10 +00:00
refactor(parser): improve typings and do some refactoring (#305)
* dev: add response types * dev: refactor `Parser#parseResponse()` * dev: update YouTube parsers * dev: update YouTube Music classes * dev: update YouTube Kids classes * dev: update core classes * dev(Parser): fix some inconsistencies * chore: update docs * chore: update docs x2 * fix: export response types * chore(docs): update parser example
This commit is contained in:
@@ -45,7 +45,10 @@ class CommentThread extends YTNode {
|
||||
|
||||
const response = await continuation.endpoint.call(this.#actions, { parse: true });
|
||||
|
||||
this.replies = observe(response.on_response_received_endpoints_memo?.getType(Comment).map((comment) => {
|
||||
if (!response.on_response_received_endpoints_memo)
|
||||
throw new InnertubeError('Unexpected response.', response);
|
||||
|
||||
this.replies = observe(response.on_response_received_endpoints_memo.getType(Comment).map((comment) => {
|
||||
comment.setActions(this.#actions);
|
||||
return comment;
|
||||
}));
|
||||
@@ -75,12 +78,15 @@ class CommentThread extends YTNode {
|
||||
|
||||
const response = await load_more_button.endpoint.call(this.#actions, { parse: true });
|
||||
|
||||
this.replies = observe(response?.on_response_received_endpoints_memo.getType(Comment).map((comment) => {
|
||||
if (!response.on_response_received_endpoints_memo)
|
||||
throw new InnertubeError('Unexpected response.', response);
|
||||
|
||||
this.replies = observe(response.on_response_received_endpoints_memo.getType(Comment).map((comment) => {
|
||||
comment.setActions(this.#actions);
|
||||
return comment;
|
||||
}));
|
||||
|
||||
this.#continuation = response?.on_response_received_endpoints_memo.getType(ContinuationItem)?.[0];
|
||||
this.#continuation = response.on_response_received_endpoints_memo.getType(ContinuationItem)?.[0];
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user