Skip to content

Instantly share code, notes, and snippets.

@meftunca
Created April 21, 2019 16:45
Show Gist options
  • Save meftunca/50e9ec7c3caa7d7608521cdcbf681c2d to your computer and use it in GitHub Desktop.
Save meftunca/50e9ec7c3caa7d7608521cdcbf681c2d to your computer and use it in GitHub Desktop.
JS uniqid generator
export default (key = "key") => {
let ts = String(new Date().getTime()),
i = 0,
out = "";
for (i = 0; i < ts.length; i += 2) {
out += Number(ts.substr(i, 2)).toString(36);
}
return key + out;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment