port JavaScript Succinct Trie decoding function to AngularJS service