Verified Commit a88d041e authored by Camil Staps's avatar Camil Staps 🚀

Add jsTraceVal

parent 063c7a9f
Pipeline #29287 passed with stage
in 5 minutes and 52 seconds
......@@ -225,7 +225,16 @@ addJSFromUrl :: !String !(Maybe JSFun) !*JSWorld -> *JSWorld
/**
* A simple wrapper around JavaScript's `console.log`.
* Use {{`jsTraceVal`}} to trace JavaScript values.
* @param The value to log.
* @param The value to return.
*/
jsTrace :: !a .b -> .b | toString a
/**
* A simple wrapper around JavaScript's `console.log`.
* Use {{`jsTrace`}} to trace Clean values.
* @param The value to log.
* @param The value to return.
*/
jsTraceVal :: !JSVal .a -> .a
......@@ -608,9 +608,12 @@ where
}
jsTrace :: !a .b -> .b | toString a
jsTrace s x = case eval_js (js_val_to_string (JSCall (JSVar "console.log") {JSString (toString s)})) of
jsTrace s x = jsTraceVal (JSString (toString s)) x
jsTraceVal :: !JSVal .a -> .a
jsTraceVal v x = case eval_js (js_val_to_string (JSCall (JSVar "console.log") {v})) of
True -> x
False -> abort_with_node s // just in case it is a JSVal
False -> abort_with_node v
set_js :: !*String !*String -> Bool
set_js var val = code {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment