Add tests for the AsyncFunction

This commit is contained in:
Jonathan Clem 2020-02-27 17:27:49 -05:00
parent 6eefe48bc9
commit 38e3ffe4c6
No known key found for this signature in database
GPG key ID: B3662C4A8F843179
7 changed files with 4679 additions and 100 deletions

11
src/async-function.ts Normal file
View 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))
}