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:
Alex Crichton
2018-10-10 15:53:50 -07:00
parent 70e13705b4
commit f9d2dbd0b6
2 changed files with 66 additions and 0 deletions

View File

@ -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);
}