Skip to content

Commit 7aa04d6

Browse files
Types: Using Uint8Array instead of Buffer
The API supports at various places to use Uint8Arrays to be used instead of Buffers. This PR loosens the type restrictions on a few instances where I noticed that an Uint8Array would suffice.
1 parent 2b1286b commit 7aa04d6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export class Buffer extends Uint8Array {
44
toString(encoding?: string, start?: number, end?: number): string;
55
toJSON(): { type: 'Buffer', data: any[] };
66
equals(otherBuffer: Buffer): boolean;
7-
compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
7+
compare(otherBuffer: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
88
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
99
slice(start?: number, end?: number): Buffer;
1010
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
@@ -163,11 +163,11 @@ export class Buffer extends Uint8Array {
163163
* @param totalLength Total length of the buffers when concatenated.
164164
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
165165
*/
166-
static concat(list: Buffer[], totalLength?: number): Buffer;
166+
static concat(list: Uint8Array[], totalLength?: number): Buffer;
167167
/**
168168
* The same as buf1.compare(buf2).
169169
*/
170-
static compare(buf1: Buffer, buf2: Buffer): number;
170+
static compare(buf1: Uint8Array, buf2: Uint8Array): number;
171171
/**
172172
* Allocates a new buffer of {size} octets.
173173
*

0 commit comments

Comments
 (0)