
var Utils = (function() {
    var stringDist = function(b, a) {
        if (!a || b === undefined || b === null)
            return 0;
        if (!b.length)
            return 1;
        // Try to find b in a
        var pos = a.indexOf(b);
        if (pos === -1) {
            return 0;
        }
        return (b.length / a.length);
    },
    getClosestDistanceString = function(strToMatch, str, getString) {
        if (Array.isArray(str)) {
            var maxScore = 0;
            for (var i =0, nbItems = str.length; i < nbItems; i++) {
                var currentScore = getClosestDistanceString(strToMatch, str[i], getString);
                if (currentScore === 1)
                    return 1;
                maxScore = Math.max(currentScore, maxScore);
            }
            return maxScore;
        }
        else
            return stringDist(strToMatch, getString ? getString(str) : str);
    };

    return {
        getClosestDistanceString: getClosestDistanceString
    };
})();

/** @suppress {undefinedVars,checkTypes} */
(function() {
    if (typeof module !== "undefined") {
        module.exports.Utils = Utils;
    }
})();


