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

jsgen: optional "or blocks" (#6938)

This commit is contained in:
Leah Lundqvist
2020-11-24 22:52:23 +01:00
committed by GitHub
parent 23c9563600
commit 96b73acad7
5 changed files with 98 additions and 8 deletions

View File

@@ -35,13 +35,13 @@ pub fn eprint(s any) {
// a 'real' way to exit in the browser.
pub fn exit(c int) {
JS.process.exit(c)
js_throw('exit($c)')
}
pub fn unwrap(opt any) any {
o := &Option(opt)
if o.not_ok {
panic(o.error)
return o.error
js_throw(o.error)
}
return opt
}