adaptive base54 digits depending on char frequency (WIP)
This commit is contained in:
17
lib/utils.js
17
lib/utils.js
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user