Skip to main content

eval_str_print

Function eval_str_print 

Source
pub fn eval_str_print(src: &str, origin: &str) -> Result<(), String>
Expand description

node -p <src>: evaluate as -e does, then write the program’s COMPLETION value through the console.log formatter, exactly as Node’s --print does (node -p '[1,2]' prints [ 1, 2 ], node -p '"s"' prints the bare s). Side effects still happen, so node -p 'console.log("x")' prints x and then undefined.

Deliberately compiled with compile_completion rather than through the source-keyed rkyv cache: the cache is keyed by source TEXT alone, so a -p-shaped chunk and an -e-shaped chunk for the same string would alias.