Document default endianess
This commit is contained in:
parent
0f3ef46aa1
commit
5d73e64b17
@ -25,6 +25,12 @@ export class Uint32 implements Integer, WithByteConverters {
|
||||
return Uint32.fromBytes(bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Uint32 from a fixed length byte array.
|
||||
*
|
||||
* @param bytes a list of exactly 4 bytes
|
||||
* @param endianess defaults to big endian
|
||||
*/
|
||||
public static fromBytes(bytes: ArrayLike<number>, endianess: "be" | "le" = "be"): Uint32 {
|
||||
if (bytes.length !== 4) {
|
||||
throw new Error("Invalid input length. Expected 4 bytes.");
|
||||
@ -168,6 +174,12 @@ export class Uint64 implements Integer, WithByteConverters {
|
||||
return Uint64.fromBytes(bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Uint64 from a fixed length byte array.
|
||||
*
|
||||
* @param bytes a list of exactly 8 bytes
|
||||
* @param endianess defaults to big endian
|
||||
*/
|
||||
public static fromBytes(bytes: ArrayLike<number>, endianess: "be" | "le" = "be"): Uint64 {
|
||||
if (bytes.length !== 8) {
|
||||
throw new Error("Invalid input length. Expected 8 bytes.");
|
||||
|
||||
12
packages/math/types/integers.d.ts
vendored
12
packages/math/types/integers.d.ts
vendored
@ -10,6 +10,12 @@ interface WithByteConverters {
|
||||
export declare class Uint32 implements Integer, WithByteConverters {
|
||||
/** @deprecated use Uint32.fromBytes */
|
||||
static fromBigEndianBytes(bytes: ArrayLike<number>): Uint32;
|
||||
/**
|
||||
* Creates a Uint32 from a fixed length byte array.
|
||||
*
|
||||
* @param bytes a list of exactly 4 bytes
|
||||
* @param endianess defaults to big endian
|
||||
*/
|
||||
static fromBytes(bytes: ArrayLike<number>, endianess?: "be" | "le"): Uint32;
|
||||
static fromString(str: string): Uint32;
|
||||
protected readonly data: number;
|
||||
@ -36,6 +42,12 @@ export declare class Uint53 implements Integer {
|
||||
export declare class Uint64 implements Integer, WithByteConverters {
|
||||
/** @deprecated use Uint64.fromBytes */
|
||||
static fromBytesBigEndian(bytes: ArrayLike<number>): Uint64;
|
||||
/**
|
||||
* Creates a Uint64 from a fixed length byte array.
|
||||
*
|
||||
* @param bytes a list of exactly 8 bytes
|
||||
* @param endianess defaults to big endian
|
||||
*/
|
||||
static fromBytes(bytes: ArrayLike<number>, endianess?: "be" | "le"): Uint64;
|
||||
static fromString(str: string): Uint64;
|
||||
static fromNumber(input: number): Uint64;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user