UNPKG

605 BTypeScriptView Raw
1import type { U8aLike } from '../types.js';
2/**
3 * @name u8aToU8a
4 * @summary Creates a Uint8Array value from a Uint8Array, Buffer, string or hex input.
5 * @description
6 * `null` or `undefined` inputs returns a `[]` result, Uint8Array values returns the value, hex strings returns a Uint8Array representation.
7 * @example
8 * <BR>
9 *
10 * ```javascript
11 * import { u8aToU8a } from '@polkadot/util';
12 *
13 * u8aToU8a(new Uint8Array([0x12, 0x34]); // => Uint8Array([0x12, 0x34])
14 * u8aToU8a(0x1234); // => Uint8Array([0x12, 0x34])
15 * ```
16 */
17export declare function u8aToU8a(value?: U8aLike | null): Uint8Array;