* Take into account byteoffset/length

This commit is contained in:
Michael Van Canneyt 2025-02-06 15:54:30 +01:00
parent fa88ecbe08
commit bc95a7dc7f

View File

@ -1495,13 +1495,18 @@ begin
end;
function SharedToNonShared(aArray : TJSTypedArray; aWordSized : Boolean = False): TJSTypedArray;
var
Buf : TJSSharedArrayBuffer;
begin
if HaveSharedArrayBuffer and (aArray.bufferObj is TJSSharedArrayBuffer) then
begin
Buf:=TJSSharedArrayBuffer(aArray.bufferObj).slice(aArray.byteOffset,aArray.byteLength);
if aWordSized then
Result:=TJSUInt16Array.New(SharedToNonShared(aArray.bufferObj))
Result:=TJSUInt16Array.New(SharedToNonShared(Buf))
else
Result:=TJSUInt8Array.New(SharedToNonShared(aArray.bufferObj))
Result:=TJSUInt8Array.New(SharedToNonShared(Buf))
end
else
Result:=aArray;
end;