Skip to content

Commit 9bf7d5b

Browse files
committed
chore: update method signatures.
1 parent b576456 commit 9bf7d5b

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/dynamicBuffer.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,12 @@ export class DynamicBuffer {
319319
* buffer when sorted; `-1` if `target` should come after this buffer when sorted.
320320
*/
321321
compare(
322-
target: DynamicBuffer | Buffer | Uint8Array,
322+
target: this | Buffer | Uint8Array,
323323
targetStart: number = 0,
324324
targetEnd: number = target.length,
325325
sourceStart: number = 0,
326326
sourceEnd: number = this.length,
327-
): number {
327+
): 0 | 1 | -1 {
328328
const otherBuf = target instanceof DynamicBuffer ? (target.buffer || ([] as number[])) : target;
329329
const thisBuf = this.buffer || ([] as number[]);
330330

@@ -394,7 +394,7 @@ export class DynamicBuffer {
394394
* is treated as length+end.
395395
* @param end If not specified, length of the this object is used as its default value.
396396
*/
397-
copyWithin(target: number, start: number, end: number = this.length): DynamicBuffer {
397+
copyWithin(target: number, start: number, end: number = this.length): this {
398398
if (!this.buffer || this.length === 0) {
399399
return this;
400400
}
@@ -463,7 +463,7 @@ export class DynamicBuffer {
463463
* to compare this buffer.
464464
* @returns `true` if two buffers have exactly the same bytes, `false` otherwise.
465465
*/
466-
equals(otherBuffer: DynamicBuffer | Buffer | Uint8Array): boolean {
466+
equals(otherBuffer: this | Buffer | Uint8Array): boolean {
467467
return this.compare(otherBuffer, 0, otherBuffer.length, 0, this.length) === 0;
468468
}
469469

@@ -509,7 +509,7 @@ export class DynamicBuffer {
509509
offset: number = 0,
510510
end: number = this.length,
511511
encoding: BufferEncoding = 'utf8',
512-
): DynamicBuffer {
512+
): this {
513513
if (!this.buffer || this.length === 0 || end - offset <= 0) {
514514
return this;
515515
}
@@ -824,7 +824,7 @@ export class DynamicBuffer {
824824
* `buf.length - 8`, default `0`.
825825
* @returns Integer read from the buffer at the specified offset.
826826
*/
827-
readBigInt64BE(offset: number = 0): BigInt {
827+
readBigInt64BE(offset: number = 0): bigint {
828828
if (!this.buffer || this.length < 8) {
829829
throw new RangeError('Attempt to access memory outside buffer bounds');
830830
}
@@ -841,7 +841,7 @@ export class DynamicBuffer {
841841
* `buf.length - 8`, default `0`.
842842
* @returns Integer read from the buffer at the specified offset.
843843
*/
844-
readBigInt64LE(offset: number = 0): BigInt {
844+
readBigInt64LE(offset: number = 0): bigint {
845845
if (!this.buffer || this.length < 8) {
846846
throw new RangeError('Attempt to access memory outside buffer bounds');
847847
}
@@ -858,7 +858,7 @@ export class DynamicBuffer {
858858
* `buf.length - 8`, default `0`.
859859
* @returns Integer read from the buffer at the specified offset.
860860
*/
861-
readBigUInt64BE(offset: number = 0): BigInt {
861+
readBigUInt64BE(offset: number = 0): bigint {
862862
if (!this.buffer || this.length < 8) {
863863
throw new RangeError('Attempt to access memory outside buffer bounds');
864864
}
@@ -875,7 +875,7 @@ export class DynamicBuffer {
875875
* `buf.length - 8`, default `0`.
876876
* @returns Integer read from the buffer at the specified offset.
877877
*/
878-
readBigUInt64LE(offset: number = 0): BigInt {
878+
readBigUInt64LE(offset: number = 0): bigint {
879879
if (!this.buffer || this.length < 8) {
880880
throw new RangeError('Attempt to access memory outside buffer bounds');
881881
}
@@ -1343,7 +1343,7 @@ export class DynamicBuffer {
13431343
*
13441344
* @returns The reference to this buffer.
13451345
*/
1346-
reverse(): DynamicBuffer {
1346+
reverse(): this {
13471347
if (!this.buffer || this.length === 0) {
13481348
return this;
13491349
}
@@ -1453,7 +1453,7 @@ export class DynamicBuffer {
14531453
*
14541454
* @returns A reference to this buffer.
14551455
*/
1456-
swap16(): DynamicBuffer {
1456+
swap16(): this {
14571457
if (this.length % 2 !== 0) {
14581458
throw new RangeError('Buffer size must be a multiple of 2');
14591459
}
@@ -1485,7 +1485,7 @@ export class DynamicBuffer {
14851485
*
14861486
* @returns A reference to this buffer.
14871487
*/
1488-
swap32(): DynamicBuffer {
1488+
swap32(): this {
14891489
if (this.length % 4 !== 0) {
14901490
throw new RangeError('Buffer size must be a multiple of 4');
14911491
}
@@ -1518,7 +1518,7 @@ export class DynamicBuffer {
15181518
*
15191519
* @returns A reference to this buffer.
15201520
*/
1521-
swap64(): DynamicBuffer {
1521+
swap64(): this {
15221522
if (this.length % 8 !== 0) {
15231523
throw new RangeError('Buffer size must be a multiple of 8');
15241524
}
@@ -1580,7 +1580,7 @@ export class DynamicBuffer {
15801580
* // {"type":"Buffer","data":[72,101,108,108,111]}
15811581
* ```
15821582
*/
1583-
toJSON(): { type: string, data: number[] } {
1583+
toJSON(): { type: 'Buffer', data: number[] } {
15841584
const data: number[] = [];
15851585

15861586
if (this.buffer && this.used > 0) {

0 commit comments

Comments
 (0)