locutus
Version:
Locutus other languages' standard libraries to JavaScript for fun and educational purposes
15 lines (14 loc) • 489 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.hexdec = hexdec;
function hexdec(hexString) {
// discuss at: https://locutus.io/php/hexdec/
// parity verified: PHP 8.3
// original by: Philippe Baumann
// example 1: hexdec('that')
// returns 1: 10
// example 2: hexdec('a0')
// returns 2: 160
hexString = (hexString + '').replace(/[^a-f0-9]/gi, '');
return parseInt(hexString, 16);
}