Add tslint (#151)
This commit is contained in:
+11
-11
@@ -7,17 +7,17 @@ import isString from './string';
|
||||
const HEX_REGEX = /^0x[a-fA-F0-9]+$/;
|
||||
|
||||
/**
|
||||
@name isHex
|
||||
@signature isHex (value: any, bitLength: number = -1): boolean
|
||||
@summary Tests for a hex string.
|
||||
@description
|
||||
Checks to see if the input value is a `0x` prefixed hex string. Optionally (`bitLength` !== -1) checks to see if the bitLength is correct.
|
||||
@example
|
||||
import { isHex } from '@polkadot/util';
|
||||
|
||||
isHex('0x1234'); // => true
|
||||
isHex('0x1234', 8); // => false
|
||||
*/
|
||||
* @name isHex
|
||||
* @signature isHex (value: any, bitLength: number = -1): boolean
|
||||
* @summary Tests for a hex string.
|
||||
* @description
|
||||
* Checks to see if the input value is a `0x` prefixed hex string. Optionally (`bitLength` !== -1) checks to see if the bitLength is correct.
|
||||
* @example
|
||||
* import { isHex } from '@polkadot/util';
|
||||
*
|
||||
* isHex('0x1234'); // => true
|
||||
* isHex('0x1234', 8); // => false
|
||||
*/
|
||||
export default function isHex (_value: any, bitLength: number = -1, ignoreLength: boolean = false): _value is string {
|
||||
const value = (_value as string);
|
||||
const isValidHex = value === '0x' || (isString(value) && HEX_REGEX.test(value));
|
||||
|
||||
Reference in New Issue
Block a user