adaptive base54 digits depending on char frequency (WIP)

This commit is contained in:
Mihai Bazon
2012-09-10 18:25:52 +03:00
parent a41e6cfabb
commit 6b9aeb5325
4 changed files with 138 additions and 71 deletions

View File

@@ -141,23 +141,6 @@ var MAP = (function(){
return MAP;
})();
// XXX: currently this is optimized for jQuery, though I have the
// feeling it works well in general for many scripts (well, better
// than alphabetical order). It would be nice if we could adapt it to
// the currently running script.
var BASE54_DIGITS = "etnrisouaflchpdvmgybwESxTNCkLAOM_DPHBjFIqRUzWXV$JKQGYZ0516372984";
//var BASE54_DIGITS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789";
function base54(num) {
var ret = "", base = 54;
do {
ret += BASE54_DIGITS.charAt(num % base);
num = Math.floor(num / base);
base = 64;
} while (num > 0);
return ret;
};
function push_uniq(array, el) {
if (array.indexOf(el) < 0)
array.push(el);