Merge pull request #318 from xeqlol/weakmap-bindings

WeakMap bindings
This commit is contained in:
Nick Fitzgerald
2018-06-26 12:55:30 -07:00
committed by GitHub
3 changed files with 195 additions and 0 deletions

View File

@ -579,6 +579,46 @@ extern {
pub fn value_of(this: &Object) -> Object;
}
// WeakMap
#[wasm_bindgen]
extern {
pub type WeakMap;
/// The WeakMap object is a collection of key/value pairs in which the keys are weakly referenced.
/// The keys must be objects and the values can be arbitrary values.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap
#[wasm_bindgen(constructor)]
pub fn new() -> WeakMap;
/// The set() method sets the value for the key in the WeakMap object. Returns
/// the WeakMap object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set
#[wasm_bindgen(method, js_class="WeakMap")]
pub fn set(this: &WeakMap, key: Object, value: JsValue) -> WeakMap;
/// The get() method returns a specified by key element
/// from a WeakMap object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get
#[wasm_bindgen(method)]
pub fn get(this: &WeakMap, key: Object) -> JsValue;
/// The has() method returns a boolean indicating whether an element with
/// the specified key exists in the WeakMap object or not.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has
#[wasm_bindgen(method)]
pub fn has(this: &WeakMap, key: Object) -> bool;
/// The delete() method removes the specified element from a WeakMap object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete
#[wasm_bindgen(method)]
pub fn delete(this: &WeakMap, key: Object) -> bool;
}
// JsString
#[wasm_bindgen]
extern {