Comparing version 0.4.8 to 0.4.9
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var xml2js; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var prefixMatch; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
// Generated by CoffeeScript 1.9.2 | ||
(function() { | ||
@@ -83,2 +83,3 @@ var bom, builder, escapeCDATA, events, isEmpty, processName, processors, requiresCDATA, sax, wrapCDATA, | ||
explicitChildren: false, | ||
preserveChildrenOrder: false, | ||
childkey: '$$', | ||
@@ -335,8 +336,12 @@ charsAsChildren: false, | ||
return function() { | ||
var cdata, emptyStr, err, node, nodeName, obj, old, s, xpath; | ||
var cdata, emptyStr, err, key, node, nodeName, obj, objClone, old, s, xpath; | ||
obj = stack.pop(); | ||
nodeName = obj["#name"]; | ||
delete obj["#name"]; | ||
cdata = obj.cdata; | ||
delete obj.cdata; | ||
if (!_this.options.explicitChildren || !_this.options.preserveChildrenOrder) { | ||
delete obj["#name"]; | ||
} | ||
if (obj.cdata === true) { | ||
cdata = obj.cdata; | ||
delete obj.cdata; | ||
} | ||
s = stack[stack.length - 1]; | ||
@@ -379,15 +384,29 @@ if (obj[charkey].match(/^\s*$/) && !cdata) { | ||
if (_this.options.explicitChildren && !_this.options.mergeAttrs && typeof obj === 'object') { | ||
node = {}; | ||
if (_this.options.attrkey in obj) { | ||
node[_this.options.attrkey] = obj[_this.options.attrkey]; | ||
delete obj[_this.options.attrkey]; | ||
if (!_this.options.preserveChildrenOrder) { | ||
node = {}; | ||
if (_this.options.attrkey in obj) { | ||
node[_this.options.attrkey] = obj[_this.options.attrkey]; | ||
delete obj[_this.options.attrkey]; | ||
} | ||
if (!_this.options.charsAsChildren && _this.options.charkey in obj) { | ||
node[_this.options.charkey] = obj[_this.options.charkey]; | ||
delete obj[_this.options.charkey]; | ||
} | ||
if (Object.getOwnPropertyNames(obj).length > 0) { | ||
node[_this.options.childkey] = obj; | ||
} | ||
obj = node; | ||
} else if (s) { | ||
s[_this.options.childkey] = s[_this.options.childkey] || []; | ||
objClone = {}; | ||
for (key in obj) { | ||
if (!hasProp.call(obj, key)) continue; | ||
objClone[key] = obj[key]; | ||
} | ||
s[_this.options.childkey].push(objClone); | ||
delete obj["#name"]; | ||
if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) { | ||
obj = obj[charkey]; | ||
} | ||
} | ||
if (!_this.options.charsAsChildren && _this.options.charkey in obj) { | ||
node[_this.options.charkey] = obj[_this.options.charkey]; | ||
delete obj[_this.options.charkey]; | ||
} | ||
if (Object.getOwnPropertyNames(obj).length > 0) { | ||
node[_this.options.childkey] = obj; | ||
} | ||
obj = node; | ||
} | ||
@@ -410,6 +429,14 @@ if (stack.length > 0) { | ||
return function(text) { | ||
var s; | ||
var charChild, s; | ||
s = stack[stack.length - 1]; | ||
if (s) { | ||
s[charkey] += text; | ||
if (_this.options.explicitChildren && _this.options.preserveChildrenOrder && _this.options.charsAsChildren && text.replace(/\\n/g, '').trim() !== '') { | ||
s[_this.options.childkey] = s[_this.options.childkey] || []; | ||
charChild = { | ||
'#name': '__text__' | ||
}; | ||
charChild[charkey] = text; | ||
s[_this.options.childkey].push(charChild); | ||
} | ||
return s; | ||
@@ -416,0 +443,0 @@ } |
{ | ||
"name" : "xml2js", | ||
"description" : "Simple XML to JavaScript object converter.", | ||
"keywords" : ["xml", "json"], | ||
"homepage" : "https://github.com/Leonidas-from-XIV/node-xml2js", | ||
"version" : "0.4.8", | ||
"author" : "Marek Kubica <marek@xivilization.net> (http://xivilization.net)", | ||
"contributors" : [ | ||
"name": "xml2js", | ||
"description": "Simple XML to JavaScript object converter.", | ||
"keywords": [ | ||
"xml", | ||
"json" | ||
], | ||
"homepage": "https://github.com/Leonidas-from-XIV/node-xml2js", | ||
"version": "0.4.9", | ||
"author": "Marek Kubica <marek@xivilization.net> (http://xivilization.net)", | ||
"contributors": [ | ||
"maqr <maqr.lollerskates@gmail.com> (https://github.com/maqr)", | ||
@@ -40,31 +43,33 @@ "Ben Weaver (http://benweaver.com/)", | ||
"Piotr Rochala (http://rocha.la/)", | ||
"Michael Avila (https://github.com/michaelavila)" | ||
"Michael Avila (https://github.com/michaelavila)", | ||
"Ryan Gahl (https://github.com/ryedin)", | ||
"Eric Laberge <e.laberge@gmail.com> (https://github.com/elaberge)", | ||
"Benjamin E. Coe <ben@npmjs.com> (https://twitter.com/benjamincoe)" | ||
], | ||
"main" : "./lib/xml2js", | ||
"directories" : { | ||
"main": "./lib/xml2js", | ||
"directories": { | ||
"lib": "./lib" | ||
}, | ||
"scripts" : { | ||
"test": "zap" | ||
"scripts": { | ||
"test": "zap", | ||
"coverage": "nyc npm test && nyc report", | ||
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls" | ||
}, | ||
"repository" : { | ||
"type" : "git", | ||
"url" : "https://github.com/Leonidas-from-XIV/node-xml2js.git" | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Leonidas-from-XIV/node-xml2js.git" | ||
}, | ||
"dependencies" : { | ||
"sax" : "0.6.x", | ||
"xmlbuilder" : ">=2.4.6" | ||
"dependencies": { | ||
"sax": "0.6.x", | ||
"xmlbuilder": ">=2.4.6" | ||
}, | ||
"devDependencies" : { | ||
"coffee-script" : ">=1.9.0", | ||
"zap" : ">=0.2.6", | ||
"docco" : ">=0.6.2", | ||
"diff" : ">=1.0.8" | ||
"devDependencies": { | ||
"coffee-script": ">=1.9.0", | ||
"coveralls": "^2.11.2", | ||
"diff": ">=1.0.8", | ||
"docco": ">=0.6.2", | ||
"nyc": "^2.2.1", | ||
"zap": ">=0.2.6" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://raw.github.com/Leonidas-from-XIV/node-xml2js/master/LICENSE" | ||
} | ||
] | ||
"license": "MIT" | ||
} |
@@ -259,2 +259,10 @@ node-xml2js | ||
`explicitChildren` is set to `true`. Added in 0.2.5. | ||
* `preserveChildrenOrder` (default `false`): Modifies the behavior of | ||
`explicitChildren` so that the value of the "children" property becomes an | ||
ordered array. When this is `true`, every node will also get a `#name` field | ||
whose value will correspond to the XML nodeName, so that you may iterate | ||
the "children" array and still be able to determine node names. The named | ||
(and potentially unordered) properties are also retained in this | ||
configuration at the same level as the ordered "children" array. Added in | ||
0.4.9. | ||
* `charsAsChildren` (default `false`): Determines whether chars should be | ||
@@ -356,2 +364,3 @@ considered children if `explicitChildren` is on. Added in 0.2.5. | ||
[![Build Status](https://secure.travis-ci.org/Leonidas-from-XIV/node-xml2js.png?branch=master)](https://travis-ci.org/Leonidas-from-XIV/node-xml2js) | ||
[![Coverage Status](https://coveralls.io/repos/Leonidas-from-XIV/node-xml2js/badge.svg?branch=)](https://coveralls.io/r/Leonidas-from-XIV/node-xml2js?branch=master) | ||
[![Dependency Status](https://david-dm.org/Leonidas-from-XIV/node-xml2js.png)](https://david-dm.org/Leonidas-from-XIV/node-xml2js) | ||
@@ -358,0 +367,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110470
22
571
388
6