import * as types from '../config/types' ; const HEX_REGEX = /^0x[a-fA-F0-9]+$/ ; export function isHex ( value , bitLength = - 1 , ignoreLength = false ) { const isValidHex = value === '0x' || ( isString ( value ) && HEX_REGEX . test ( value . toString ( ) ) ) ; if ( isValidHex && bitLength !== - 1 ) { return ( value as string ) . length === ( 2 + Math . ceil ( bitLength / 4 ) ) ; } return isValidHex && ( ignoreLength || ( ( value as string ) . length % 2 === 0 ) ) ; } export function isString ( value ) { return typeof value === 'string' || value instanceof String ; } export function isBoolean ( value ) { return typeof value === 'boolean' ; } export function isBigInt ( value ) { return typeof value === 'bigint' ; } export function isToBn ( value ? ) { return ! ! value && isFunction ( ( value as types . ToBn ) . toBn ) ; } export function isFunction ( value ) { return typeof value === 'function' ; }