feat: register cast package to jsmod
This commit is contained in:
parent
286e5e7317
commit
ca82edea01
4
go.mod
4
go.mod
@ -1,3 +1,5 @@
|
||||
module apigo.cc/go/cast
|
||||
|
||||
go 1.25
|
||||
go 1.25.0
|
||||
|
||||
require apigo.cc/go/jsmod v1.0.0
|
||||
|
||||
2
go.sum
2
go.sum
@ -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=
|
||||
31
js_export.go
Normal file
31
js_export.go
Normal file
@ -0,0 +1,31 @@
|
||||
package cast
|
||||
|
||||
import (
|
||||
"apigo.cc/go/jsmod"
|
||||
)
|
||||
|
||||
func init() {
|
||||
jsmod.Register("cast", map[string]any{
|
||||
// JSON
|
||||
"toJSON": ToJSON,
|
||||
"prettyJSON": PrettyToJSON,
|
||||
"fromJSON": func(data any) (any, error) {
|
||||
var res any
|
||||
err := UnmarshalJSON(data, &res)
|
||||
return res, err
|
||||
},
|
||||
|
||||
// Time
|
||||
"now": Now,
|
||||
"parseTime": ParseTime,
|
||||
"formatTime": FormatTime,
|
||||
"addTime": AddTime,
|
||||
"duration": Duration,
|
||||
"describeDuration": DescribeDuration,
|
||||
|
||||
// Logic
|
||||
"split": Split,
|
||||
"splitArgs": SplitArgs,
|
||||
"joinArgs": JoinArgs,
|
||||
})
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user