purescript-contrib/purescript-arraybuffer

fromUint8Array, toUint8Array

Closed this issue · 1 comments

I find myself needing to do these casts all the time and I think we should add these to the package.

Really these two types are the same type and making them different was a JavaScript design mistake.

fromUint8Array :: Uint8Array -> Effect DataView
fromUint8Array x = DV.part (AT.buffer x) (AT.byteOffset x) (AT.byteLength x)

toUint8Array :: DataView -> Effect Uint8Array
toUint8Array x = AT.part (DV.buffer x) (DV.byteOffset x) (DV.byteLength x)

Maybe castDataView, castUint8Array.