diff --git a/crates/js-sys/src/lib.rs b/crates/js-sys/src/lib.rs index d2d5e83d5..d6c746f66 100644 --- a/crates/js-sys/src/lib.rs +++ b/crates/js-sys/src/lib.rs @@ -3065,9 +3065,17 @@ pub mod WebAssembly { /// The `get()` prototype method of the `WebAssembly.Table()` object /// retrieves a function reference stored at a given index. /// - /// [MDN documentation]( + /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get) #[wasm_bindgen(method, catch, js_namespace = WebAssembly)] pub fn get(this: &Table, index: u32) -> Result; + + /// The `grow()` prototype method of the `WebAssembly.Table` object + /// increases the size of the `Table` instance by a specified number of + /// elements. + /// + /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/grow) + #[wasm_bindgen(method, catch, js_namespace = WebAssembly)] + pub fn grow(this: &Table, additional_capacity: u32) -> Result; } // WebAssembly.Memory diff --git a/crates/js-sys/tests/wasm/WebAssembly.rs b/crates/js-sys/tests/wasm/WebAssembly.rs index d2e42a697..230a4bfcc 100644 --- a/crates/js-sys/tests/wasm/WebAssembly.rs +++ b/crates/js-sys/tests/wasm/WebAssembly.rs @@ -130,6 +130,9 @@ fn table() { assert!(table.get(0).is_ok()); assert!(table.get(999).is_err()); + + table.grow(1).unwrap(); + assert_eq!(table.length(), 2); } #[wasm_bindgen_test]