File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,13 @@ extern {
98
98
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf
99
99
#[ wasm_bindgen( method, js_name = isPrototypeOf) ]
100
100
pub fn is_prototype_of ( this : & Object , value : & JsValue ) -> bool ;
101
+
102
+ /// The propertyIsEnumerable() method returns a Boolean indicating
103
+ /// whether the specified property is enumerable.
104
+ ///
105
+ /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable
106
+ #[ wasm_bindgen( method, js_name = propertyIsEnumerable) ]
107
+ pub fn property_is_enumerable ( this : & Object , property : & JsValue ) -> bool ;
101
108
}
102
109
103
110
// Array
Original file line number Diff line number Diff line change @@ -118,3 +118,38 @@ fn is_prototype_of() {
118
118
"# )
119
119
. test ( )
120
120
}
121
+
122
+ #[ test]
123
+ fn property_is_enumerable ( ) {
124
+ project ( )
125
+ . file ( "src/lib.rs" , r#"
126
+ #![feature(proc_macro, wasm_custom_section)]
127
+
128
+ extern crate wasm_bindgen;
129
+ use wasm_bindgen::prelude::*;
130
+ use wasm_bindgen::js;
131
+
132
+ #[wasm_bindgen]
133
+ pub fn property_is_enumerable(obj: &js::Object, property: &JsValue) -> bool {
134
+ obj.property_is_enumerable(&property)
135
+ }
136
+ "# )
137
+ . file ( "test.ts" , r#"
138
+ import * as assert from "assert";
139
+ import * as wasm from "./out";
140
+
141
+ export function test() {
142
+ assert(wasm.property_is_enumerable({ foo: 42 }, "foo"));
143
+ assert(wasm.property_is_enumerable({ 42: "foo" }, 42));
144
+ assert(!wasm.property_is_enumerable({}, 42));
145
+
146
+ const obj = {};
147
+ Object.defineProperty(obj, "foo", { enumerable: false });
148
+ assert(!wasm.property_is_enumerable(obj, "foo"));
149
+
150
+ const s = Symbol();
151
+ assert.ok(wasm.property_is_enumerable({ [s]: true }, s));
152
+ }
153
+ "# )
154
+ . test ( )
155
+ }
You can’t perform that action at this time.
0 commit comments