hyphenate, 하이픈 변환
;(function(global){
global.hyphenate = function(_value) { // camelCase to hypen pattern, hyphenate(key)
var cache = {};
var replacer = function(_match) {
return '-' + _match[0].toLowerCase();
};
return cache[_value] || (cache[_value] = _value.replace(/([A-Z])/g, replacer));
}
global.round = function(n) { // 소숫점 4자리
return Math.round(n * 10000) / 10000;
}
global.random = function() { // 0~1000 난수
return Math.floor(Math.random() * 1000)
}
global.setUniqueId = function(_str) { // Unique Id 생성하기, 특수문자 제거 또는 난수 생성
return (typeof _str == 'string') ? _str.toLowerCase().replace(/[^a-z0-9)]/gi, '') : Math.floor(Math.random() * 1000)
};
})(this);