condensed javascript encoder and decoder