From 58c372756f07af57915f0447f917f22596add00a Mon Sep 17 00:00:00 2001 From: Andreas Thomas Date: Thu, 10 Dec 2020 13:14:18 +0100 Subject: [PATCH 1/2] Fix `write{U}Int{LE,BE} types They should take a BigInt as parameter and return the written bytes as regular number, right? At least that's what it actually does :) --- index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index 07096a2f..01da37c5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -42,15 +42,15 @@ export class Buffer extends Uint8Array { writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeBigUInt64LE(value: number, offset: number): BigInt; - writeBigUInt64BE(value: number, offset: number): BigInt; + writeBigUInt64LE(value: BigInt, offset: number): number; + writeBigUInt64BE(value: BigInt, offset: number): number; writeInt8(value: number, offset: number, noAssert?: boolean): number; writeInt16LE(value: number, offset: number, noAssert?: boolean): number; writeInt16BE(value: number, offset: number, noAssert?: boolean): number; writeInt32LE(value: number, offset: number, noAssert?: boolean): number; writeInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeBigInt64LE(value: number, offset: number): BigInt; - writeBigInt64BE(value: number, offset: number): BigInt; + writeBigInt64LE(value: BigInt, offset: number): number; + writeBigInt64BE(value: BigInt, offset: number): number; writeFloatLE(value: number, offset: number, noAssert?: boolean): number; writeFloatBE(value: number, offset: number, noAssert?: boolean): number; writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; From c716b6d79f5b567da7becb756a956c07842da897 Mon Sep 17 00:00:00 2001 From: Andreas Thomas Date: Mon, 11 Jan 2021 14:47:59 +0100 Subject: [PATCH 2/2] Make offset optional to match node Buffer implementation --- index.d.ts | 70 +++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/index.d.ts b/index.d.ts index 01da37c5..1342b529 100644 --- a/index.d.ts +++ b/index.d.ts @@ -16,45 +16,45 @@ export class Buffer extends Uint8Array { readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; readUInt8(offset: number, noAssert?: boolean): number; - readUInt16LE(offset: number, noAssert?: boolean): number; - readUInt16BE(offset: number, noAssert?: boolean): number; - readUInt32LE(offset: number, noAssert?: boolean): number; - readUInt32BE(offset: number, noAssert?: boolean): number; - readBigUInt64LE(offset: number): BigInt; - readBigUInt64BE(offset: number): BigInt; - readInt8(offset: number, noAssert?: boolean): number; - readInt16LE(offset: number, noAssert?: boolean): number; - readInt16BE(offset: number, noAssert?: boolean): number; - readInt32LE(offset: number, noAssert?: boolean): number; - readInt32BE(offset: number, noAssert?: boolean): number; - readBigInt64LE(offset: number): BigInt; - readBigInt64BE(offset: number): BigInt; - readFloatLE(offset: number, noAssert?: boolean): number; - readFloatBE(offset: number, noAssert?: boolean): number; - readDoubleLE(offset: number, noAssert?: boolean): number; - readDoubleBE(offset: number, noAssert?: boolean): number; + readUInt16LE(offset?: number, noAssert?: boolean): number; + readUInt16BE(offset?: number, noAssert?: boolean): number; + readUInt32LE(offset?: number, noAssert?: boolean): number; + readUInt32BE(offset?: number, noAssert?: boolean): number; + readBigUInt64LE(offset?: number): BigInt; + readBigUInt64BE(offset?: number): BigInt; + readInt8(offset?: number, noAssert?: boolean): number; + readInt16LE(offset?: number, noAssert?: boolean): number; + readInt16BE(offset?: number, noAssert?: boolean): number; + readInt32LE(offset?: number, noAssert?: boolean): number; + readInt32BE(offset?: number, noAssert?: boolean): number; + readBigInt64LE(offset?: number): BigInt; + readBigInt64BE(offset?: number): BigInt; + readFloatLE(offset?: number, noAssert?: boolean): number; + readFloatBE(offset?: number, noAssert?: boolean): number; + readDoubleLE(offset?: number, noAssert?: boolean): number; + readDoubleBE(offset?: number, noAssert?: boolean): number; reverse(): this; swap16(): Buffer; swap32(): Buffer; swap64(): Buffer; - writeUInt8(value: number, offset: number, noAssert?: boolean): number; - writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; - writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; - writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; - writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeBigUInt64LE(value: BigInt, offset: number): number; - writeBigUInt64BE(value: BigInt, offset: number): number; - writeInt8(value: number, offset: number, noAssert?: boolean): number; - writeInt16LE(value: number, offset: number, noAssert?: boolean): number; - writeInt16BE(value: number, offset: number, noAssert?: boolean): number; - writeInt32LE(value: number, offset: number, noAssert?: boolean): number; - writeInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeBigInt64LE(value: BigInt, offset: number): number; - writeBigInt64BE(value: BigInt, offset: number): number; - writeFloatLE(value: number, offset: number, noAssert?: boolean): number; - writeFloatBE(value: number, offset: number, noAssert?: boolean): number; - writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; - writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; + writeUInt8(value: number, offset?: number, noAssert?: boolean): number; + writeUInt16LE(value: number, offset?: number, noAssert?: boolean): number; + writeUInt16BE(value: number, offset?: number, noAssert?: boolean): number; + writeUInt32LE(value: number, offset?: number, noAssert?: boolean): number; + writeUInt32BE(value: number, offset?: number, noAssert?: boolean): number; + writeBigUInt64LE(value: BigInt, offset?: number): number; + writeBigUInt64BE(value: BigInt, offset?: number): number; + writeInt8(value: number, offset?: number, noAssert?: boolean): number; + writeInt16LE(value: number, offset?: number, noAssert?: boolean): number; + writeInt16BE(value: number, offset?: number, noAssert?: boolean): number; + writeInt32LE(value: number, offset?: number, noAssert?: boolean): number; + writeInt32BE(value: number, offset?: number, noAssert?: boolean): number; + writeBigInt64LE(value: BigInt, offset?: number): number; + writeBigInt64BE(value: BigInt, offset?: number): number; + writeFloatLE(value: number, offset?: number, noAssert?: boolean): number; + writeFloatBE(value: number, offset?: number, noAssert?: boolean): number; + writeDoubleLE(value: number, offset?: number, noAssert?: boolean): number; + writeDoubleBE(value: number, offset?: number, noAssert?: boolean): number; fill(value: any, offset?: number, end?: number): this; indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;