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 8.0.0 to 8.1.0

lib/XMLDocumentCB.js

25

CHANGELOG.md

@@ -5,2 +5,26 @@ # Change Log

## [8.1.0] - 2016-03-29
- Added the callback option to the `begin` export function. When used with a
calback function, the XML document will be generated in chunks and each chunk
will be passed to the supplied function. In this mode, `begin` uses a different
code path and the builder should use much less memory since the entire XML tree
is not kept. There are a few drawbacks though. For example, traversing the document
tree or adding attributes to a node after it is written is not possible. It is
also not possible to remove nodes or attributes.
``` js
var result = '';
builder.begin(function(chunk) { result += chunk; })
.dec()
.ele('root')
.ele('xmlbuilder').up()
.end();
```
- Replaced native `Object.assign` with `lodash.assign` to support old JS engines. See [#111](https://github.com/oozcitak/xmlbuilder-js/issues/111).
- Added the ability to add comments and processing instructions before and after the root element. Added `commentBefore`, `commentAfter`, `instructionBefore` and `instructionAfter` functions for this purpose.
- Dropped support for old node.js releases. Minimum required node.js version is now 4.0.
## [8.0.0] - 2016-03-25

@@ -291,2 +315,3 @@ - Added the `begin` export function. See the wiki for details.

[8.1.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v8.0.0...v8.1.0
[8.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v7.0.0...v8.0.0

@@ -293,0 +318,0 @@ [7.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v6.0.0...v7.0.0

23

lib/index.js
// Generated by CoffeeScript 1.10.0
(function() {
var XMLDocument, XMLStreamWriter, XMLStringWriter;
var XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction;
isFunction = require('lodash/isFunction');
assign = require('lodash/assign');
XMLDocument = require('./XMLDocument');
XMLDocumentCB = require('./XMLDocumentCB');
XMLStringWriter = require('./XMLStringWriter');

@@ -16,3 +22,3 @@

}
options = Object.assign({}, xmldec, doctype, options);
options = assign({}, xmldec, doctype, options);
doc = new XMLDocument(options);

@@ -29,4 +35,13 @@ root = doc.element(name);

module.exports.begin = function(options) {
return new XMLDocument(options);
module.exports.begin = function(options, onData, onEnd) {
var ref;
if (isFunction(options)) {
ref = [options, onData], onData = ref[0], onEnd = ref[1];
options = {};
}
if (onData) {
return new XMLDocumentCB(options, onData, onEnd);
} else {
return new XMLDocument(options);
}
};

@@ -33,0 +48,0 @@

4

lib/XMLDocument.js

@@ -20,5 +20,3 @@ // Generated by CoffeeScript 1.10.0

XMLDocument.__super__.constructor.call(this, null);
if (options == null) {
options = {};
}
options || (options = {});
if (!options.writer) {

@@ -25,0 +23,0 @@ options.writer = new XMLStringWriter();

@@ -51,5 +51,3 @@ // Generated by CoffeeScript 1.10.0

lastChild = null;
if (attributes == null) {
attributes = {};
}
attributes || (attributes = {});
attributes = attributes.valueOf();

@@ -155,5 +153,3 @@ if (!isObject(attributes)) {

}
if (attributes == null) {
attributes = {};
}
attributes || (attributes = {});
attributes = attributes.valueOf();

@@ -160,0 +156,0 @@ if (!isObject(attributes)) {

@@ -17,5 +17,3 @@ // Generated by CoffeeScript 1.10.0

var key, ref, value;
if (options == null) {
options = {};
}
options || (options = {});
this.allowSurrogateChars = options.allowSurrogateChars;

@@ -22,0 +20,0 @@ this.noDoubleEncoding = options.noDoubleEncoding;

@@ -263,2 +263,37 @@ // Generated by CoffeeScript 1.10.0

XMLStringWriter.prototype.openNode = function(node, level) {
var att, name, r, ref;
level || (level = 0);
if (node instanceof XMLElement) {
r = this.space(level) + '<' + node.name;
ref = node.attributes;
for (name in ref) {
if (!hasProp.call(ref, name)) continue;
att = ref[name];
r += this.attribute(att);
}
r += (node.children ? '>' : '/>') + this.newline;
return r;
} else {
r = this.space(level) + '<!DOCTYPE ' + node.rootNodeName;
if (node.pubID && node.sysID) {
r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
} else if (node.sysID) {
r += ' SYSTEM "' + node.sysID + '"';
}
r += (node.children ? ' [' : '>') + this.newline;
return r;
}
};
XMLStringWriter.prototype.closeNode = function(node, level) {
level || (level = 0);
switch (false) {
case !(node instanceof XMLElement):
return this.space(level) + '</' + node.name + '>' + this.newline;
case !(node instanceof XMLDocType):
return this.space(level) + ']>' + this.newline;
}
};
return XMLStringWriter;

@@ -265,0 +300,0 @@

@@ -9,5 +9,3 @@ // Generated by CoffeeScript 1.10.0

var key, ref, ref1, ref2, ref3, ref4, value;
if (options == null) {
options = {};
}
options || (options = {});
this.pretty = options.pretty || false;

@@ -34,5 +32,3 @@ this.allowEmpty = (ref = options.allowEmpty) != null ? ref : false;

var key, ref, value;
if (options == null) {
options = {};
}
options || (options = {});
if ("pretty" in options) {

@@ -39,0 +35,0 @@ this.pretty = options.pretty;

{
"name": "xmlbuilder",
"version": "8.0.0",
"version": "8.1.0",
"keywords": [

@@ -5,0 +5,0 @@ "xml",

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