feat: register rand package to jsmod

This commit is contained in:
AI Engineer 2026-05-30 17:09:58 +08:00
parent 36501bd5ff
commit c54df23b45
3 changed files with 29 additions and 0 deletions

2
go.mod
View File

@ -1,3 +1,5 @@
module apigo.cc/go/rand
go 1.25.0
require apigo.cc/go/jsmod v1.0.0

2
go.sum Normal file
View File

@ -0,0 +1,2 @@
apigo.cc/go/jsmod v1.0.0 h1:lVQMq0tCno4kbHlQ3j5wzsm+v24J+bznIoHxpton0pE=
apigo.cc/go/jsmod v1.0.0/go.mod h1:bmyeZtOAP/j5am+YRnaiM89smysK24K7ebk0koFtsSw=

25
js_export.go Normal file
View File

@ -0,0 +1,25 @@
package rand
import (
"apigo.cc/go/jsmod"
)
func init() {
jsmod.Register("rand", map[string]any{
"int": func(min, max int64) int64 {
return Int(min, max)
},
"fastInt": func(min, max int64) int64 {
return FastInt(min, max)
},
"float": func(min, max float64) float64 {
return Float(min, max)
},
"fastFloat": func(min, max float64) float64 {
return FastFloat(min, max)
},
"byte": Byte,
"bytes": Bytes,
"perm": Perm,
})
}