mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 10:10:52 +00:00
feat(Map): add Map.new
This commit is contained in:
parent
07e61e1175
commit
27ee57175a
@ -331,6 +331,13 @@ extern {
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has
|
||||
#[wasm_bindgen(method)]
|
||||
pub fn has(this: &Map, key: &JsValue) -> bool;
|
||||
|
||||
/// The Map object holds key-value pairs. Any value (both objects and
|
||||
/// primitive values) maybe used as either a key or a value.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new() -> Map;
|
||||
}
|
||||
|
||||
// Math
|
||||
|
@ -124,4 +124,32 @@ fn has() {
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new() {
|
||||
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 new_map() -> js::Map {
|
||||
js::Map::new()
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
const map = wasm.new_map();
|
||||
|
||||
assert.equal(map.size, 0);
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user