evaluate method
Implementation
JSValue evaluate(
String script, {
JSObject? thisObject,
String? sourceURL,
int startingLineNumber = 1,
}) {
final JSException exception = JSException.create(this);
final JSString jsScript = JSString.fromString(script);
final JSString? jsSourceURL = sourceURL != null ? JSString.fromString(sourceURL) : null;
try {
final JSValueRef valueRef = JSEvaluateScript(
_ref,
jsScript.ref,
thisObject?.ref ?? nullptr,
jsSourceURL?.ref ?? nullptr,
startingLineNumber,
exception.ref,
);
if (exception.shouldThrow) {
throw exception.error;
}
return JSValue(this, valueRef);
} finally {
jsSourceURL?.release();
jsScript.release();
exception.release();
}
}