Example #1
0
//horrific way to do map(func)
func extractAllLetters(obj js.Object) js.Object {
	result := js.Global.Get("Array").New()
	for i := 0; i < obj.Length(); i++ {
		result.SetIndex(i, extractLetter(obj.Index(i)))
	}
	return result
}
Example #2
0
func wrapNodes(o *js.Object) []dom.Node {
	l := o.Length()
	toRet := make([]dom.Node, l)
	for i := 0; i < l; i++ {
		toRet[i] = dom.WrapNode(o.Index(i))
	}
	return toRet
}
Example #3
0
func getFloats(obj *js.Object) (ret []float64) {
	if (obj == js.Undefined) || (obj == nil) || (obj.Length() == 0) {
		return nil
	}

	ret = make([]float64, 0, obj.Length())
	for i := 0; i < obj.Length(); i++ {
		ret = append(ret, obj.Index(i).Float())
	}

	return
}