mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-07-02 21:52:48 +00:00
chore: fix invalid jsdoc comments
This commit is contained in:
@@ -7,8 +7,7 @@ const Constants = require('./Constants');
|
||||
/** @namespace */
|
||||
class Request {
|
||||
/**
|
||||
* @param {Innertube} session
|
||||
* @constructor
|
||||
* @param {import('../Innertube')} session
|
||||
*/
|
||||
constructor(session) {
|
||||
this.session = session;
|
||||
@@ -99,8 +98,11 @@ class Request {
|
||||
|
||||
/**
|
||||
* Adjusts the context according to the given client.
|
||||
*
|
||||
* @param {object} ctx
|
||||
* @param {string} client
|
||||
* @todo refactor this?
|
||||
* @returns
|
||||
* @returns {void}
|
||||
*/
|
||||
#adjustContext(ctx, client) {
|
||||
switch (client) {
|
||||
|
||||
@@ -4,7 +4,6 @@ const Crypto = require('crypto');
|
||||
const UserAgent = require('user-agents');
|
||||
const Flatten = require('flat');
|
||||
|
||||
/** @namespace */
|
||||
class InnertubeError extends Error {
|
||||
constructor (message, info) {
|
||||
super(message);
|
||||
@@ -24,14 +23,13 @@ class NoStreamingDataError extends InnertubeError {}
|
||||
|
||||
/**
|
||||
* Utility to help access deep properties of an object.
|
||||
*
|
||||
*
|
||||
* @param {object} obj - the object.
|
||||
* @param {string} key - key of the property being accessed.
|
||||
* @param {string} target - anything that might be inside of the property.
|
||||
* @param {number} depth - maximum number of nested objects to flatten.
|
||||
* @param {boolean} safe - if set to true arrays will be preserved.
|
||||
*
|
||||
* @returns {object|Array.<any>}
|
||||
* @returns {object|object[]}
|
||||
*/
|
||||
function findNode(obj, key, target, depth, safe = true) {
|
||||
const flat_obj = Flatten(obj, { safe, maxDepth: depth || 2 });
|
||||
@@ -43,9 +41,9 @@ function findNode(obj, key, target, depth, safe = true) {
|
||||
/**
|
||||
* Creates a trap to intercept property access
|
||||
* and add utilities to an object.
|
||||
*
|
||||
*
|
||||
* @param {object} obj
|
||||
* @returns
|
||||
* @returns {object}
|
||||
*/
|
||||
function observe(obj) {
|
||||
return new Proxy(obj, {
|
||||
@@ -53,9 +51,11 @@ function observe(obj) {
|
||||
if (prop == 'get') {
|
||||
/**
|
||||
* Returns the first object to match the rule.
|
||||
*
|
||||
* @name get
|
||||
* @param {object} rule
|
||||
* @param {boolean} del_item
|
||||
* @returns {*}
|
||||
*/
|
||||
return (rule, del_item) => target
|
||||
.find((obj, index) => {
|
||||
@@ -72,9 +72,11 @@ function observe(obj) {
|
||||
if (prop == 'findAll') {
|
||||
/**
|
||||
* Returns all objects that match the rule.
|
||||
*
|
||||
* @name findAll
|
||||
* @param {object} rule
|
||||
* @param {boolean} del_items
|
||||
* @returns {*}
|
||||
*/
|
||||
return (rule, del_items) => target
|
||||
.filter((obj, index) => {
|
||||
@@ -91,8 +93,10 @@ function observe(obj) {
|
||||
if (prop == 'remove') {
|
||||
/**
|
||||
* Removes the item at the given index.
|
||||
*
|
||||
* @name remove
|
||||
* @param {number} index
|
||||
* @returns {*}
|
||||
*/
|
||||
return (index) => target.splice(index, 1);
|
||||
}
|
||||
@@ -106,7 +110,7 @@ function observe(obj) {
|
||||
/**
|
||||
* Compares given objects. May not work correctly for
|
||||
* objects with methods.
|
||||
*
|
||||
*
|
||||
* @param {object} obj1
|
||||
* @param {object} obj2
|
||||
* @returns {boolean}
|
||||
@@ -129,7 +133,6 @@ function deepCompare(obj1, obj2) {
|
||||
* @param {string} data - the data.
|
||||
* @param {string} start_string - start string.
|
||||
* @param {string} end_string - end string.
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
function getStringBetweenStrings(data, start_string, end_string) {
|
||||
@@ -138,8 +141,12 @@ function getStringBetweenStrings(data, start_string, end_string) {
|
||||
return match ? match[1] : undefined;
|
||||
}
|
||||
|
||||
function escapeStringRegexp(string) {
|
||||
return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
|
||||
/**
|
||||
* @param {string} input
|
||||
* @returns {string}
|
||||
*/
|
||||
function escapeStringRegexp(input) {
|
||||
return input.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +185,7 @@ function generateSidAuth(sid) {
|
||||
|
||||
/**
|
||||
* Generates a random string with the given length.
|
||||
*
|
||||
*
|
||||
* @param {number} length
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -195,7 +202,7 @@ function generateRandomString(length) {
|
||||
|
||||
/**
|
||||
* Converts time (h:m:s) to seconds.
|
||||
*
|
||||
*
|
||||
* @param {string} time
|
||||
* @returns {number} seconds
|
||||
*/
|
||||
@@ -221,7 +228,7 @@ function camelToSnake(string) {
|
||||
|
||||
/**
|
||||
* Checks if a given client is valid.
|
||||
*
|
||||
*
|
||||
* @param {string} client
|
||||
* @returns {boolean}
|
||||
*/
|
||||
@@ -231,9 +238,9 @@ function isValidClient(client) {
|
||||
|
||||
/**
|
||||
* Throws an error if given parameters are undefined.
|
||||
*
|
||||
*
|
||||
* @param {object} params
|
||||
* @returns
|
||||
* @returns {void}
|
||||
*/
|
||||
function throwIfMissing(params) {
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
@@ -244,7 +251,7 @@ function throwIfMissing(params) {
|
||||
|
||||
/**
|
||||
* Turns the ntoken transform data into a valid json array
|
||||
*
|
||||
*
|
||||
* @param {string} data
|
||||
* @returns {string}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user