UNPKG

@tetcoin/util

Version:
32 lines (27 loc) 902 B
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = hexHasPrefix; var _hex = _interopRequireDefault(require("../is/hex")); // Copyright 2017-2019 @polkadot/util authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. /** * @name hexHasPrefix * @summary Tests for the existence of a `0x` prefix. * @description * Checks for a valid hex input value and if the start matched `0x` * @example * <BR> * * ```javascript * import { hexHasPrefix } from '@tetcoin/util'; * * console.log('has prefix', hexHasPrefix('0x1234')); // => true * ``` */ function hexHasPrefix(value) { return !!(value && (0, _hex.default)(value, -1, true) && value.substr(0, 2) === '0x'); }