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 }
//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() }