MCPcopy Create free account
hub / github.com/microsoft/vscode-cpptools / createFunction

Method createFunction

Extension/src/Utility/Sandbox/sandbox.ts:87–102  ·  view source on GitHub ↗
(sourceCode: string, parameterNames: string[] = [], options?: CreateOptions & { async?: boolean })

Source from the content-addressed store, hash-verified

85 createFunction<T = ((...args: any[]) => Promise<unknown>)>(sourceCode: string, parameterNames: string[], options: CreateOptions & { async: true }): ScriptError[] | T;
86
87 createFunction<T = ((...args: any[]) => unknown)>(sourceCode: string, parameterNames: string[] = [], options?: CreateOptions & { async?: boolean }): ScriptError[] | T {
88 // insert defaults in options
89 options = {
90 lineOffset: 0,
91 columnOffset: 0,
92 filename: '<sandbox>',
93 ...options ? options : {}
94 };
95
96 let scriptSrc = sourceCode;
97
98 scriptSrc = `${options.async ? 'async ' : ''}(${parameterNames.join(',')}) => { ${scriptSrc} }`;
99
100 // create the script object, run it, and capture the generated function
101 return new Script(scriptSrc, options).runInContext(this.context, {});
102 }
103}
104

Callers 2

subscribeFunction · 0.80
generateFilterFnFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected