You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

node-xml-stream-parser

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-xml-stream-parser - npm Package Compare versions

Comparing version

to
1.0.9

.idea/codeStyles/codeStyleConfig.xml

4

dist/parser.js

@@ -20,2 +20,3 @@ "use strict";

}
return function (Constructor, protoProps, staticProps) {

@@ -194,2 +195,5 @@ if (protoProps) defineProperties(Constructor.prototype, protoProps);

if (this.tagType && this.tagType === TAG_TYPE.SELF_CLOSING) {
if (Object.keys(attributes).length === 0 && attributes.constructor === Object) {
attributes = { ___selfClosing___: true };
}
this.emit(EVENTS.OPEN_TAG, name, attributes);

@@ -196,0 +200,0 @@ this.emit(EVENTS.CLOSE_TAG, name, attributes);

215

dist/parser.spec.js

@@ -1,10 +0,10 @@

'use strict';
"use strict";
var _chai = require('chai');
var _chai = require("chai");
var _index = require('./index');
var _index = require("./index");
var _index2 = _interopRequireDefault(_index);
var _fs = require('fs');
var _fs = require("fs");

@@ -15,133 +15,136 @@ var _fs2 = _interopRequireDefault(_fs);

describe('node-xml-stream', function () {
describe("node-xml-stream", function () {
describe("Emit instruction", function () {
it("#on(instruction)", function (done) {
var p = new _index2.default();
describe('Emit instruction', function () {
p.on("instruction", function (name, attrs) {
(0, _chai.expect)(name).to.eql("xml");
(0, _chai.expect)(attrs).to.be.a("object").with.property("version", "2.0");
(0, _chai.expect)(attrs).to.have.property("encoding", "utf-8");
done();
});
it('#on(instruction)', function (done) {
var p = new _index2.default();
p.write('<root><?xml version="2.0" encoding="utf-8"?></root>');
});
});
describe("Emit Tag after that have namespace ", function () {
it("#on(instruction)", function (done) {
var p = new _index2.default();
p.on('instruction', function (name, attrs) {
(0, _chai.expect)(name).to.eql('xml');
(0, _chai.expect)(attrs).to.be.a('object').with.property('version', '2.0');
(0, _chai.expect)(attrs).to.have.property('encoding', 'utf-8');
done();
});
p.on("opentag", function (name, attrs) {
(0, _chai.expect)(name).to.eql("imo:openimmo");
(0, _chai.expect)(attrs).to.be.a("object").with.property("xmlns:imo", "http://www.openimmo.de");
done();
});
p.write('<root><?xml version="2.0" encoding="utf-8"?></root>');
});
p.write('<?xml version="1.0" encoding="UTF-8"?><imo:openimmo xmlns:imo="http://www.openimmo.de" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openimmo.de openimmo.xsd"></imo:openimmo>');
});
describe('Emit Tag after that have namespace ', function () {
});
it('#on(instruction)', function (done) {
var p = new _index2.default();
describe("Emit opentag", function () {
it("#on(opentag)", function (done) {
var p = new _index2.default();
p.on('opentag', function (name, attrs) {
(0, _chai.expect)(name).to.eql('imo:openimmo');
(0, _chai.expect)(attrs).to.be.a('object').with.property('xmlns:imo', 'http://www.openimmo.de');
done();
});
p.on("opentag", function (name, attrs) {
(0, _chai.expect)(name).to.eql("root");
(0, _chai.expect)(attrs).to.be.a("object").with.property("name", "steeljuice");
done();
});
p.write('<?xml version="1.0" encoding="UTF-8"?><imo:openimmo xmlns:imo="http://www.openimmo.de" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openimmo.de openimmo.xsd"></imo:openimmo>');
});
p.write('<root name="steeljuice"><sub>TEXT</sub></root>');
});
});
describe('Emit opentag', function () {
it('#on(opentag)', function (done) {
var p = new _index2.default();
describe("Emit closetag", function () {
it("#on(closetag)", function (done) {
var p = new _index2.default();
p.on('opentag', function (name, attrs) {
(0, _chai.expect)(name).to.eql('root');
(0, _chai.expect)(attrs).to.be.a('object').with.property('name', 'steeljuice');
done();
});
p.on("closetag", function (name) {
(0, _chai.expect)(name).to.eql("root");
done();
});
p.write('<root name="steeljuice"><sub>TEXT</sub></root>');
});
p.write('<root name="steeljuice">TEXT</root>');
});
describe('Emit closetag', function () {
it('#on(closetag)', function (done) {
var p = new _index2.default();
it("#on(closetag) self closing.", function (done) {
var p = new _index2.default();
p.on("closetag", function (name, attrs) {
(0, _chai.expect)(name).to.eql("self");
(0, _chai.expect)(attrs).to.be.a("object").with.property("name", "steeljuice");
});
p.on('closetag', function (name) {
(0, _chai.expect)(name).to.eql('root');
done();
});
p.write('<self name="steeljuice" />');
done();
});
it("#on(closetag) empty self closing.", function (done) {
var p = new _index2.default();
p.on("closetag", function (name, attrs) {
(0, _chai.expect)(name).to.eql("self");
(0, _chai.expect)(attrs).to.be.a("object").with.property("___selfClosing___", true);
});
p.write('<root name="steeljuice">TEXT</root>');
});
it('#on(closetag) self closing.', function (done) {
var p = new _index2.default();
p.on('closetag', function (name, attrs) {
(0, _chai.expect)(name).to.eql('self');
(0, _chai.expect)(attrs).to.be.a('object').with.property('name', 'steeljuice');
});
p.write('<self name="steeljuice"/>');
p.write('<self name="steeljuice" />');
done();
});
p.write("<self/>");
done();
});
});
describe('Emit text', function () {
it('#on(text)', function (done) {
var p = new _index2.default();
p.on('text', function (text) {
(0, _chai.expect)(text).to.eql('SteelJuice');
done();
});
p.write('<self name="steeljuice"/><root>SteelJuice</root>');
});
describe("Emit text", function () {
it("#on(text)", function (done) {
var p = new _index2.default();
p.on("text", function (text) {
(0, _chai.expect)(text).to.eql("SteelJuice");
done();
});
p.write('<self name="steeljuice"/><root>SteelJuice</root>');
});
});
describe('Emit CDATA', function () {
describe("Emit CDATA", function () {
it("#on(cdata)", function (done) {
var p = new _index2.default();
it('#on(cdata)', function (done) {
var p = new _index2.default();
p.on("cdata", function (cdata) {
(0, _chai.expect)(cdata).to.eql("<p>cdata-text</br></p>");
done();
});
p.on('cdata', function (cdata) {
(0, _chai.expect)(cdata).to.eql('<p>cdata-text</br></p>');
done();
});
p.write('<root><![CDATA[<p>cdata-text</br></p>]]</root>');
});
p.write("<root><![CDATA[<p>cdata-text</br></p>]]</root>");
});
});
describe('Ignore comments', function () {
describe("Ignore comments", function () {
it("#on(text) with comments", function (done) {
var p = new _index2.default();
p.on("text", function (text) {
(0, _chai.expect)(text).to.eql("TEXT");
done();
});
it('#on(text) with comments', function (done) {
var p = new _index2.default();
p.on('text', function (text) {
(0, _chai.expect)(text).to.eql('TEXT');
done();
});
p.write('<root><!--Comment is written here! -->TEXT<!-- another comment! --></root>');
});
p.write("<root><!--Comment is written here! -->TEXT<!-- another comment! --></root>");
});
});
describe('Stream', function () {
it('#pipe() a stream.', function (done) {
var p = new _index2.default();
var stream = _fs2.default.createReadStream('./test/intertwingly.atom');
stream.pipe(p);
describe("Stream", function () {
it("#pipe() a stream.", function (done) {
var p = new _index2.default();
var stream = _fs2.default.createReadStream("./test/intertwingly.atom");
stream.pipe(p);
// Count the number of entry tags found (start/closing) and compare them (they should be the same) when the stream is completed.
var entryclose = 0;
var entrystart = 0;
p.on('closetag', function (name) {
if (name === 'entry') entryclose++;
});
p.on('opentag', function (name) {
if (name === 'entry') entrystart++;
});
p.on('finish', function () {
(0, _chai.expect)(entryclose).to.eql(entrystart);
done();
});
});
// Count the number of entry tags found (start/closing) and compare them (they should be the same) when the stream is completed.
var entryclose = 0;
var entrystart = 0;
p.on("closetag", function (name) {
if (name === "entry") entryclose++;
});
p.on("opentag", function (name) {
if (name === "entry") entrystart++;
});
p.on("finish", function () {
(0, _chai.expect)(entryclose).to.eql(entrystart);
done();
});
});
});
});
{
"name": "node-xml-stream-parser",
"version": "1.0.8",
"version": "1.0.9",
"description": "A fast XML parser using streams.",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet