[6a3a178] | 1 | /// <reference types="node" />
|
---|
| 2 | import { SmartBuffer } from './smartbuffer';
|
---|
| 3 | import { Buffer } from 'buffer';
|
---|
| 4 | /**
|
---|
| 5 | * Error strings
|
---|
| 6 | */
|
---|
| 7 | declare const ERRORS: {
|
---|
| 8 | INVALID_ENCODING: string;
|
---|
| 9 | INVALID_SMARTBUFFER_SIZE: string;
|
---|
| 10 | INVALID_SMARTBUFFER_BUFFER: string;
|
---|
| 11 | INVALID_SMARTBUFFER_OBJECT: string;
|
---|
| 12 | INVALID_OFFSET: string;
|
---|
| 13 | INVALID_OFFSET_NON_NUMBER: string;
|
---|
| 14 | INVALID_LENGTH: string;
|
---|
| 15 | INVALID_LENGTH_NON_NUMBER: string;
|
---|
| 16 | INVALID_TARGET_OFFSET: string;
|
---|
| 17 | INVALID_TARGET_LENGTH: string;
|
---|
| 18 | INVALID_READ_BEYOND_BOUNDS: string;
|
---|
| 19 | INVALID_WRITE_BEYOND_BOUNDS: string;
|
---|
| 20 | };
|
---|
| 21 | /**
|
---|
| 22 | * Checks if a given encoding is a valid Buffer encoding. (Throws an exception if check fails)
|
---|
| 23 | *
|
---|
| 24 | * @param { String } encoding The encoding string to check.
|
---|
| 25 | */
|
---|
| 26 | declare function checkEncoding(encoding: BufferEncoding): void;
|
---|
| 27 | /**
|
---|
| 28 | * Checks if a given number is a finite integer. (Throws an exception if check fails)
|
---|
| 29 | *
|
---|
| 30 | * @param { Number } value The number value to check.
|
---|
| 31 | */
|
---|
| 32 | declare function isFiniteInteger(value: number): boolean;
|
---|
| 33 | /**
|
---|
| 34 | * Checks if a length value is valid. (Throws an exception if check fails)
|
---|
| 35 | *
|
---|
| 36 | * @param { Number } length The value to check.
|
---|
| 37 | */
|
---|
| 38 | declare function checkLengthValue(length: any): void;
|
---|
| 39 | /**
|
---|
| 40 | * Checks if a offset value is valid. (Throws an exception if check fails)
|
---|
| 41 | *
|
---|
| 42 | * @param { Number } offset The value to check.
|
---|
| 43 | */
|
---|
| 44 | declare function checkOffsetValue(offset: any): void;
|
---|
| 45 | /**
|
---|
| 46 | * Checks if a target offset value is out of bounds. (Throws an exception if check fails)
|
---|
| 47 | *
|
---|
| 48 | * @param { Number } offset The offset value to check.
|
---|
| 49 | * @param { SmartBuffer } buff The SmartBuffer instance to check against.
|
---|
| 50 | */
|
---|
| 51 | declare function checkTargetOffset(offset: number, buff: SmartBuffer): void;
|
---|
| 52 | interface Buffer {
|
---|
| 53 | readBigInt64BE(offset?: number): bigint;
|
---|
| 54 | readBigInt64LE(offset?: number): bigint;
|
---|
| 55 | readBigUInt64BE(offset?: number): bigint;
|
---|
| 56 | readBigUInt64LE(offset?: number): bigint;
|
---|
| 57 | writeBigInt64BE(value: bigint, offset?: number): number;
|
---|
| 58 | writeBigInt64LE(value: bigint, offset?: number): number;
|
---|
| 59 | writeBigUInt64BE(value: bigint, offset?: number): number;
|
---|
| 60 | writeBigUInt64LE(value: bigint, offset?: number): number;
|
---|
| 61 | }
|
---|
| 62 | /**
|
---|
| 63 | * Throws if Node.js version is too low to support bigint
|
---|
| 64 | */
|
---|
| 65 | declare function bigIntAndBufferInt64Check(bufferMethod: keyof Buffer): void;
|
---|
| 66 | export { ERRORS, isFiniteInteger, checkEncoding, checkOffsetValue, checkLengthValue, checkTargetOffset, bigIntAndBufferInt64Check };
|
---|