mirror of
https://github.com/actions/github-script.git
synced 2025-12-20 05:52:28 +00:00
Add tests for the AsyncFunction
This commit is contained in:
11
src/async-function.ts
Normal file
11
src/async-function.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor
|
||||
|
||||
type AsyncFunctionArguments = {[key: string]: any}
|
||||
|
||||
export async function callAsyncFunction(
|
||||
args: AsyncFunctionArguments,
|
||||
source: string
|
||||
): Promise<any> {
|
||||
const fn = new AsyncFunction(...Object.keys(args), source)
|
||||
return fn(...Object.values(args))
|
||||
}
|
||||
Reference in New Issue
Block a user