当前位置: 首页>>代码示例>>Golang>>正文


Golang Object.Float方法代码示例

本文整理汇总了Golang中github.com/gopherjs/gopherjs/js.Object.Float方法的典型用法代码示例。如果您正苦于以下问题:Golang Object.Float方法的具体用法?Golang Object.Float怎么用?Golang Object.Float使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/gopherjs/gopherjs/js.Object的用法示例。


在下文中一共展示了Object.Float方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: isEmpty

func isEmpty(v, t *js.Object) bool {
	switch t.Get("kind").Int() {
	case boolKind:
		return !v.Bool()
	case int8Kind, int16Kind, int32Kind, intKind, uint8Kind, uint16Kind, uint32Kind, uintKind:
		return v.Int() == 0
	case int64Kind, uint64Kind:
		return v.Int64() == 0
	case float32Kind, float64Kind:
		return v.Float() == 0
	case arrayKind, sliceKind, stringKind:
		return v.Length() == 0
	case ptrKind:
		return v == t.Get("nil")
	case interfaceKind:
		if v.Get("$val") == js.Undefined {
			return true
		}
		return isEmpty(v.Get("$val"), v.Get("constructor"))
	case mapKind:
		return js.Global.Get("Object").Call("keys", v).Length() == 0
	}
	return false
}
开发者ID:MJKWoolnough,项目名称:gopherjs,代码行数:24,代码来源:encode.go

示例2: LinearF

//LinearF calls the scale to interpolate a value into its range and returns
//the results as a float. If the extractor function is specified, it should
//pull the floating point input value out of the provided object.
func (self *linearScaleImpl) LinearF(obj js.Object, fn ExtractorFuncF) float64 {
	if fn != nil {
		return self.obj.Invoke(fn(obj)).Float()
	}
	return self.obj.Invoke(obj.Float()).Float()
}
开发者ID:nplanel,项目名称:d3,代码行数:9,代码来源:d3.go


注:本文中的github.com/gopherjs/gopherjs/js.Object.Float方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。