p and q methods + all function

This commit is contained in:
Felix Roos 2023-11-16 06:52:47 +01:00
parent ee7cd8cd4c
commit a7b799f154
2 changed files with 34 additions and 15 deletions

View file

@ -47,10 +47,5 @@ export const evaluate = async (code, transpiler) => {
// if no transpiler is given, we expect a single instruction (!wrapExpression)
const options = { wrapExpression: !!transpiler };
let evaluated = await safeEval(code, options);
if (!isPattern(evaluated)) {
console.log('evaluated', evaluated);
const message = `got "${typeof evaluated}" instead of pattern`;
throw new Error(message + (typeof evaluated === 'function' ? ', did you forget to call a function?' : '.'));
}
return { mode: 'javascript', pattern: evaluated, meta };
};