mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
js: use write() on the freestanding backend (#16704)
This commit is contained in:
parent
11521a70e4
commit
c84eb29b78
@ -9,9 +9,10 @@ pub fn js_throw(s any) {
|
||||
for {}
|
||||
}
|
||||
|
||||
#let globalPrint;
|
||||
#let globalPrint, globalWrite;
|
||||
$if js_freestanding {
|
||||
#globalPrint = globalThis.print
|
||||
#globalWrite = (typeof globalThis.write === 'function')? write: globalThis.print
|
||||
}
|
||||
|
||||
pub fn flush_stdout() {
|
||||
@ -33,6 +34,8 @@ pub fn println(s string) {
|
||||
pub fn print(s string) {
|
||||
$if js_node {
|
||||
#$process.stdout.write(s.str)
|
||||
} $else $if js_freestanding {
|
||||
#globalWrite(s.str)
|
||||
} $else {
|
||||
panic('Cannot `print` in a browser, use `println` instead')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user