"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DbUtil = void 0;
var typescript_ioc_1 = require("typescript-ioc");
var DbUtil = /** @class */ (function () {
    function DbUtil() {
    }
    DbUtil_1 = DbUtil;
    DbUtil.underline2Hump = function (s) {
        return s.replace(/_(\w)/g, function (all, letter) {
            return letter.toUpperCase();
        });
    };
    DbUtil.jsonToHump = function (obj) {
        if (obj instanceof Array) {
            obj.forEach(function (v, i) {
                DbUtil_1.jsonToHump(v);
            });
        }
        else if (obj instanceof Object) {
            Object.keys(obj).forEach(function (key) {
                var newKey = DbUtil_1.underline2Hump(key);
                if (newKey !== key) {
                    obj[newKey] = obj[key];
                    delete obj[key];
                }
                DbUtil_1.jsonToHump(obj[newKey]);
            });
        }
        return obj;
    };
    var DbUtil_1;
    DbUtil = DbUtil_1 = __decorate([
        typescript_ioc_1.Singleton
    ], DbUtil);
    return DbUtil;
}());
exports.DbUtil = DbUtil;
//# sourceMappingURL=DbUtil.js.map