xml2js
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -11,10 +11,23 @@ (function() { | ||
}; | ||
sax = require("sax"); | ||
events = require("events"); | ||
sax = require('sax'); | ||
events = require('events'); | ||
exports.Parser = (function() { | ||
__extends(Parser, events.EventEmitter); | ||
function Parser() { | ||
this.parseString = __bind(this.parseString, this); var stack; | ||
this.saxParser = sax.parser(true); | ||
this.EXPLICIT_CHARKEY = false; | ||
function Parser(opts) { | ||
this.parseString = __bind(this.parseString, this); var key, options, stack, value; | ||
options = { | ||
explicitCharkey: false, | ||
trim: true, | ||
normalize: true | ||
}; | ||
for (key in opts) { | ||
if (!__hasProp.call(opts, key)) continue; | ||
value = opts[key]; | ||
options[key] = value; | ||
} | ||
this.saxParser = sax.parser(true, { | ||
trim: false, | ||
normalize: false | ||
}); | ||
this.EXPLICIT_CHARKEY = options.explicitCharkey; | ||
this.resultObject = null; | ||
@@ -46,3 +59,8 @@ stack = []; | ||
} else { | ||
obj["#"] = obj["#"].replace(/\s{2,}/g, " ").trim(); | ||
if (options.trim) { | ||
obj["#"] = obj["#"].trim(); | ||
} | ||
if (options.normalize) { | ||
obj["#"] = obj["#"].replace(/\s{2,}/g, " ").trim(); | ||
} | ||
if (Object.keys(obj).length === 1 && "#" in obj && !this.EXPLICIT_CHARKEY) { | ||
@@ -49,0 +67,0 @@ obj = obj["#"]; |
@@ -6,3 +6,3 @@ { | ||
"homepage" : "https://github.com/Leonidas-from-XIV/node-xml2js", | ||
"version" : "0.1.8", | ||
"version" : "0.1.9", | ||
"author" : "Marek Kubica <marek@xivilization.net> (http://xivilization.net)", | ||
@@ -9,0 +9,0 @@ "contributors" : [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
12381
96