UNPKG

561 BJavaScriptView Raw
1import { u8aToString } from '../u8a/toString.js';
2import { hexToU8a } from './toU8a.js';
3/**
4 * @name hexToU8a
5 * @summary Creates a Uint8Array object from a hex string.
6 * @description
7 * Hex input values return the actual bytes value converted to a string. Anything that is not a hex string (including the `0x` prefix) throws an error.
8 * @example
9 * <BR>
10 *
11 * ```javascript
12 * import { hexToString } from '@polkadot/util';
13 *
14 * hexToU8a('0x68656c6c6f'); // hello
15 * ```
16 */
17export function hexToString(_value) {
18 return u8aToString(hexToU8a(_value));
19}