callAsConstructor method
Calls an object as a constructor.
arguments
(JSValueRef[]) A JSValue array of arguments to pass to the constructor. Pass NULL if argumentCount is 0.
exception
(JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
@result
(JSObjectRef) The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor.
Implementation
JSObject callAsConstructor({
List<JSValue>? arguments,
bool autoDispose = true,
}) {
final JSException exception = JSException.create(context);
final JSValueRef valueRef = JSObjectCallAsConstructor(
context.ref,
_ref,
arguments?.length ?? 0,
arguments?.ref ?? nullptr,
exception.ref,
);
if (exception.shouldThrow) throw exception.error;
return JSObject(context, valueRef, autoDispose: autoDispose);
}