diff options
Diffstat (limited to 'lib/scope.js')
-rw-r--r-- | lib/scope.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/scope.js b/lib/scope.js index acc6fa25..eebedfd8 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -450,13 +450,13 @@ var base54 = (function() { var chars, frequency; function reset() { frequency = Object.create(null); - chars = string.split(""); - chars.map(function(ch){ frequency[ch] = 0 }); + chars = string.split("").map(function(ch){ return ch.charCodeAt(0) }); + chars.forEach(function(ch){ frequency[ch] = 0 }); } base54.consider = function(str){ for (var i = str.length; --i >= 0;) { - var ch = str.charAt(i); - ++frequency[ch]; + var code = str.charCodeAt(i); + if (code in frequency) ++frequency[code]; } }; base54.sort = function() { @@ -473,7 +473,7 @@ var base54 = (function() { function base54(num) { var ret = "", base = 54; do { - ret += chars[num % base]; + ret += String.fromCharCode(chars[num % base]); num = Math.floor(num / base); base = 64; } while (num > 0); |