mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
js: port more methods (os, builtin) (#12238)
This commit is contained in:
@@ -83,6 +83,10 @@ fn js_stacktrace() string {
|
||||
return stacktrace
|
||||
}
|
||||
|
||||
pub fn print_backtrace() {
|
||||
println(js_stacktrace())
|
||||
}
|
||||
|
||||
// Check for nil value
|
||||
pub fn isnil(val voidptr) bool {
|
||||
res := false
|
||||
|
||||
@@ -6,6 +6,7 @@ module builtin
|
||||
|
||||
fn (a any) toString()
|
||||
|
||||
[noreturn]
|
||||
pub fn panic(s string) {
|
||||
eprintln('V panic: $s\n$js_stacktrace()')
|
||||
exit(1)
|
||||
|
||||
@@ -155,3 +155,35 @@ pub fn (b []byte) hex() string {
|
||||
}
|
||||
return hex
|
||||
}
|
||||
|
||||
pub fn (i int) hex2() string {
|
||||
return '0x' + i.hex()
|
||||
}
|
||||
|
||||
pub fn (i i8) hex2() string {
|
||||
return '0x' + i.hex()
|
||||
}
|
||||
|
||||
pub fn (i i16) hex2() string {
|
||||
return '0x' + i.hex()
|
||||
}
|
||||
|
||||
pub fn (i i64) hex2() string {
|
||||
return '0x' + i.hex()
|
||||
}
|
||||
|
||||
pub fn (i byte) hex2() string {
|
||||
return '0x' + i.hex()
|
||||
}
|
||||
|
||||
pub fn (i u16) hex2() string {
|
||||
return '0x' + i.hex()
|
||||
}
|
||||
|
||||
pub fn (i u32) hex2() string {
|
||||
return '0x' + i.hex()
|
||||
}
|
||||
|
||||
pub fn (i u64) hex2() string {
|
||||
return '0x' + i.hex()
|
||||
}
|
||||
|
||||
@@ -910,3 +910,10 @@ pub fn (s string) index(search string) ?int {
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
pub fn (_rune string) utf32_code() int {
|
||||
res := 0
|
||||
#res.val = s.str.charCodeAt()
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user