haxe icon indicating copy to clipboard operation
haxe copied to clipboard

[js] implement haxe.io.ArrayBufferView.fromBytes()

Open zagortenej opened this issue 4 months ago • 0 comments

haxe.io.ArrayBufferView.fromBytes() does not exist for JS target as per docs (and source code, ofc): https://api.haxe.org/haxe/io/ArrayBufferView.html

This PR implements fromBytes() for JS target based on how fromBytes() is implemented in /std/haxe/io/ArrayBufferView: https://github.com/HaxeFoundation/haxe/blob/e0b355c6be312c1b17382603f018cf52522ec651/std/haxe/io/ArrayBufferView.hx#L89.

ArrayBufferViewData for JS target is js.lib.ArrayBufferView which is a helper representing JS TypedArray. Uint8Array is one of the native JS typed arrays, and Haxe UInt8ArrayData has been used to implement fromBytes for JS in similar way it is in the source link above.

UInt8ArrayData for JS target does not unify with ArrayBufferViewImpl from the source link above, however the implementation in this post seems to work on JS target in my tests.

zagortenej avatar Sep 06 '25 21:09 zagortenej