-
-
Save pyengwoei/f34848cc5bf1911e19e6b7773a740c41 to your computer and use it in GitHub Desktop.
This file contains 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 alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""), | |
length = 64, | |
map = {}, | |
seed = 0, | |
i = 0, | |
prev; | |
function encode(num) { | |
var encoded = ""; | |
do { | |
encoded = alphabet[num % length] + encoded; | |
num = Math.floor(num / length) | |
} while (num > 0); | |
return encoded | |
} | |
function yeast() { | |
var now = encode(+new Date); | |
if (now !== prev) return seed = 0, prev = now; | |
return now + "." + encode(seed++) | |
} | |
aaa =yeast(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment