getProperty method

JSValue getProperty(
  1. String propertyName, {
  2. bool autoDispose = true,
})

Tests whether an object has a given property. propertyName (JSStringRef) A JSString containing the property's name. 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.

Implementation

JSValue getProperty(String propertyName, {bool autoDispose = true}) {
  final JSException exception = JSException.create(context);
  final JSString jspropName = JSString.fromString(propertyName);
  final JSValue value = JSValue(
    context,
    JSObjectGetProperty(context.ref, _ref, jspropName.ref, exception.ref),
    autoDispose: autoDispose,
  );
  if (exception.shouldThrow) throw exception.error;
  return value;
}