mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-16 19:12:24 +00:00
1.0 KiB
1.0 KiB
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"); };' }