package bindings
import (
"fmt"
"syscall/js"
)
type String string
func (s String) From(v js.Value) String {
return String(v.String())
}
func (s String) TryFrom(v js.Value) (String, error) {
if v.Type() != js.TypeString {
return s, fmt.Errorf("js.Value is not a string")
}
return s.From(v), nil
}
type Bool bool
func (b Bool) From(v js.Value) Bool {
return Bool(v.Bool())
}
func (b Bool) TryFrom(v js.Value) (Bool, error) {
if v.Type() != js.TypeBoolean {
return b, fmt.Errorf("js.Value is not a boolean")
}
return b.From(v), nil
}