mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-13 09:32:12 +00:00
chore: Inline some trivial private methods (#946)
This commit is contained in:
@@ -50,18 +50,6 @@ export default class Actions {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mimics the Axios API using Fetch's Response object.
|
||||
* @param response - The response object.
|
||||
*/
|
||||
async #wrap(response: Response): Promise<ApiResponse> {
|
||||
return {
|
||||
success: response.ok,
|
||||
status_code: response.status,
|
||||
data: JSON.parse(await response.text())
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes calls to the playback tracking API.
|
||||
* @param url - The URL to call.
|
||||
@@ -187,7 +175,12 @@ export default class Actions {
|
||||
return parsed_response;
|
||||
}
|
||||
|
||||
return this.#wrap(response);
|
||||
// Mimics the Axios API using Fetch's Response object.
|
||||
return {
|
||||
success: response.ok,
|
||||
status_code: response.status,
|
||||
data: JSON.parse(await response.text())
|
||||
};
|
||||
}
|
||||
|
||||
#isBrowse(response: IParsedResponse): response is IBrowseResponse {
|
||||
|
||||
@@ -11,22 +11,13 @@ export class YTNode {
|
||||
this.type = (this.constructor as YTNodeConstructor).type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the node is of the given type.
|
||||
* @param type - The type to check
|
||||
* @returns whether the node is of the given type
|
||||
*/
|
||||
#is<T extends YTNode>(type: YTNodeConstructor<T>): this is T {
|
||||
return this.type === type.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the node is of the given type.
|
||||
* @param types - The type to check
|
||||
* @returns whether the node is of the given type
|
||||
*/
|
||||
is<T extends YTNode, K extends YTNodeConstructor<T>[]>(...types: K): this is InstanceType<K[number]> {
|
||||
return types.some((type) => this.#is(type));
|
||||
return types.some((type) => this.type === type.type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user