Browse Source

Add Is<Type> helpers

master
Brett Langdon 7 years ago
parent
commit
60d9a66c13
No known key found for this signature in database GPG Key ID: B664881177781B04
2 changed files with 20 additions and 0 deletions
  1. +10
    -0
      generate/static/value.go
  2. +10
    -0
      value.go

+ 10
- 0
generate/static/value.go View File

@ -41,3 +41,13 @@ func GetJSValue(v interface{}) interface{} {
}
return v
}
func (v Value) IsUndefined() bool { return v.Type() == js.TypeUndefined }
func (v Value) IsNull() bool { return v.Type() == js.TypeNull }
func (v Value) IsNullOrUndefined() bool { return v.IsNull() || v.IsUndefined() }
func (v Value) IsBoolean() bool { return v.Type() == js.TypeBoolean }
func (v Value) IsNumber() bool { return v.Type() == js.TypeNumber }
func (v Value) IsString() bool { return v.Type() == js.TypeString }
func (v Value) IsSymbol() bool { return v.Type() == js.TypeSymbol }
func (v Value) IsObject() bool { return v.Type() == js.TypeObject }
func (v Value) IsFunction() bool { return v.Type() == js.TypeFunction }

+ 10
- 0
value.go View File

@ -41,3 +41,13 @@ func GetJSValue(v interface{}) interface{} {
}
return v
}
func (v Value) IsUndefined() bool { return v.Type() == js.TypeUndefined }
func (v Value) IsNull() bool { return v.Type() == js.TypeNull }
func (v Value) IsNullOrUndefined() bool { return v.IsNull() || v.IsUndefined() }
func (v Value) IsBoolean() bool { return v.Type() == js.TypeBoolean }
func (v Value) IsNumber() bool { return v.Type() == js.TypeNumber }
func (v Value) IsString() bool { return v.Type() == js.TypeString }
func (v Value) IsSymbol() bool { return v.Type() == js.TypeSymbol }
func (v Value) IsObject() bool { return v.Type() == js.TypeObject }
func (v Value) IsFunction() bool { return v.Type() == js.TypeFunction }

Loading…
Cancel
Save