Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var code = [
'return function(doc) {',
' "use strict";',
' var emitted = false;',
' var emit = function (a, b) {',
' emitted = true;',
' };',
' var view = ' + input + ';',
' view(doc);',
' if (emitted) {',
' return true;',
' }',
'};'
].join('\n');
return scopeEval(code, {});
}
function evalFunctionWithEval(func, emit) {
return scopeEval(
"return (" + func.replace(/;\s*$/, "") + ");",
{
emit: emit,
sum: sum,
log: log,
isArray: isArray,
toJSON: toJSON
}
);
}
function evalFilter(input) {
return scopeEval('"use strict";\nreturn ' + input + ';', {});
}