From 7aa04d6951870fed0b021981963b48fabbc01660 Mon Sep 17 00:00:00 2001 From: Martin Heidegger Date: Sat, 21 Nov 2020 11:05:07 +0900 Subject: [PATCH] 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. --- index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 5aa3549..07096a2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4,7 +4,7 @@ export class Buffer extends Uint8Array { toString(encoding?: string, start?: number, end?: number): string; toJSON(): { type: 'Buffer', data: any[] }; equals(otherBuffer: Buffer): boolean; - compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number; + compare(otherBuffer: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number; copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; slice(start?: number, end?: number): Buffer; writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; @@ -163,11 +163,11 @@ export class Buffer extends Uint8Array { * @param totalLength Total length of the buffers when concatenated. * 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. */ - static concat(list: Buffer[], totalLength?: number): Buffer; + static concat(list: Uint8Array[], totalLength?: number): Buffer; /** * The same as buf1.compare(buf2). */ - static compare(buf1: Buffer, buf2: Buffer): number; + static compare(buf1: Uint8Array, buf2: Uint8Array): number; /** * Allocates a new buffer of {size} octets. * -- 2.34.1