21 lines
640 B
JavaScript
21 lines
640 B
JavaScript
"use strict";
|
|
var HexToDecConverter = (function () {
|
|
function HexToDecConverter() {
|
|
}
|
|
HexToDecConverter.prototype.getDisplayname = function () {
|
|
return "Convert hexadecimal to decimal";
|
|
};
|
|
HexToDecConverter.prototype.getId = function () {
|
|
return "hextodec";
|
|
};
|
|
HexToDecConverter.prototype.convert = function (input) {
|
|
var n = parseInt(input, 16);
|
|
if (isNaN(n)) {
|
|
throw new Error("The input seems not to be a valid hexadecimal number.");
|
|
}
|
|
return n.toString(10);
|
|
};
|
|
return HexToDecConverter;
|
|
}());
|
|
exports.HexToDecConverter = HexToDecConverter;
|