youtubei.js / Utils / findFunction
Function: findFunction()
findFunction(
source
,args
):ASTLookupResult
|undefined
Searches for a function in the given code based on specified criteria.
Parameters
• source: string
• args: ASTLookupArgs
Returns
ASTLookupResult
| undefined
An object containing the function's details if found, undefined
otherwise.
Example
const source = '(function() {var foo, bar; foo = function() { console.log("foo"); }; bar = function() { console.log("bar"); }; })();';
const result = findFunction(source, { name: 'bar' });
console.log(result);
// Output: { start: 69, end: 110, name: 'bar', node: { ... }, result: 'bar = function() { console.log("bar"); };' }