2
0

feat(editor): Code step

This commit is contained in:
Baptiste Arnaud
2022-03-07 17:39:57 +01:00
parent b2784f19fd
commit e3e07ddd4d
13 changed files with 239 additions and 16 deletions

View File

@ -1,8 +1,6 @@
import { Variable } from 'models'
import { isDefined, isNotDefined } from 'utils'
const safeEval = eval
export const stringContainsVariable = (str: string): boolean =>
/\{\{(.*?)\}\}/g.test(str)
@ -22,7 +20,7 @@ export const parseVariables =
export const evaluateExpression = (str: string) => {
try {
const evaluatedResult = safeEval(str)
const evaluatedResult = Function('return' + str)()
return isNotDefined(evaluatedResult) ? '' : evaluatedResult.toString()
} catch (err) {
console.log(err)