ox
Version:
Ethereum Standard Library
54 lines • 1.85 kB
TypeScript
import * as Errors from '../../Errors.js';
/**
* Decodes a big-endian unsigned `Uint8Array` into a `bigint`. When `signed` is
* true, applies twos-complement on the high bit.
*
* @internal
*/
export declare function bytesToBigInt(value: Uint8Array, signed?: boolean): bigint;
/**
* Decodes a big-endian unsigned `Uint8Array` into a number, throwing if the
* value cannot be represented as a safe integer.
*
* @internal
*/
export declare function bytesToSafeNumber(value: Uint8Array, signed?: boolean): number;
/**
* Encodes a number/bigint into a big-endian `Uint8Array` of the given byte
* size (or minimal size when `size` is omitted).
*
* @internal
*/
export declare function bigIntToBytes(value: number | bigint, options?: bigIntToBytes.Options): Uint8Array;
/** @internal */
export declare function bigIntByteLength(n: bigint): number;
/** Thrown when a value cannot be represented as a safe integer. */
export declare class IntegerOutOfRangeError extends Errors.BaseError {
readonly name = "Hex.IntegerOutOfRangeError";
constructor({ max, min, signed, size, value, }: {
max?: string | undefined;
min: string;
signed?: boolean | undefined;
size?: number | undefined;
value: string;
});
}
/** @internal */
export declare namespace bigIntToBytes {
type Options = {
/** Whether the value is signed. */
signed?: boolean | undefined;
/** Size (in bytes) of the output. */
size?: number | undefined;
};
type ErrorType = IntegerOutOfRangeError | Errors.GlobalErrorType;
}
/** @internal */
export declare namespace bytesToBigInt {
type ErrorType = Errors.GlobalErrorType;
}
/** @internal */
export declare namespace bytesToSafeNumber {
type ErrorType = IntegerOutOfRangeError | Errors.GlobalErrorType;
}
//# sourceMappingURL=int.d.ts.map