Skip to content

Commit a4cef7c

Browse files
committed
chore: simplify arraybuffer logic
1 parent 06b0cb7 commit a4cef7c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

fallback/_utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ export function fromBuffer(arr, format) {
4848

4949
return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength)
5050
case 'arraybuffer':
51-
return fromBuffer(arr, 'uint8').buffer
51+
return arr.buffer.byteLength === arr.byteLength
52+
? arr.buffer
53+
: arr.buffer.slice(arr.byteOffset, arr.byteOffset + arr.byteLength)
5254
case 'buffer':
5355
if (arr.constructor !== Buffer) throw new Error('Unexpected')
5456
return arr

0 commit comments

Comments
 (0)