MCPcopy Create free account
hub / github.com/dop251/goja / tryExoticToPrimitive

Method tryExoticToPrimitive

object.go:875–888  ·  view source on GitHub ↗
(hint Value)

Source from the content-addressed store, hash-verified

873}
874
875func (o *Object) tryExoticToPrimitive(hint Value) Value {
876 exoticToPrimitive := toMethod(o.self.getSym(SymToPrimitive, nil))
877 if exoticToPrimitive != nil {
878 ret := exoticToPrimitive(FunctionCall{
879 This: o,
880 Arguments: []Value{hint},
881 })
882 if _, fail := ret.(*Object); !fail {
883 return ret
884 }
885 panic(o.runtime.NewTypeError("Cannot convert object to primitive value"))
886 }
887 return nil
888}
889
890func (o *Object) toPrimitiveNumber() Value {
891 if v := o.tryExoticToPrimitive(hintNumber); v != nil {

Callers 3

toPrimitiveNumberMethod · 0.95
toPrimitiveStringMethod · 0.95
toPrimitiveMethod · 0.95

Calls 3

toMethodFunction · 0.85
NewTypeErrorMethod · 0.80
getSymMethod · 0.65

Tested by

no test coverage detected