cast/js_export.go

37 lines
661 B
Go
Raw Normal View History

2026-05-30 17:16:05 +08:00
package cast
import (
"apigo.cc/go/jsmod"
)
func init() {
jsmod.Register("cast", map[string]any{
// JSON
"ToJSON": ToJSON,
"PrettyToJSON": PrettyToJSON,
"FromJSON": jsFromJSON,
2026-05-30 17:16:05 +08:00
// Time
"Now": Now,
"ParseTime": ParseTime,
"FormatTime": FormatTime,
"AddTime": AddTime,
"Duration": Duration,
"DescribeDuration": DescribeDuration,
2026-05-30 17:16:05 +08:00
// Logic
"Split": Split,
"SplitArgs": SplitArgs,
"JoinArgs": JoinArgs,
2026-05-30 17:16:05 +08:00
})
}
func jsFromJSON(data any) (any, error) {
var res any
err := UnmarshalJSON(data, &res)
if err != nil {
return nil, jsmod.MakeError(err)
}
return res, nil
}