There are some apis accept parameters with type array_like<'a>
, but i can not find any way to create a value with that type.
The api with array_like<'a> parameters are blow:
Js.TypedArray2.Float32Array.from
Js.TypedArray2.from...
I thought array_like
was just for binding to JS, and those from
functions were for casting values passed from JS APIs that have array_like
return values.
To create a Float32Array
from an array<float>
in ReScript you could use make
instead of from
Currently, there is no way to create a TypedArray from literal except you create a binding to do this.
In ts/js, you can do this
const array = new Uint8Array([1, 2, 3, 4])
2 Likes
Or (if you are not using @rescript/core) you could use Js.TypedArray2.Uint8Array like so:
let array = Js.TypedArray2.Uint8Array.make([1,2,3,4])