pub struct JsObject(/* private fields */);
Implementations§
Source§impl JsObject
impl JsObject
pub fn new(env: NapiEnv) -> NapiResult<JsObject>
Sourcepub fn set_named_property(
&mut self,
key: impl AsRef<str>,
value: impl NapiValueT,
) -> NapiResult<()>
pub fn set_named_property( &mut self, key: impl AsRef<str>, value: impl NapiValueT, ) -> NapiResult<()>
This method is equivalent to calling napi_get_property with a napi_value created from the string passed in as utf8Name.
Sourcepub fn get_property_names(&self) -> NapiResult<JsArray>
pub fn get_property_names(&self) -> NapiResult<JsArray>
This API returns the names of the enumerable properties of object as an array of strings. The properties of object whose key is a symbol will not be included.
Sourcepub fn get_all_property_names(
&self,
mode: NapiKeyCollectionMode,
filter: NapiKeyFilter,
conversion: NapiKeyConversion,
) -> NapiResult<JsArray>
pub fn get_all_property_names( &self, mode: NapiKeyCollectionMode, filter: NapiKeyFilter, conversion: NapiKeyConversion, ) -> NapiResult<JsArray>
This API returns an array containing the names of the available properties of this object.
Sourcepub fn set<T: NapiValueT>(
&mut self,
key: impl AsRef<str>,
value: T,
) -> NapiResult<()>
pub fn set<T: NapiValueT>( &mut self, key: impl AsRef<str>, value: T, ) -> NapiResult<()>
Set value by string-like key.
Sourcepub fn set_property(
&mut self,
key: impl NapiValueT,
value: impl NapiValueT,
) -> NapiResult<()>
pub fn set_property( &mut self, key: impl NapiValueT, value: impl NapiValueT, ) -> NapiResult<()>
This API set a property on the Object passed in.
Sourcepub fn get_property(&self, key: impl NapiValueT) -> NapiResult<JsValue>
pub fn get_property(&self, key: impl NapiValueT) -> NapiResult<JsValue>
This API gets the requested property from the Object passed in.
Sourcepub unsafe fn get_unchecked<T: NapiValueT>(
&self,
key: impl AsRef<str>,
) -> NapiResult<T>
pub unsafe fn get_unchecked<T: NapiValueT>( &self, key: impl AsRef<str>, ) -> NapiResult<T>
Get value by string-like key.
§Safety
This function just put napi handle in struct T
without any check. It is your duty to
make sure the origin value is really type of T
.
Sourcepub fn get<T: NapiValueT>(&self, key: impl AsRef<str>) -> NapiResult<T>
pub fn get<T: NapiValueT>(&self, key: impl AsRef<str>) -> NapiResult<T>
Get value by string-like key.
Sourcepub fn has_property(&self, key: impl NapiValueT) -> NapiResult<bool>
pub fn has_property(&self, key: impl NapiValueT) -> NapiResult<bool>
This API checks if the Object passed in has the named property.
Sourcepub fn delete_property(&self, key: impl NapiValueT) -> NapiResult<bool>
pub fn delete_property(&self, key: impl NapiValueT) -> NapiResult<bool>
This API attempts to delete the key own property from object.
Sourcepub fn has_own_property(
&mut self,
key: impl NapiValueT,
value: impl NapiValueT,
) -> NapiResult<bool>
pub fn has_own_property( &mut self, key: impl NapiValueT, value: impl NapiValueT, ) -> NapiResult<bool>
This API checks if the Object passed in has the named own property. key must be a string or a symbol, or an error will be thrown. Node-API will not perform any conversion between data types.
Sourcepub fn get_named_property(&self, key: impl AsRef<str>) -> NapiResult<JsValue>
pub fn get_named_property(&self, key: impl AsRef<str>) -> NapiResult<JsValue>
This method is equivalent to calling napi_get_property with a napi_value created from the string passed in as utf8Name.
Sourcepub fn has_named_property(&self, key: impl AsRef<str>) -> NapiResult<bool>
pub fn has_named_property(&self, key: impl AsRef<str>) -> NapiResult<bool>
This method is equivalent to calling napi_has_property with a napi_value created from the string passed in as utf8Name.
Sourcepub fn set_element(
&mut self,
index: u32,
value: impl NapiValueT,
) -> NapiResult<()>
pub fn set_element( &mut self, index: u32, value: impl NapiValueT, ) -> NapiResult<()>
This API sets an element on the Object passed in.
Sourcepub fn get_element(&mut self, index: u32) -> NapiResult<JsValue>
pub fn get_element(&mut self, index: u32) -> NapiResult<JsValue>
This API gets the element at the requested index.
Sourcepub fn has_element(&mut self, index: u32) -> NapiResult<bool>
pub fn has_element(&mut self, index: u32) -> NapiResult<bool>
This API returns if the Object passed in has an element at the requested index.
Sourcepub fn delete_element(&mut self, index: u32) -> NapiResult<bool>
pub fn delete_element(&mut self, index: u32) -> NapiResult<bool>
This API attempts to delete the specified index from object.
Sourcepub fn freeze(&mut self) -> NapiResult<()>
pub fn freeze(&mut self) -> NapiResult<()>
Object.freeze()
Sourcepub fn seal(&mut self) -> NapiResult<()>
pub fn seal(&mut self) -> NapiResult<()>
Object.seal()