add NewUUID() to jsutil

This commit is contained in:
syumai 2023-02-06 02:48:45 +09:00
parent b8bd0f88dc
commit f25a65c45a

View File

@ -18,6 +18,7 @@ var (
ErrorClass = Global.Get("Error")
ReadableStreamClass = Global.Get("ReadableStream")
DateClass = Global.Get("Date")
Crypto = Global.Get("crypto")
)
func NewObject() js.Value {
@ -102,3 +103,7 @@ func DateToTime(v js.Value) (time.Time, error) {
func TimeToDate(t time.Time) js.Value {
return DateClass.New(t.UnixMilli())
}
func NewUUID() string {
return Crypto.Call("randomUUID").String()
}