UNPKG

450 BJavaScriptView Raw
1import { isHex } from '../is/hex.js';
2/**
3 * @name hexHasPrefix
4 * @summary Tests for the existence of a `0x` prefix.
5 * @description
6 * Checks for a valid hex input value and if the start matched `0x`
7 * @example
8 * <BR>
9 *
10 * ```javascript
11 * import { hexHasPrefix } from '@polkadot/util';
12 *
13 * console.log('has prefix', hexHasPrefix('0x1234')); // => true
14 * ```
15 */
16export function hexHasPrefix(value) {
17 return !!value && isHex(value, -1);
18}
\No newline at end of file