Function: hexToUnsigned()
hexToUnsigned(
hex):number
Read a hexadecimal string as an unsigned integer (big-endian: the first digit is the most significant).
Parameters
hex
string
The hexadecimal digits, in either case, with or without a 0x/0X prefix ('FF', '0x00ff').
Returns
number
The unsigned value, from 0 to Number.MAX_SAFE_INTEGER.
Throws
When hex has no digit ('', '0x') or a character which is not a hexadecimal digit (a sign, a space, '0x1g').
Throws
When the value is above Number.MAX_SAFE_INTEGER ('20000000000000' and more): it would lose its precision as a number.
Example
typescript
import {hexToUnsigned} from 'lakutata/utils'
console.log(hexToUnsigned('FF'), hexToUnsigned('0x0100'), hexToUnsigned('FFFFFFFF'))
//255 256 4294967295