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

js: make vlib/v/util compile on JS backend (#12660)

This commit is contained in:
playX
2021-12-03 13:25:36 +03:00
committed by GitHub
parent be5446bfa4
commit 0da7e2f8ab
7 changed files with 79 additions and 20 deletions

View File

@@ -955,3 +955,23 @@ pub fn tos(jsstr JS.String) string {
return res
}
pub fn (s string) compare(a string) int {
min_len := if s.len < a.len { s.len } else { a.len }
for i in 0 .. min_len {
if s[i] < a[i] {
return -1
}
if s[i] > a[i] {
return 1
}
}
if s.len < a.len {
return -1
}
if s.len > a.len {
return 1
}
return 0
}