UNPKG

@microbit/microbit-universal-hex

Version:
51 lines 1.77 kB
/** * General utilities. * @packageDocumentation * * (c) 2020 Micro:bit Educational Foundation and the project contributors. * SPDX-License-Identifier: MIT */ /** * Convert from a string with a hexadecimal number into a Uint8Array byte array. * * @export * @param hexStr A string with a hexadecimal number. * @returns A Uint8Array with the number broken down in bytes. */ export declare function hexStrToBytes(hexStr: string): Uint8Array; /** * Convert a positive integer byte (0 to 0xFF) into a hex string. * * @export * @param byte Number to convert into a hex string. * @param prefix Boolean to add '0x' to the beginning of the string. * @returns String with hex value, padded to always at least 2 characters. */ export declare function byteToHexStr(byte: number, prefix?: boolean): string; /** * A version of byteToHexStr() without input sanitation, only to be called when * the caller can guarantee the input is a positive integer between 0 and 0xFF. * * @export * @param byte Number to convert into a hex string. * @returns String with hex value, padded to always have 2 characters. */ export declare function byteToHexStrFast(byte: number): string; /** * Converts a Uint8Array into a string with base 16 hex digits. It doesn't * include an opening '0x'. * * @export * @param byteArray Uint8Array to convert to hex. * @returns String with base 16 hex digits. */ export declare function byteArrayToHexStr(byteArray: Uint8Array): string; /** * Concatenates an array of Uint8Arrays into a single Uint8Array. * * @export * @param arraysToConcat Arrays to concatenate. * @returns Single concatenated Uint8Array. */ export declare function concatUint8Arrays(arraysToConcat: Uint8Array[]): Uint8Array; //# sourceMappingURL=utils.d.ts.map