UNPKG

@polkadot/util

Version:
27 lines (24 loc) 722 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.u8aToBuffer = u8aToBuffer; // Copyright 2017-2022 @polkadot/util authors & contributors // SPDX-License-Identifier: Apache-2.0 /** * @name u8aToBuffer * @summary Creates a Buffer object from a hex string. * @description * `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. * @example * <BR> * * ```javascript * import { u8aToBuffer } from '@polkadot/util'; * * console.log('Buffer', u8aToBuffer('0x123480001f')); * ``` */ function u8aToBuffer(value) { return Buffer.from(value || []); }