Skip to content

Commit

Permalink
Reverted checking for Buffer API's existence.
Browse files Browse the repository at this point in the history
  • Loading branch information
iwoplaza committed Jul 20, 2024
1 parent e7f3d47 commit 232857f
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/io/bufferIOBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,6 @@ export type BufferIOOptions = {
endianness?: Endianness | 'system';
};

interface BufferView {
byteOffset: number;
buffer: ArrayBufferLike;
}

function isBufferView(value: unknown): value is BufferView {
const BufferImpl =
typeof global !== 'undefined' && 'Buffer' in global
? global.Buffer
: undefined;
return !!BufferImpl && value instanceof BufferImpl;
}

export class BufferIOBase {
protected readonly uint8View: Uint8Array;
protected readonly helperInt32View: Int32Array;
Expand All @@ -47,7 +34,7 @@ export class BufferIOBase {
this.switchEndianness = this.endianness !== systemEndianness;

let innerBuffer = buffer;
if (isBufferView(innerBuffer)) {
if (typeof Buffer !== 'undefined' && innerBuffer instanceof Buffer) {
// Getting rid of the outer shell, which causes the Uint8Array line to create a copy, instead of a view.
this.byteOffset += innerBuffer.byteOffset;
innerBuffer = innerBuffer.buffer;
Expand Down

0 comments on commit 232857f

Please sign in to comment.