github.com/goplusjs/gopherjs@v1.2.6-0.20211206034512-f187917453b8/compiler/typesutil/typesutil.go (about)

     1  package typesutil
     2  
     3  import "go/types"
     4  
     5  func IsJsPackage(pkg *types.Package) bool {
     6  	return pkg != nil && pkg.Path() == "github.com/gopherjs/gopherjs/js"
     7  }
     8  
     9  func IsJsObject(t types.Type) bool {
    10  	ptr, isPtr := t.(*types.Pointer)
    11  	if !isPtr {
    12  		return false
    13  	}
    14  	named, isNamed := ptr.Elem().(*types.Named)
    15  	return isNamed && IsJsPackage(named.Obj().Pkg()) && named.Obj().Name() == "Object"
    16  }