Skip to content

Commit df85183

Browse files
author
CodeApe
committed
first commit
0 parents  commit df85183

File tree

9 files changed

+855430
-0
lines changed

9 files changed

+855430
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
.vscode
3+
.idea

build_wasm.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//go:build js && wasm
2+
3+
package wasmecdict
4+
5+
import (
6+
"syscall/js"
7+
)
8+
9+
const version = "0.0.1"
10+
11+
func lookUp(_ js.Value, args []js.Value) any {
12+
if len(args) > 0 {
13+
text := args[0].String()
14+
res := LookUp(text)
15+
if res != nil {
16+
return js.ValueOf(res.toMap())
17+
}
18+
}
19+
return js.Undefined()
20+
}
21+
22+
func info(_ js.Value, _ []js.Value) any {
23+
return map[string]interface{}{
24+
"version": version,
25+
"words": len(dictMapSingleton),
26+
"lemmas": len(lemmaMapSingleton),
27+
"author": "[email protected]",
28+
"email": "[email protected]",
29+
"DictionaryData": "https://github.com/skywind3000/ECDICT",
30+
"License": "MIT",
31+
}
32+
}
33+
34+
func main() {
35+
js.Global().Set("lookUp", js.FuncOf(lookUp)) //export window.lookUp to lookUp English word
36+
js.Global().Set("ecDictionary", js.FuncOf(info)) // export ecDictionary show info
37+
done := make(chan struct{}, 0)
38+
<-done
39+
}

ecdict.csv

Lines changed: 770612 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)