diff --git a/src/evaluate.ts b/src/evaluate.ts index b9e9608..f901f9f 100644 --- a/src/evaluate.ts +++ b/src/evaluate.ts @@ -2,10 +2,20 @@ import {type Opt} from "./deep.ts"; import {base64Encode} from "./base64.ts"; import {utfEncode} from "./text.ts"; +/** +* Auxiliary type for default export. +*/ export interface DefExp{ default: T; } +/** +* Evaluate ESM JavaScript code in module scope. +* @example +* ```ts +* const {default: data} = await evaluateESM>("export default 'hello!';"); +* ``` +*/ export async function evaluateESM>(code:string):Promise{ return await import(`data:text/javascript;base64,${base64Encode(utfEncode(code))}`); } \ No newline at end of file