UNPKG

584 BTypeScriptView Raw
1import type { BufferObject } from '../types.js';
2/**
3 * @name u8aToBuffer
4 * @summary Creates a Buffer object from a hex string.
5 * @description
6 * `null` inputs returns an empty `Buffer` result. `UInt8Array` input values return the actual bytes value converted to a `Buffer`. Anything that is not a `UInt8Array` throws an error.
7 * @example
8 * <BR>
9 *
10 * ```javascript
11 * import { u8aToBuffer } from '@polkadot/util';
12 *
13 * console.log('Buffer', u8aToBuffer(new Uint8Array([1, 2, 3])));
14 * ```
15 */
16export declare function u8aToBuffer<T = BufferObject>(value?: Uint8Array | null): T;