import { isNumber } from 'lodash';
var NumberMapper = /** @class */ (function () {
    function NumberMapper() {
    }
    NumberMapper.prototype.fromDb = function (attributeValue) {
        if (attributeValue.N) {
            var numberValue = Number.parseFloat(attributeValue.N);
            if (isNaN(numberValue)) {
                throw new Error("value " + attributeValue.N + " resolves to NaN when parsing using Number.parseFloat");
            }
            return numberValue;
        }
        else {
            throw new Error('there is no N(umber) value defiend on given attribute value');
        }
    };
    NumberMapper.prototype.toDb = function (modelValue) {
        if (!isNumber(modelValue)) {
            throw new Error('this mapper only support values of type number');
        }
        return { N: modelValue.toString() };
    };
    return NumberMapper;
}());
export { NumberMapper };
//# sourceMappingURL=number.mapper.js.map