mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-15 18:42:11 +00:00
chore: update Utils.js jsdoc
This commit is contained in:
@@ -24,11 +24,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.
|
||||
* @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>}
|
||||
*/
|
||||
function findNode(obj, key, target, depth, safe = true) {
|
||||
const flat_obj = Flatten(obj, { safe, maxDepth: depth || 2 });
|
||||
@@ -38,11 +40,13 @@ function findNode(obj, key, target, depth, safe = true) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string between two delimiters.
|
||||
* Finds a string between two delimiters.
|
||||
*
|
||||
* @param {string} data - The data.
|
||||
* @param {string} start_string - Start string.
|
||||
* @param {string} end_string - End string.
|
||||
* @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) {
|
||||
const regex = new RegExp(`${escapeStringRegexp(start_string)}(.*?)${escapeStringRegexp(end_string)}`, 's');
|
||||
@@ -88,6 +92,12 @@ function generateSidAuth(sid) {
|
||||
return ['SAPISIDHASH', [timestamp, gen_hash].join('_')].join(' ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a random string with a given length.
|
||||
*
|
||||
* @param {number} length
|
||||
* @returns {string}
|
||||
*/
|
||||
function generateRandomString(length) {
|
||||
const result = [];
|
||||
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
|
||||
|
||||
Reference in New Issue
Block a user