From 370d3e09172c35e4f0a7c6a47edd53625b6e2012 Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Sat, 13 Oct 2012 12:24:27 +0300 Subject: [PATCH] fix regression from fb5c01c073d06034815d5f3b782fd11cbdf6d6f5 is_digit takes a char code now, not a string --- lib/scope.js | 10 +++++----- 1 file 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); -- 2.34.1