/// <reference path="leaf.ts" />
var Leaf;
(function (Leaf) {
    var Util = (function () {
        function Util() {
        }
        Util.capitalize = function (str) {
            if (!str)
                return str;
            return str.charAt(0).toUpperCase() + str.slice(1);
        };
        Util.uncapitalize = function (str) {
            if (!str)
                return str;
            return str.charAt(0).toLowerCase() + str.slice(1);
        };
        Util.camelToSlug = function (str) {
            if (!str)
                return str;
            return str.replace(/[a-z][A-Z]/g, function (match) {
                return match[0] + "-" + match[1].toLowerCase();
            }).toLowerCase();
        };
        Util.slugToCamel = function (str) {
            if (!str)
                return str;
            return str.replace(/-[a-z]/ig, function (match) {
                return match.slice(1).toUpperCase();
            });
        };
        Util.deepEqual = function (a, b) {
            if (a === b)
                return true;
            if (typeof a !== typeof b)
                return false;
            if (typeof a !== "object")
                return false;
            if (a instanceof Array) {
                if (a.length != b.length)
                    return false;
                for (var i = 0; i < a.length; i++) {
                    if (a[i] != b[i])
                        return false;
                    return true;
                }
            }
            else {
                var pas = Object.getOwnPropertyNames(a);
                var pbs = Object.getOwnPropertyNames(b);
                if (pas.length != pbs.length) {
                    return false;
                }
                for (var i = 0; i < pas.length; i++) {
                    var key = pas[i];
                    if (a[key] != b[key])
                        return false;
                }
                return true;
            }
        };
        return Util;
    }());
    Leaf.Util = Util;
})(Leaf || (Leaf = {}));
//# sourceMappingURL=util.js.map