-
UUID가 필요 할 경우!물망초. 2020. 10. 21. 12:03
function generateUUID(fmt) { // Public Domain/MIT var d = new Date().getTime();//Timestamp var d2 = (performance && performance.now && (performance.now()*1000)) || 0;//Time in microseconds since page-load or 0 if unsupported return fmt.replace(/[xy]/g, function(c) { var r = Math.random() * 16;//random number between 0 and 16 if(d > 0){//Use timestamp until depleted r = (d + r)%16 | 0; d = Math.floor(d/16); } else {//Use microseconds since page-load if supported r = (d2 + r)%16 | 0; d2 = Math.floor(d2/16); } return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); } console.log(generateUUID('xxx-xxx-xxx'))
가볍게 쓴다면 위와 같이 사용. 출처 https://stackoverflow.com/a/8809472
nanoid
를 사용 https://www.npmjs.com/package/nanoid'물망초.' 카테고리의 다른 글
border-box vs. content-box 간단정리 (0) 2021.02.02 개발 중 필요한 것을 정리해두자. (0) 2021.01.19 window.addEventListener in enzyme. (0) 2020.10.20 왜 대소문자를 구분을 하지 못하니!!!(feat. Git) (1) 2020.08.12 그냥 잊지 말아야 할 것. (0) 2020.05.26