Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xml-js

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xml-js - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1

11

lib/common.js

@@ -45,9 +45,10 @@ /*jslint node:true */

var i, j, options = {};
function findIndex (argument, index) {
if (argument.alias === process.argv[i].slice(1) || argument.arg === process.argv[i].slice(2)) {
j = index;
}
}
for (i = 2; i < process.argv.length; i += 1) {
j = -1;
optionalArgs.forEach(function (argument, index) {
if (argument.alias === process.argv[i].slice(1) || argument.arg === process.argv[i].slice(2)) {
j = index;
}
});
optionalArgs.forEach(findIndex);
if (j >= 0) {

@@ -54,0 +55,0 @@ switch (optionalArgs[j].type) {

@@ -59,2 +59,33 @@ /*jslint node:true */

function writeElement (element, options, depth) {
var xml = '';
xml += '<' + element.name;
if (element[options.attributesKey]) {
xml += writeAttributes(element[options.attributesKey]);
}
if (options.fullTagEmptyElement || (element[options.elementsKey] && element[options.elementsKey].length) || (element[options.attributesKey] && element[options.attributesKey]['xml:space'] === 'preserve')) {
xml += '>';
if (element[options.elementsKey] && element[options.elementsKey].length) {
xml += writeElements(element[options.elementsKey], options, depth + 1);
}
xml += (options.spaces && element[options.elementsKey] && element[options.elementsKey].length && (element[options.elementsKey].length > 1 || element[options.elementsKey][0].type !== 'text') ? '\n' : '') + Array(depth + 1).join(options.spaces);
xml += '</' + element.name + '>';
} else {
xml += '/>';
}
return xml;
}
function writeElements (elements, options, depth, firstLine) {
var sep = writeIndentation(options, depth, firstLine);
return elements.reduce(function (xml, element) {
switch (element.type) {
case 'element': return xml + sep + writeElement(element, options, depth);
case 'comment': return xml + sep + writeComment(element, options);
case 'cdata': return xml + sep + writeCdata(element, options);
case 'text': return xml + writeText(element, options);
}
}, '');
}
function writeElementCompact (element, name, options, depth, firstLine) {

@@ -94,33 +125,2 @@ var xml = '', key;

function writeElements (elements, options, depth, firstLine) {
var sep = writeIndentation(options, depth, firstLine);
return elements.reduce(function (xml, element) {
switch (element.type) {
case 'element': return xml + sep + writeElement(element, options, depth);
case 'comment': return xml + sep + writeComment(element, options);
case 'cdata': return xml + sep + writeCdata(element, options);
case 'text': return xml + writeText(element, options);
}
}, '');
}
function writeElement (element, options, depth) {
var xml = '';
xml += '<' + element.name;
if (element[options.attributesKey]) {
xml += writeAttributes(element[options.attributesKey]);
}
if (options.fullTagEmptyElement || (element[options.elementsKey] && element[options.elementsKey].length) || (element[options.attributesKey] && element[options.attributesKey]['xml:space'] === 'preserve')) {
xml += '>';
if (element[options.elementsKey] && element[options.elementsKey].length) {
xml += writeElements(element[options.elementsKey], options, depth + 1);
}
xml += (options.spaces && element[options.elementsKey] && element[options.elementsKey].length && (element[options.elementsKey].length > 1 || element[options.elementsKey][0].type !== 'text') ? '\n' : '') + Array(depth + 1).join(options.spaces);
xml += '</' + element.name + '>';
} else {
xml += '/>';
}
return xml;
}
module.exports = function (js, options) {

@@ -127,0 +127,0 @@ 'use strict';

{
"name": "xml-js",
"version": "0.9.0",
"version": "0.9.1",
"description": "A convertor between XML text and Javascript object / JSON text.",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc