diff --git a/lib/parse.js b/lib/parse.js index 128d07c..ec9a578 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -1,24 +1,7 @@ "use strict"; var hex = function (c){ - switch (c){ - case "0": return 0; - case "1": return 1; - case "2": return 2; - case "3": return 3; - case "4": return 4; - case "5": return 5; - case "6": return 6; - case "7": return 7; - case "8": return 8; - case "9": return 9; - case "a": case "A": return 10; - case "b": case "B": return 11; - case "c": case "C": return 12; - case "d": case "D": return 13; - case "e": case "E": return 14; - case "f": case "F": return 15; - } + return parseInt(c, 16); }; module.exports = function (data, options, handlers, control){ @@ -40,7 +23,7 @@ module.exports = function (data, options, handlers, control){ var keySpace; var sep; var ignoreLine; - + var line = function (){ if (key || value || sep){ handlers.line (key, value); @@ -49,7 +32,7 @@ module.exports = function (data, options, handlers, control){ sep = false; } }; - + var escapeString = function (key, c, code){ if (escapingUnicode && unicodeRemaining){ unicode = (unicode << 4) + hex (c); @@ -58,7 +41,7 @@ module.exports = function (data, options, handlers, control){ escapingUnicode = false; return key + String.fromCharCode (unicode); } - + //code 117: u if (code === 117){ unicode = 0; @@ -66,9 +49,9 @@ module.exports = function (data, options, handlers, control){ unicodeRemaining = 4; return key; } - + escape = false; - + //code 116: t //code 114: r //code 110: n @@ -77,13 +60,13 @@ module.exports = function (data, options, handlers, control){ else if (code === 114) return key + "\r"; else if (code === 110) return key + "\n"; else if (code === 102) return key + "\f"; - + return key + c; }; - + var isComment; var isSeparator; - + if (options._strict){ isComment = function (c, code, options){ return options._comments[c]; @@ -105,7 +88,7 @@ module.exports = function (data, options, handlers, control){ return code === 61 || code === 58 || options._separators[c]; }; } - + for (var i=~~control.resume; i