参数命名风格转换

camelize方法,转换为驼峰命名风格:

function camelize (target) {
        if (target.indexOf('_') < 0 && target.indexOf('_') < 0) return target; 
        return target.replace(/[-_][^-_]/g , function(match){
            return match[1].toUpperCase();
        })
    }

underscored方法,转换为下划线风格:

function underscored(target){
        return target.replace(/([a-zd])([A-Z])/g , '$1_$2').replace(/-/g , '_').toLowerCase();
    }

  

原文地址:https://www.cnblogs.com/bigman-bugman/p/9101394.html