mirror of
https://github.com/actions/github-script.git
synced 2026-02-08 03:57:27 +00:00
14 lines
299 B
TypeScript
14 lines
299 B
TypeScript
export async function callAsyncFunction<A = {}, R = unknown>(
|
|
args: A,
|
|
source: string
|
|
): Promise<R> {
|
|
const argsKeys = Object.keys(args).join(',')
|
|
|
|
const wrappedFunction: (
|
|
args: A
|
|
) => Promise<R> = eval(`async({${argsKeys}}) => {
|
|
${source}
|
|
}`)
|
|
|
|
return wrappedFunction(args)
|
|
}
|