UNPKG

@sanpjs/generator

Version:

@sanpjs/generator

23 lines 667 B
"use strict"; /** * Copyright (c) Baidu Inc. All rights reserved. * * This source code is licensed under the MIT license. * See LICENSE file in the project root for license information. * * @file evaluate * @author ksky521 */ Object.defineProperty(exports, "__esModule", { value: true }); const utils_1 = require("@sanpjs/utils"); exports.default = (exp, data) => { /* eslint-disable no-new-func */ const fn = new Function('data', 'with (data) { return ' + exp + '}'); try { return fn(data); } catch (e) { utils_1.logger.error(`Error when evaluating filter condition: ${exp}`); } }; //# sourceMappingURL=evaluate.js.map