Пример #1
0
// Convert a value to Object.
func (v *Value) ToObject() *Object {
	var result *Object

	v.cx.rt.Use(func() {
		var obj *C.JSObject
		if C.JS_ValueToObject(v.cx.jscx, v.val, &obj) == C.JS_TRUE {
			result = newObject(v.cx, obj, nil)
		}
	})

	return result
}
Пример #2
0
// Convert a value to Array.
func (v *Value) ToArray() *Array {
	var result *Array

	v.cx.rt.Use(func() {
		var obj *C.JSObject
		if C.JS_ValueToObject(v.cx.jscx, v.val, &obj) == C.JS_TRUE {
			if C.JS_IsArrayObject(v.cx.jscx, obj) == C.JS_TRUE {
				result = newArray(v.cx, obj)
			}
		}
	})

	return result
}