UNPKG
sherry-utils
Version:
latest (2.0.0-alpha.9)
next (2.0.0-alpha.8)
2.0.0-alpha.9
2.0.0-alpha.8
2.0.0-alpha.7
2.0.0-alpha.6
2.0.0-alpha.5
2.0.0-alpha.4
2.0.0-alpha.3
2.0.0-alpha.2
2.0.0-alpha.1
2.0.0-alpha.0
sherry-utils for Sherry
github.com/sherry/sherry/packages/sherry-utils
sherry/sherry
sherry-utils
/
lib
/
evaluate.js
11 lines
(10 loc)
•
291 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
module
.
exports
=
function
(
exp, data
) {
/* eslint-disable no-new-func */
const
fn =
new
Function
(
'data'
,
`with (data) { return
${exp}
}`
)
try
{
return
fn
(data) }
catch
(err) {
console
.
error
(err.
stack
)
console
.
error
(
`Error when evaluating filter condition:
${exp}
`
) } }