Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
safe-expr-eval — 安全表达式求值器 - expr-eval 的无缝替代品,且不存在 CVE-2025-12735 漏洞 | Kitploit
工具/GitHubGitHub/alecasg555/safe-expr-eval
通用工具代码分析脚本与自动化
GitHubalecasg555/safe-expr-eval

safe-expr-eval

安全表达式求值器 - expr-eval 的无缝替代品,且不存在 CVE-2025-12735 漏洞

查看仓库
4133个月前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

safe-expr-eval

面向 JavaScript 和 TypeScript 的快速轻量级表达式求值器。

一个具有熟悉 API、零依赖和完整 TypeScript 支持的现代表达式解析器。


功能特性

  • 快速表达式解析与求值
  • 轻量级且无依赖
  • 完整 TypeScript 支持
  • 简单且熟悉的 API
  • 自定义函数和常量
  • 兼容 ES2020+
  • 测试完善

安装

root@kitploit:~
npm install safe-expr-eval

快速开始

基本用法

root@kitploit:~
import { Parser } from 'safe-expr-eval';

const parser = new Parser();
const expr = parser.parse('2 * x + 1');

console.log(expr.evaluate({ x: 3 })); // 7
console.log(expr.evaluate({ x: 10 })); // 21

直接求值

root@kitploit:~
import { evaluate } from 'safe-expr-eval';

const result = evaluate('10 + 5 * 2');

console.log(result); // 20

编译表达式

root@kitploit:~
import { compile } from 'safe-expr-eval';

const fn = compile('price * quantity * (1 - discount)');

console.log(
  fn({
    price: 100,
    quantity: 2,
    discount: 0.1
  })
); // 180

支持的操作

算术

root@kitploit:~
+  -  *  /  %

比较

root@kitploit:~
==  !=  >  <  >=  <=

逻辑

root@kitploit:~
and  or  not
&&   ||   !

数据类型

root@kitploit:~
Numbers   → 42, 3.14
Strings   → "hello"
Booleans  → true, false
Variables → price, user.name

自定义函数

root@kitploit:~
const parser = new Parser();

parser.functions.max = Math.max;
parser.functions.min = Math.min;
parser.functions.round = Math.round;

const expr = parser.parse(
  'round(max(a, b) * 1.5)'
);

console.log(
  expr.evaluate({
    a: 10,
    b: 20
  })
); // 30

常量

root@kitploit:~
const parser = new Parser();

parser.consts.PI = Math.PI;
parser.consts.TAX_RATE = 0.15;

const expr = parser.parse(
  'price * (1 + TAX_RATE)'
);

console.log(
  expr.evaluate({
    price: 100
  })
); // 115

API

Parser

创建解析器

root@kitploit:~
new Parser()

解析表达式

root@kitploit:~
parser.parse(expression)

求值表达式

root@kitploit:~
parser.evaluate(expression, variables?)

函数注册表

root@kitploit:~
parser.functions

常量注册表

root@kitploit:~
parser.consts

独立函数

evaluate

root@kitploit:~
evaluate(expression, variables?)

compile

root@kitploit:~
compile(expression)

测试

root@kitploit:~
npm test
root@kitploit:~
npm run test:coverage

许可证

MIT

详细信息请参阅 LICENSE 文件。


贡献

欢迎提交 Pull Request 和贡献。


问题

如果您发现 bug 或有功能请求,请提交 issue。


作者

Alejandro Castrillon

root@kitploit:~
GitHub: https://github.com/
下载工具