21 lines
623 B
JavaScript
21 lines
623 B
JavaScript
"use strict";
|
|
var DecToBinConverter = (function () {
|
|
function DecToBinConverter() {
|
|
}
|
|
DecToBinConverter.prototype.getDisplayname = function () {
|
|
return "Convert decimal to binary";
|
|
};
|
|
DecToBinConverter.prototype.getId = function () {
|
|
return "dectobin";
|
|
};
|
|
DecToBinConverter.prototype.convert = function (input) {
|
|
var n = parseInt(input, 10);
|
|
if (isNaN(n)) {
|
|
throw new Error("The input seems not to be a valid integer.");
|
|
}
|
|
return n.toString(2);
|
|
};
|
|
return DecToBinConverter;
|
|
}());
|
|
exports.DecToBinConverter = DecToBinConverter;
|