Files
common/docs/util/modules/_hex_tou8a_.md
T
2018-11-14 12:31:44 +00:00

1.0 KiB

Functions

hexToU8a

▸ hexToU8a(_value?: * string | null*, bitLength?: number): Uint8Array

Defined in hex/toU8a.ts:25

name: hexToU8a

signature: hexToU8a (value?: string, bitLength: number = -1): Uint8Array

summary: Creates a Buffer object from a hex string.

description: null inputs returns an empty Uint8Array result. Hex input values return the actual bytes value converted to a Uint8Array. Anything that is not a hex string (including the 0x prefix) throws an error.

example:

import { hexToU8a } from '@polkadot/util';

hexToU8a('0x80001f'); // Uint8Array([0x80, 0x00, 0x1f])
hexToU8a('0x80001f', 32); // Uint8Array([0x00, 0x80, 0x00, 0x1f])

Parameters:

Param Type Default value
Optional _value string | null -
Default value bitLength number -1

Returns: Uint8Array