Commit a86e4dbe authored by Steffen Michels's avatar Steffen Michels

Merge branch 'add-jsTraceVal' into 'master'

Add jsTraceVal

See merge request !308
parents 913bc508 a88d041e
Pipeline #29288 passed with stage
in 5 minutes and 32 seconds
......@@ -230,7 +230,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
......@@ -615,9 +615,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