'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; Eif ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (EprotoProps) defineProperties(Constructor.prototype, protoProps); Iif (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (I!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var UnitNormaliser = function () {
function UnitNormaliser() {
_classCallCheck(this, UnitNormaliser);
this.namesVarients = {};
}
_createClass(UnitNormaliser, [{
key: 'addAlias',
value: function addAlias(unitName, alias) {
if (!unitName) throw new Error('absent name!');
if (!alias) throw new Error('absent alias!');
if (!this.namesVarients[unitName]) {
this.namesVarients[unitName] = unitName;
}
this.namesVarients[alias.toLowerCase()] = unitName;
}
}, {
key: 'normalise',
value: function normalise(alias) {
if (!alias) return;
return this.namesVarients[alias.toLowerCase()];
}
}]);
return UnitNormaliser;
}();
exports.default = UnitNormaliser; |