Skip to content

Instantly share code, notes, and snippets.

@zhoufenfens
Created June 20, 2019 17:42
Show Gist options
  • Save zhoufenfens/5f7c479f28a6dca9c628a51014878079 to your computer and use it in GitHub Desktop.
Save zhoufenfens/5f7c479f28a6dca9c628a51014878079 to your computer and use it in GitHub Desktop.
function string10to62(number) {
var chars = '0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ'.split(''),
radix = chars.length,
qutient = +number,
arr = [];
do {
mod = qutient % radix;
qutient = (qutient - mod) / radix;
arr.unshift(chars[mod]);
} while (qutient);
return arr.join('');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment