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

Method tryPrimitive

object.go:837–849  ·  view source on GitHub ↗
(methodName unistring.String)

Source from the content-addressed store, hash-verified

835}
836
837func (o *Object) tryPrimitive(methodName unistring.String) Value {
838 if method, ok := o.self.getStr(methodName, nil).(*Object); ok {
839 if call, ok := method.self.assertCallable(); ok {
840 v := call(FunctionCall{
841 This: o,
842 })
843 if _, fail := v.(*Object); !fail {
844 return v
845 }
846 }
847 }
848 return nil
849}
850
851func (o *Object) ordinaryToPrimitiveNumber() Value {
852 if v := o.tryPrimitive("valueOf"); v != nil {

Callers 2

Calls 3

callTypeAlias · 0.85
getStrMethod · 0.65
assertCallableMethod · 0.65

Tested by

no test coverage detected