import { isNumber } from 'lodash';
function numberFromDb(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');
    }
}
function numberToDb(modelValue) {
    if (!isNumber(modelValue)) {
        throw new Error('this mapper only support values of type number');
    }
    return { N: modelValue.toString() };
}
export var NumberMapper = {
    fromDb: numberFromDb,
    toDb: numberToDb,
};
//# sourceMappingURL=number.mapper.js.map