File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,13 @@ extern {
254
254
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable
255
255
#[ wasm_bindgen( method, js_name = propertyIsEnumerable) ]
256
256
pub fn property_is_enumerable ( this : & Object , property : & JsValue ) -> bool ;
257
+
258
+ /// The valueOf() method returns the primitive value of the
259
+ /// specified object.
260
+ ///
261
+ /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf
262
+ #[ wasm_bindgen( method, js_name = valueOf) ]
263
+ pub fn value_of ( this : & Object ) -> Object ;
257
264
}
258
265
259
266
// String
Original file line number Diff line number Diff line change @@ -184,3 +184,31 @@ fn to_locale_string() {
184
184
"# )
185
185
. test ( )
186
186
}
187
+
188
+ #[ test]
189
+ fn value_of ( ) {
190
+ project ( )
191
+ . file ( "src/lib.rs" , r#"
192
+ #![feature(proc_macro, wasm_custom_section)]
193
+
194
+ extern crate wasm_bindgen;
195
+ use wasm_bindgen::prelude::*;
196
+ use wasm_bindgen::js;
197
+
198
+ #[wasm_bindgen]
199
+ pub fn value_of(obj: &js::Object) -> js::Object {
200
+ obj.value_of()
201
+ }
202
+ "# )
203
+ . file ( "test.ts" , r#"
204
+ import * as assert from "assert";
205
+ import * as wasm from "./out";
206
+
207
+ export function test() {
208
+ const obj = { foo: 42 };
209
+ assert.strictEqual(wasm.value_of(obj), obj);
210
+ assert.notStrictEqual(wasm.value_of(obj), { foo: 42 });
211
+ }
212
+ "# )
213
+ . test ( )
214
+ }
You can’t perform that action at this time.
0 commit comments