1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.hexHasPrefix = hexHasPrefix;
|
7 |
|
8 | var _hex = require("../is/hex");
|
9 |
|
10 | // Copyright 2017-2022 @polkadot/util authors & contributors
|
11 | // SPDX-License-Identifier: Apache-2.0
|
12 |
|
13 | /**
|
14 | * @name hexHasPrefix
|
15 | * @summary Tests for the existence of a `0x` prefix.
|
16 | * @description
|
17 | * Checks for a valid hex input value and if the start matched `0x`
|
18 | * @example
|
19 | * <BR>
|
20 | *
|
21 | * ```javascript
|
22 | * import { hexHasPrefix } from '@polkadot/util';
|
23 | *
|
24 | * console.log('has prefix', hexHasPrefix('0x1234')); // => true
|
25 | * ```
|
26 | */
|
27 | function hexHasPrefix(value) {
|
28 | return !!value && (0, _hex.isHex)(value, -1);
|
29 | } |
\ | No newline at end of file |