pub struct JsObject {
pub prototype: Option<JsObjectRef>,
pub extensible: bool,
pub frozen: bool,
pub sealed: bool,
pub null_prototype: bool,
pub properties: PropertyStorage,
pub exotic: ExoticObject,
pub private_fields: Option<FxHashMap<PrivateFieldKey, JsValue>>,
}Expand description
A JavaScript object
Fields§
§prototype: Option<JsObjectRef>Prototype link
extensible: boolWhether the object can have properties added
frozen: boolWhether the object is frozen (no modifications allowed)
sealed: boolWhether the object is sealed (no new properties, but existing can be modified)
null_prototype: boolWhether this object was explicitly created with null prototype (Object.create(null))
properties: PropertyStorageObject properties (optimized for small objects)
exotic: ExoticObjectExotic object behavior
private_fields: Option<FxHashMap<PrivateFieldKey, JsValue>>Private fields storage (only used by instances of classes with private members) Key is (ClassBrandId, field_name), value is the private field/method value
Implementations§
Source§impl JsObject
impl JsObject
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new ordinary object with pre-allocated property capacity
Sourcepub fn with_prototype(prototype: JsObjectRef) -> Self
pub fn with_prototype(prototype: JsObjectRef) -> Self
Create a new ordinary object with a prototype
Sourcepub fn get_private_field(&self, key: &PrivateFieldKey) -> Option<&JsValue>
pub fn get_private_field(&self, key: &PrivateFieldKey) -> Option<&JsValue>
Get a private field value
Sourcepub fn set_private_field(&mut self, key: PrivateFieldKey, value: JsValue)
pub fn set_private_field(&mut self, key: PrivateFieldKey, value: JsValue)
Set a private field value
Sourcepub fn has_private_field(&self, key: &PrivateFieldKey) -> bool
pub fn has_private_field(&self, key: &PrivateFieldKey) -> bool
Check if an object has a specific private field
Sourcepub fn is_callable(&self) -> bool
pub fn is_callable(&self) -> bool
Check if this object is callable
Sourcepub fn get_own_property(&self, key: &PropertyKey) -> Option<&Property>
pub fn get_own_property(&self, key: &PropertyKey) -> Option<&Property>
Get an own property
Sourcepub fn get_property(&self, key: &PropertyKey) -> Option<JsValue>
pub fn get_property(&self, key: &PropertyKey) -> Option<JsValue>
Get a property, searching the prototype chain
Sourcepub fn get_property_descriptor(
&self,
key: &PropertyKey,
) -> Option<(Property, bool)>
pub fn get_property_descriptor( &self, key: &PropertyKey, ) -> Option<(Property, bool)>
Get a property descriptor, searching the prototype chain Returns (property, found_in_prototype)
Sourcepub fn set_property(&mut self, key: PropertyKey, value: JsValue)
pub fn set_property(&mut self, key: PropertyKey, value: JsValue)
Set a property
Sourcepub fn define_property(&mut self, key: PropertyKey, prop: Property)
pub fn define_property(&mut self, key: PropertyKey, prop: Property)
Define a property with attributes
Sourcepub fn has_own_property(&self, key: &PropertyKey) -> bool
pub fn has_own_property(&self, key: &PropertyKey) -> bool
Check if object has own property
Sourcepub fn own_keys(&self) -> Vec<PropertyKey>
pub fn own_keys(&self) -> Vec<PropertyKey>
Get own property keys
Sourcepub fn array_length(&self) -> Option<u32>
pub fn array_length(&self) -> Option<u32>
Get array length if this is an array, None otherwise
Sourcepub fn array_elements(&self) -> Option<&[JsValue]>
pub fn array_elements(&self) -> Option<&[JsValue]>
Get array elements slice if this is an array
Sourcepub fn array_elements_mut(&mut self) -> Option<&mut Vec<JsValue>>
pub fn array_elements_mut(&mut self) -> Option<&mut Vec<JsValue>>
Get mutable array elements if this is an array
Source§impl JsObject
impl JsObject
Sourcepub fn as_environment(&self) -> Option<&EnvironmentData>
pub fn as_environment(&self) -> Option<&EnvironmentData>
Get environment data if this is an environment object
Sourcepub fn as_environment_mut(&mut self) -> Option<&mut EnvironmentData>
pub fn as_environment_mut(&mut self) -> Option<&mut EnvironmentData>
Get mutable environment data if this is an environment object
Sourcepub fn is_environment(&self) -> bool
pub fn is_environment(&self) -> bool
Check if this object is an environment