-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.go
More file actions
72 lines (56 loc) · 1.81 KB
/
client.go
File metadata and controls
72 lines (56 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//go:build wasm
package main
import (
"syscall/js"
. "github.com/tinywasm/fmt"
)
func main() {
// Your WebAssembly code here ok
// Crear el elemento div
dom := js.Global().Get("document").Call("createElement", "div")
// Demonstrate conversion processes like in README line 48
items := []string{" ÁPPLE ", " banána ", " piñata ", " ÑANDÚ "}
buf := Convert().
Write("<h1>fmt Conversion Processes</h1>").
Write("<h2>Original Items:</h2>").
Write("<ul>")
// Show original items
for _, item := range items {
buf.Write("<li>").Write(item).Write("</li>")
}
buf.Write("</ul>").
Write("<h2>After Processing:</h2>").
Write("<ul>")
// Process items like in README example
builder := Convert()
for i, item := range items {
processed := Convert(item).
TrimSpace(). // TrimSpace whitespace
Tilde(). // Normalize accents
ToLower(). // Convert to lowercase
Capitalize(). // Capitalize first letter
String() // Finalize the string
builder.Write(processed)
if i < len(items)-1 {
builder.Write(" - ")
}
}
buf.Write("<li>").Write(builder.String()).Write("</li>").
Write("</ul>").
Write("<h2>Conversion Steps Applied:</h2>").
Write("<ol>").
Write("<li>TrimSpace() - Remove leading/trailing whitespace</li>").
Write("<li>Tilde() - Normalize accents (á→a, ñ→n, etc.)</li>").
Write("<li>ToLower() - Convert to lowercase</li>").
Write("<li>Capitalize() - Capitalize first letter</li>").
Write("</ol>")
dom.Set("innerHTML", buf.String())
// Obtener el body del documento y agregar el elemento
body := js.Global().Get("document").Get("body")
body.Call("appendChild", dom)
logger := func(msg ...any) {
js.Global().Get("console").Call("log", Translate(msg...).String())
}
logger("hello tinystring:", 123, 45.67, true, []string{"a", "b", "c"})
select {}
}