Skip to content

Instantly share code, notes, and snippets.

View mattlubner's full-sized avatar

Matt Lubner mattlubner

View GitHub Profile
@mattlubner
mattlubner / base62.js
Last active October 14, 2020 20:46 — forked from kevinyan815/base62.js
BigInt-compatible Base62 Conversion Functions
// requires ES2020 for BigInt support
const digits = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
function toBase62(number) {
if (number === 0n) {
return '0';
}
let result = '';
let remaining = number;