/**
 * Convert underscore joined string to camel string
 * @function lib/string.camelize
 * @param {string} str - String to convert.
 * @param {boolean} [capitalize] - Should capitalize or not.
 * @returns {string} - Converted string.
 * @author Taka Okunishi
 *
 */
module.exports = function (str, capitalize) {
    var camel = str && str.replace(/(.)(\_[a-z])/g, function ($0, $1, $2) {
        return $1 + $2.toUpperCase().replace('_', '');
    }) || str;
    if (capitalize) {
        return require('./capitalize')(camel);
    } else {
        return camel;
    }
};