mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-14 21:41:23 +00:00
Add binding for Object.getOwnPropertySymbols()
This commit is contained in:
@ -2048,6 +2048,13 @@ extern "C" {
|
||||
#[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyNames)]
|
||||
pub fn get_own_property_names(obj: &Object) -> Array;
|
||||
|
||||
/// The Object.getOwnPropertySymbols() method returns an array of
|
||||
/// all symbol properties found directly upon a given object.
|
||||
///
|
||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols)
|
||||
#[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertySymbols)]
|
||||
pub fn get_own_property_symbols(obj: &Object) -> Array;
|
||||
|
||||
/// The `hasOwnProperty()` method returns a boolean indicating whether the
|
||||
/// object has the specified property as its own property (as opposed to
|
||||
/// inheriting it).
|
||||
|
@ -131,6 +131,12 @@ fn get_own_property_names() {
|
||||
});
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn get_own_property_symbols() {
|
||||
let symbols = Object::get_own_property_symbols(&map_with_symbol_key());
|
||||
assert_eq!(symbols.length(), 1);
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn has_own_property() {
|
||||
assert!(foo_42().has_own_property(&"foo".into()));
|
||||
|
Reference in New Issue
Block a user