Esempio n. 1
0
// StringifyFrame is only available with GopherJS.
func StringifyFrame(object *js.Object) *js.Object {
	if _, ok := object.Interface().(string); ok {
		return object
	}

	jsView := js.Global.Get("Uint8Array").New(object)
	goBytes := jsView.Interface().([]uint8)
	goString := string(goBytes)
	return js.Global.Get("String").New(goString)
}
Esempio n. 2
0
func StringSlice(o *js.Object) []string {
	if o == nil {
		return nil
	}
	d := o.Interface().([]interface{})
	ret := make([]string, len(d))
	for i, e := range d {
		ret[i] = e.(string)
	}
	return ret
}
Esempio n. 3
0
func Float64Slice(o *js.Object) []float64 {
	if o == nil {
		return nil
	}
	d := o.Interface().([]interface{})
	ret := make([]float64, len(d))
	for i, e := range d {
		ret[i] = e.(float64)
	}
	return ret
}
Esempio n. 4
0
func IntSlice(o *js.Object) []int {
	if o == nil {
		return nil
	}
	d := o.Interface().([]interface{})
	ret := make([]int, len(d))
	for i, e := range d {
		ret[i] = int(e.(float64))
	}
	return ret
}