mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-16 18:32:13 +00:00
implements Object.prototype.isPrototypeOf() binding
This commit is contained in:
parent
6ef817b350
commit
1e1276410a
@ -98,6 +98,13 @@ extern {
|
|||||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf
|
||||||
#[wasm_bindgen(method, js_name = isPrototypeOf)]
|
#[wasm_bindgen(method, js_name = isPrototypeOf)]
|
||||||
pub fn is_prototype_of(this: &Object, value: &JsValue) -> bool;
|
pub fn is_prototype_of(this: &Object, value: &JsValue) -> bool;
|
||||||
|
|
||||||
|
/// The propertyIsEnumerable() method returns a Boolean indicating
|
||||||
|
/// whether the specified property is enumerable.
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable
|
||||||
|
#[wasm_bindgen(method, js_name = propertyIsEnumerable)]
|
||||||
|
pub fn property_is_enumerable(this: &Object, property: &JsValue) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Array
|
// Array
|
||||||
|
@ -118,3 +118,29 @@ fn is_prototype_of() {
|
|||||||
"#)
|
"#)
|
||||||
.test()
|
.test()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn property_is_enumerable() {
|
||||||
|
project()
|
||||||
|
.file("src/lib.rs", r#"
|
||||||
|
#![feature(proc_macro, wasm_custom_section)]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen;
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
use wasm_bindgen::js;
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn property_is_enumerable(obj: &js::Object, property: &JsValue) -> bool {
|
||||||
|
obj.property_is_enumerable(&property)
|
||||||
|
}
|
||||||
|
"#)
|
||||||
|
.file("test.ts", r#"
|
||||||
|
import * as assert from "assert";
|
||||||
|
import * as wasm from "./out";
|
||||||
|
|
||||||
|
export function test() {
|
||||||
|
assert(wasm.property_is_enumerable({ foo: 42 }, "foo"));
|
||||||
|
}
|
||||||
|
"#)
|
||||||
|
.test()
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user