1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/builtin/js/builtin.js.v

39 lines
679 B
V
Raw Normal View History

2020-11-25 00:52:23 +03:00
module builtin
// used to generate JS throw statements.
pub fn js_throw(s any) {
#throw (s instanceof Error ? s : new Error(s))
}
pub fn println(s any) {
$if js_freestanding {
#print(s.toString())
} $else {
#console.log(s.toString())
}
}
pub fn print(s any) {
$if js_node {
#$process.stdout.write(s.toString())
} $else {
panic('Cannot `print` in a browser, use `println` instead')
}
}
pub fn eprintln(s any) {
$if js_freestanding {
#print(s.toString())
} $else {
#console.error(s.toString())
}
}
pub fn eprint(s any) {
$if js_node {
#$process.stderr.write(s.toString())
} $else {
panic('Cannot `eprint` in a browser, use `println` instead')
}
}