radixer
This package lets you convert a big number like 123456789
to a short string like 7MyqL
, and back again.
You can do the same thing natively with .toString()
and parseInt()
, but only up to a radix of 36 (using the 26 letters a-z
and the 10 digits 0-9
). This package uses a larger character set (including A-Z
, -
and _
, totalling 64), so you get shorter strings that are still URL-friendly.
Basic usage
var radixer = ; radixer; // l65Eradixer; // 12345678
The default radixer uses the following 64 characters:
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_
Alternative API
Use the module as a constructor to get a custom radixer, using whatever character set you want.
The more characters you provide, the shorter your strings will be.
var Radixer = ; var radixer = 'àêīöû!@%$^&*;[]'; // 15 chars radixer; // ö^[àradixer; // 12345
Licence
MIT