1.0.2 • Published 6 years ago

base70 v1.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

Description

Small functions to convert numbers to base 70 string (e.g. 1520893643779 = "6vv6Bu~") and back. Provides more efficient way to store big numbers (e.g. for IDs or to reduce JSON size):

bytesmax valuestring representation
169"~"
24899"~~"
3342999"~~~"
424009999""
51680699999"~"
6117648999999"~~"
78235429999999"~~~"
8576480099999999""
  • toBase70(number) - converts a number (int) to a string (radix = 70)
  • fromBase70(string) - parses a string (result of toBase70 function) and returns an number (int).

*currently works only with unsigned integers

Encoding

toBase70() produces only URL friendly characters. Actually all of them except - (which can be used as separator between encoded values)

SymbolValue
!0
'1
(2
)3
*4
.5
06
17
28
39
410
511
612
713
814
915
A16
B17
C18
D19
E20
F21
G22
H23
I24
J25
K26
L27
M28
N29
O30
P31
Q32
R33
S34
T35
U36
V37
W38
X39
Y40
Z41
_42
a43
b44
c45
d46
e47
f48
g49
h50
i51
j52
k53
l54
m55
n56
o57
p58
q59
r60
s61
t62
u63
v64
w65
x66
y67
z68
~69
1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago