Add tests for the AsyncFunction
This commit is contained in:
@@ -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