mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-14 13:31:22 +00:00
js-sys: Add bindings for TypedArray.slice
This commit adds support for the `slice` function on all `TypedArray` instances. The `slice` function is similar to `subarray` except that it actually copies the data, whereas `subarray` just returns a different view into data.
This commit is contained in:
@ -88,3 +88,15 @@ macro_rules! test_fill {
|
||||
fn new_fill() {
|
||||
each!(test_fill);
|
||||
}
|
||||
|
||||
macro_rules! test_slice {
|
||||
($arr:ident) => {{
|
||||
let arr = $arr::new(&4.into());
|
||||
assert_eq!(arr.length(), 4);
|
||||
assert_eq!(arr.slice(1, 2).length(), 1);
|
||||
}};
|
||||
}
|
||||
#[wasm_bindgen_test]
|
||||
fn new_slice() {
|
||||
each!(test_slice);
|
||||
}
|
||||
|
Reference in New Issue
Block a user