feat: NamedSource
This commit is contained in:
@@ -1,16 +1,25 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use nix_js::context::Context;
|
||||
use nix_js::error::{Result, Source};
|
||||
use nix_js::value::Value;
|
||||
|
||||
pub fn eval(expr: &str) -> Value {
|
||||
Context::new().unwrap().eval_code(expr).unwrap()
|
||||
Context::new()
|
||||
.unwrap()
|
||||
.eval_code(Source::new_eval(expr.into()).unwrap())
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn eval_result(expr: &str) -> Result<Value, nix_js::error::Error> {
|
||||
Context::new().unwrap().eval_code(expr)
|
||||
pub fn eval_result(expr: &str) -> Result<Value> {
|
||||
Context::new()
|
||||
.unwrap()
|
||||
.eval_code(Source::new_eval(expr.into()).unwrap())
|
||||
}
|
||||
|
||||
pub fn compile(expr: &str) -> String {
|
||||
Context::new().unwrap().compile_code(expr).unwrap()
|
||||
Context::new()
|
||||
.unwrap()
|
||||
.compile_code(Source::new_eval(expr.into()).unwrap())
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user