@waku/utils
Version:
Different utilities for Waku
24 lines (23 loc) • 776 B
TypeScript
/**
* Convert input to a byte array.
*
* Handles both `0x` prefixed and non-prefixed strings.
*/
export declare function hexToBytes(hex: string | Uint8Array): Uint8Array;
export declare function numberToBytes(value: number | bigint): Uint8Array;
/**
* Convert byte array to hex string (no `0x` prefix).
*/
export declare const bytesToHex: (bytes: Uint8Array) => string;
/**
* Decode byte array to utf-8 string.
*/
export declare const bytesToUtf8: (b: Uint8Array) => string;
/**
* Encode utf-8 string to byte array.
*/
export declare const utf8ToBytes: (s: string) => Uint8Array;
/**
* Concatenate using Uint8Arrays as `Buffer` has a different behavior with `DataView`
*/
export declare function concat(byteArrays: Uint8Array[], totalLength?: number): Uint8Array;