fix pattern checks for minified code

This commit is contained in:
Felix Roos 2022-03-25 22:32:42 +01:00
parent ef75590853
commit 9458faf5b0
7 changed files with 1359 additions and 22 deletions

View file

@ -49,7 +49,8 @@ export const evaluate = async (code) => {
drawHelpers.cleanup();
uiHelpers.cleanup();
let evaluated = await eval(shapeshifted);
if (evaluated?.constructor?.name !== 'Pattern') {
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?' : '.'));
}