Socket
Socket
Sign inDemoInstall

xmlbuilder

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xmlbuilder - npm Package Compare versions

Comparing version 0.3.11 to 0.4.0

12

lib/index.js

@@ -0,7 +1,15 @@

// Generated by CoffeeScript 1.3.3
(function() {
var XMLBuilder;
XMLBuilder = require('./XMLBuilder');
module.exports.create = function() {
return new XMLBuilder();
module.exports.create = function(name, xmldec, doctype) {
if (name != null) {
return new XMLBuilder(name, xmldec, doctype).root();
} else {
return new XMLBuilder();
}
};
}).call(this);

@@ -0,16 +1,25 @@

// Generated by CoffeeScript 1.3.3
(function() {
var XMLBuilder, XMLFragment;
XMLFragment = require('./XMLFragment');
XMLBuilder = (function() {
function XMLBuilder() {
function XMLBuilder(name, xmldec, doctype) {
var att, child, _ref;
this.children = [];
this.rootObject = null;
}
XMLBuilder.prototype.begin = function(name, xmldec, doctype) {
var att, child, root;
if (!(name != null)) {
throw new Error("Root element needs a name");
if (this.is(name, 'Object')) {
_ref = [name, xmldec], xmldec = _ref[0], doctype = _ref[1];
name = null;
}
this.children = [];
name = '' + name || '';
if (name != null) {
name = '' + name || '';
if (xmldec == null) {
xmldec = {
'version': '1.0'
};
}
}
if ((xmldec != null) && !(xmldec.version != null)) {

@@ -41,5 +50,6 @@ throw new Error("Version number is required");

if (doctype != null) {
att = {
name: name
};
att = {};
if (name != null) {
att.name = name;
}
if (doctype.ext != null) {

@@ -52,2 +62,21 @@ doctype.ext = '' + doctype.ext || '';

}
if (name != null) {
this.begin(name);
}
}
XMLBuilder.prototype.begin = function(name, xmldec, doctype) {
var doc, root;
if (!(name != null)) {
throw new Error("Root element needs a name");
}
if (this.rootObject) {
this.children = [];
this.rootObject = null;
}
if (xmldec != null) {
doc = new XMLBuilder(name, xmldec, doctype);
return doc.root();
}
name = '' + name || '';
root = new XMLFragment(this, name, {});

@@ -60,5 +89,7 @@ root.isRoot = true;

};
XMLBuilder.prototype.root = function() {
return this.rootObject;
};
XMLBuilder.prototype.toString = function(options) {

@@ -74,5 +105,15 @@ var child, r, _i, _len, _ref;

};
XMLBuilder.prototype.is = function(obj, type) {
var clas;
clas = Object.prototype.toString.call(obj).slice(8, -1);
return (obj != null) && clas === type;
};
return XMLBuilder;
})();
module.exports = XMLBuilder;
}).call(this);

89

lib/XMLFragment.js

@@ -0,5 +1,8 @@

// Generated by CoffeeScript 1.3.3
(function() {
var XMLFragment;
var __hasProp = Object.prototype.hasOwnProperty;
var XMLFragment,
__hasProp = {}.hasOwnProperty;
XMLFragment = (function() {
function XMLFragment(parent, name, attributes, text) {

@@ -14,4 +17,5 @@ this.isRoot = false;

}
XMLFragment.prototype.element = function(name, attributes, text) {
var child, key, val, _ref, _ref2;
var child, key, val, _ref, _ref1;
if (!(name != null)) {

@@ -22,11 +26,9 @@ throw new Error("Missing element name");

this.assertLegalChar(name);
if (attributes != null) {
attributes;
} else {
if (attributes == null) {
attributes = {};
};
}
if (this.is(attributes, 'String') && this.is(text, 'Object')) {
_ref = [text, attributes], attributes = _ref[0], text = _ref[1];
} else if (this.is(attributes, 'String')) {
_ref2 = [{}, attributes], attributes = _ref2[0], text = _ref2[1];
_ref1 = [{}, attributes], attributes = _ref1[0], text = _ref1[1];
}

@@ -49,4 +51,5 @@ for (key in attributes) {

};
XMLFragment.prototype.insertBefore = function(name, attributes, text) {
var child, i, key, val, _ref, _ref2;
var child, i, key, val, _ref, _ref1;
if (this.isRoot) {

@@ -60,11 +63,9 @@ throw new Error("Cannot insert elements at root level");

this.assertLegalChar(name);
if (attributes != null) {
attributes;
} else {
if (attributes == null) {
attributes = {};
};
}
if (this.is(attributes, 'String') && this.is(text, 'Object')) {
_ref = [text, attributes], attributes = _ref[0], text = _ref[1];
} else if (this.is(attributes, 'String')) {
_ref2 = [{}, attributes], attributes = _ref2[0], text = _ref2[1];
_ref1 = [{}, attributes], attributes = _ref1[0], text = _ref1[1];
}

@@ -88,4 +89,5 @@ for (key in attributes) {

};
XMLFragment.prototype.insertAfter = function(name, attributes, text) {
var child, i, key, val, _ref, _ref2;
var child, i, key, val, _ref, _ref1;
if (this.isRoot) {

@@ -99,11 +101,9 @@ throw new Error("Cannot insert elements at root level");

this.assertLegalChar(name);
if (attributes != null) {
attributes;
} else {
if (attributes == null) {
attributes = {};
};
}
if (this.is(attributes, 'String') && this.is(text, 'Object')) {
_ref = [text, attributes], attributes = _ref[0], text = _ref[1];
} else if (this.is(attributes, 'String')) {
_ref2 = [{}, attributes], attributes = _ref2[0], text = _ref2[1];
_ref1 = [{}, attributes], attributes = _ref1[0], text = _ref1[1];
}

@@ -127,2 +127,3 @@ for (key in attributes) {

};
XMLFragment.prototype.remove = function() {

@@ -137,2 +138,3 @@ var i, _ref;

};
XMLFragment.prototype.text = function(value) {

@@ -150,2 +152,3 @@ var child;

};
XMLFragment.prototype.cdata = function(value) {

@@ -165,2 +168,3 @@ var child;

};
XMLFragment.prototype.comment = function(value) {

@@ -181,2 +185,3 @@ var child;

};
XMLFragment.prototype.raw = function(value) {

@@ -192,2 +197,3 @@ var child;

};
XMLFragment.prototype.up = function() {

@@ -199,2 +205,3 @@ if (this.isRoot) {

};
XMLFragment.prototype.root = function() {

@@ -211,5 +218,7 @@ var child;

};
XMLFragment.prototype.document = function() {
return this.root().documentObject;
};
XMLFragment.prototype.prev = function() {

@@ -226,2 +235,3 @@ var i;

};
XMLFragment.prototype.next = function() {

@@ -238,2 +248,3 @@ var i;

};
XMLFragment.prototype.clone = function(deep) {

@@ -252,2 +263,3 @@ var clonedSelf;

};
XMLFragment.prototype.importXMLBuilder = function(xmlbuilder) {

@@ -261,2 +273,3 @@ var clonedRoot;

};
XMLFragment.prototype.attribute = function(name, value) {

@@ -272,10 +285,9 @@ var _ref;

value = '' + value || '';
if ((_ref = this.attributes) != null) {
_ref;
} else {
if ((_ref = this.attributes) == null) {
this.attributes = {};
};
}
this.attributes[name] = this.escape(value);
return this;
};
XMLFragment.prototype.removeAttribute = function(name) {

@@ -289,4 +301,5 @@ if (!(name != null)) {

};
XMLFragment.prototype.toString = function(options, level) {
var attName, attValue, child, indent, newline, pretty, r, space, _i, _len, _ref, _ref2;
var attName, attValue, child, indent, newline, pretty, r, space, _i, _len, _ref, _ref1;
pretty = (options != null) && options.pretty || false;

@@ -332,5 +345,5 @@ indent = (options != null) && options.indent || ' ';

}
_ref2 = this.children;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
child = _ref2[_i];
_ref1 = this.children;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
child = _ref1[_i];
r += child.toString(options, level + 1);

@@ -348,5 +361,7 @@ }

};
XMLFragment.prototype.escape = function(str) {
return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/'/g, '&apos;').replace(/"/g, '&quot;');
};
XMLFragment.prototype.assertLegalChar = function(str) {

@@ -360,2 +375,3 @@ var chars, chr;

};
XMLFragment.prototype.is = function(obj, type) {

@@ -366,44 +382,61 @@ var clas;

};
XMLFragment.prototype.ele = function(name, attributes, text) {
return this.element(name, attributes, text);
};
XMLFragment.prototype.txt = function(value) {
return this.text(value);
};
XMLFragment.prototype.dat = function(value) {
return this.cdata(value);
};
XMLFragment.prototype.att = function(name, value) {
return this.attribute(name, value);
};
XMLFragment.prototype.com = function(value) {
return this.comment(value);
};
XMLFragment.prototype.doc = function() {
return this.document();
};
XMLFragment.prototype.e = function(name, attributes, text) {
return this.element(name, attributes, text);
};
XMLFragment.prototype.t = function(value) {
return this.text(value);
};
XMLFragment.prototype.d = function(value) {
return this.cdata(value);
};
XMLFragment.prototype.a = function(name, value) {
return this.attribute(name, value);
};
XMLFragment.prototype.c = function(value) {
return this.comment(value);
};
XMLFragment.prototype.r = function(value) {
return this.raw(value);
};
XMLFragment.prototype.u = function() {
return this.up();
};
return XMLFragment;
})();
module.exports = XMLFragment;
}).call(this);
{
"name": "xmlbuilder",
"version": "0.3.11",
"version": "0.4.0",
"keywords": [ "xml", "xmlbuilder" ],

@@ -5,0 +5,0 @@ "homepage": "http://github.com/oozcitak/xmlbuilder-js",

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