it's a little different. I am trying to do it myself in JAVA
JS is another language, unfortunately I don't know it at all (
I'm not familiar with either language but they look pretty similar to me. There is a "BigInteger" class in both that supports constructing from a string while setting the base of that input. You just construct it using
new BigInteger(input, 6) where input is the string (like "113125215") then convert that bigint instance to any other format like byte array then encode with Base58.
Base-6 encoding is pretty straight forward too:
https://en.wikipedia.org/wiki/Senary