UNPKG

@etherna/sdk-js

Version:

Etherna SDKs for operations on the network

52 lines 2.25 kB
import type { Bytes, BytesReference } from "./types"; export declare function checkReference(ref: BytesReference): void | never; export declare function checkBytes<Length extends number>(bytes: unknown, length: number): asserts bytes is Bytes<Length>; /** * Finds starting index `searchFor` in `element` Uin8Arrays * * If `searchFor` is not found in `element` it returns -1 * * @param element * @param searchFor * @returns starting index of `searchFor` in `element` */ export declare function findIndexOfArray(element: Uint8Array, searchFor: Uint8Array): number; /** Overwrites `a` bytearrays elements with elements of `b` starts from `i` */ export declare function overwriteBytes(a: Uint8Array, b: Uint8Array, i?: number): void; /** * Flattens the given array that consist of Uint8Arrays. */ export declare function flattenBytesArray(bytesArray: Uint8Array[]): Uint8Array; export declare function equalBytes(a: Uint8Array, b: Uint8Array): boolean; /** * runs a XOR operation on data, encrypting it if it * hasn't already been, and decrypting it if it has, using the key provided. */ export declare function encryptDecrypt(key: Uint8Array, data: Uint8Array, startIndex?: number, endIndex?: number): void; /** Tested only for Uint16 BigEndian */ export declare function fromBigEndian(bytes: Uint8Array): number; export declare function toBigEndianFromUint16(value: number): Bytes<2>; export declare function toBigEndianFromUint32(value: number): Bytes<4>; export declare function toBigEndianFromBigInt64(value: bigint): Bytes<8>; /** It returns the common bytes of the two given byte arrays until the first byte difference */ export declare function common(a: Uint8Array, b: Uint8Array): Uint8Array; export declare class IndexBytes { private bytes; constructor(); get getBytes(): Bytes<32>; set setBytes(bytes: Bytes<32>); /** * * @param byte is number max 255 */ setByte(byte: number): void; /** * checks the given byte is mapped in the Bytes<32> index * * @param byte is number max 255 */ checkBytePresent(byte: number): boolean; /** Iterates through on the indexed byte values */ forEach(hook: (byte: number) => void): void; } //# sourceMappingURL=utils.d.ts.map