feat: add bigjs to function node; (#77)

* feat: add bigjs to function node;

* fix test

* fix tests

* fix fmt
This commit is contained in:
stefan-gorules
2023-08-28 17:21:31 +02:00
committed by GitHub
parent c2741bd1ff
commit a03978fbe7
14 changed files with 118 additions and 29 deletions
+3 -1
View File
@@ -84,7 +84,9 @@ impl Script {
return Err(anyhow!("Timeout exceeded"));
}
let exception = tc_scope.exception().context("Failed to run loaded script")?;
let exception = tc_scope
.exception()
.context("Failed to run loaded script")?;
return Err(anyhow!(exception.to_rust_string_lossy(tc_scope)));
};
File diff suppressed because one or more lines are too long
@@ -17,6 +17,6 @@ const console = {
};
const main = (input) => ({
output: handler(input, {moment: __GLOBAL__DAYJS, env: __GLOBAL__ENV}),
output: handler(input, {moment: __GLOBAL__DAYJS, dayjs: __GLOBAL__DAYJS, Big: Big, env: __GLOBAL__ENV}),
log,
});
+4
View File
@@ -34,12 +34,16 @@ pub static BASE_VM: Lazy<Vec<u8>> = Lazy::new(|| {
let scope = &mut v8::ContextScope::new(handle_scope, context);
let dayjs_src = v8::String::new(scope, include_str!("scripts/dayjs.js")).unwrap();
let bigjs_src = v8::String::new(scope, include_str!("scripts/big.js")).unwrap();
let internal_src = v8::String::new(scope, include_str!("scripts/internals.js")).unwrap();
let env_src = v8::String::new(scope, env_src_string.as_str()).unwrap();
v8::Script::compile(scope, dayjs_src, None)
.unwrap()
.run(scope);
v8::Script::compile(scope, bigjs_src, None)
.unwrap()
.run(scope);
v8::Script::compile(scope, internal_src, None)
.unwrap()
.run(scope);