youtubei.js / Utils / findFunction
Function: findFunction()
findFunction(
source
,args
):FindFunctionResult
|undefined
Finds a function in a source string based on the provided search criteria.
Parameters
• source: string
• args: FindFunctionArgs
Returns
FindFunctionResult
| undefined
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"); };' }