YouTube.js
Guide
Discord
GitHub
Guide
Discord
GitHub

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"); };' }

Defined in

src/utils/Utils.ts:289

Edit this page
Last Updated:: 3/25/25, 8:08 PM
Contributors: EdamAme-x