Created
March 2, 2022 18:32
-
-
Save jmiramant/c17a73d75033f8e0ab2e1a9f5053e946 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var UID_GEN = { | |
stringBuilder: function (projNum, sowNum, uid) { | |
var id = (uid) ? uid.toUpperCase() : ""; | |
return id + "-" + projNum + "." + sowNum; | |
}, | |
generateUID: function (projNum, sowNum, exisitngId) { | |
var pNum, sNum; | |
projNum ? pNum = projNum : pNum = "01"; | |
sowNum ? sNum = sowNum : sNum = "01"; | |
if (exisitngId) return this.stringBuilder(pNum, sNum, exisitngId); | |
var uid = ''; | |
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; | |
var charactersLength = characters.length; | |
for ( var i = 0; i < 6; i++ ) { | |
uid += characters.charAt(Math.floor(Math.random() * charactersLength)); | |
} | |
//Write persitence layer to S3 and call verification | |
return this.stringBuilder(pNum, sNum, uid); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment