Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getAst (src: string, isObject: boolean): Program | null {
// NOTE: In case of objects (e.g.eval('{ 1: 2}')) without wrapping
// object will be parsed as label. To avoid this we parenthesize src
src = isObject ? `(${src})` : src;
try {
return parse(src, PARSING_OPTIONS);
}
catch (err) {
return null;
}
}