Added ObjectRemoveProp.

This commit is contained in:
Filipe Rodrigues 2024-02-16 15:22:11 +00:00
parent 62b391d318
commit f010fa0401
Signed by: zenithsiz
SSH Key Fingerprint: SHA256:Mb5ppb3Sh7IarBO/sBTXLHbYEOz37hJAlslLQPPAPaU

View File

@ -65,6 +65,17 @@ pub impl js_sys::Object {
}
}
/// Extension trait to remove a property on an object
#[extend::ext(name = ObjectRemoveProp)]
pub impl js_sys::Object {
/// Removes the `property` from this object.
///
/// Returns if the property existed
fn remove_prop(&self, property: &str) -> bool {
Reflect::delete_property(self, &property.into()).expect("Unable to remove object property")
}
}
/// Error for [`ObjectGet::get`]
#[derive(Clone, Debug)]
pub enum GetError {