feat: eval_shallow & eval_deep

This commit is contained in:
2026-01-31 22:08:32 +08:00
parent b7f4ece472
commit 4d6fd6d614
13 changed files with 164 additions and 73 deletions

View File

@@ -7,19 +7,19 @@ use nix_js::value::Value;
pub fn eval(expr: &str) -> Value {
Context::new()
.unwrap()
.eval_code(Source::new_eval(expr.into()).unwrap())
.eval(Source::new_eval(expr.into()).unwrap())
.unwrap()
}
pub fn eval_result(expr: &str) -> Result<Value> {
Context::new()
.unwrap()
.eval_code(Source::new_eval(expr.into()).unwrap())
.eval(Source::new_eval(expr.into()).unwrap())
}
pub fn compile(expr: &str) -> String {
Context::new()
.unwrap()
.compile_code(Source::new_eval(expr.into()).unwrap())
.compile(Source::new_eval(expr.into()).unwrap())
.unwrap()
}