0

There are a number of questions and resources about getting Typed arrays from an ArrayBuffer. An example: How to get an array from ArrayBuffer?. I need an actual array

I tried Array.from(myArrayBuffer) and get this:

//  buf is an ArrayBuffer(878468)
Array.from(buf) //  Array(0)  length: 0
WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560

1 Answers1

0

It seems there were no direct conversion from ArrayBuffer to a vanilla array. Two steps are needed

  • ArrayBuffer -> TypedArray
  • Array.from(typedArray)

So:

     let ab = new ArrayBuffer(1000)
     let arr = Array.from(new Float32Array(ab))

 
WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560