🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

xmlbuilder2

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xmlbuilder2 - npm Package Compare versions

Comparing version

to
1.6.0

10

lib/callback/XMLBuilderCBImpl.d.ts

@@ -1,2 +0,2 @@

import { XMLBuilderCB, AttributesObject, PIObject, DTDOptions, XMLBuilderCBOptions, ExpandObject } from "../interfaces";
import { XMLBuilderCB, AttributesObject, PIObject, DTDOptions, ExpandObject, XMLBuilderCBCreateOptions } from "../interfaces";
/**

@@ -33,3 +33,3 @@ * Represents a readable XML document stream.

*/
constructor(options: XMLBuilderCBOptions, fragment?: boolean);
constructor(options: XMLBuilderCBCreateOptions, fragment?: boolean);
/** @inheritdoc */

@@ -89,2 +89,8 @@ ele(p1: string | null | ExpandObject, p2?: AttributesObject | string, p3?: AttributesObject): XMLBuilderCB;

/**
* Reads and serializes an XML tree.
*
* @param node - root node
*/
private _fromNode;
/**
* Produces an XML serialization of the attributes of an element node.

@@ -91,0 +97,0 @@ *

92

lib/callback/XMLBuilderCBImpl.js

@@ -51,42 +51,13 @@ "use strict";

if (util_1.isObject(p1) || (util_1.isString(p1) && (/^\s*</.test(p1) || /^\s*[\{\[]/.test(p1)))) {
let currentLevel = -1;
__1.fragment(p1).each((child, index, level) => {
if (currentLevel > level) {
while (currentLevel-- > level) {
this.up();
}
}
currentLevel = level;
const node = child.node;
if (util_2.Guard.isElementNode(node)) {
const name = node.prefix ? node.prefix + ":" + node.localName : node.localName;
if (node.namespaceURI !== null) {
this.ele(node.namespaceURI, name);
}
else {
this.ele(name);
}
for (const attr of node.attributes) {
const name = attr.prefix ? attr.prefix + ":" + attr.localName : attr.localName;
if (attr.namespaceURI !== null) {
this.att(attr.namespaceURI, name, attr.value);
}
else {
this.att(name, attr.value);
}
}
}
else if (util_2.Guard.isExclusiveTextNode(node)) {
this.txt(node.data);
}
else if (util_2.Guard.isCommentNode(node)) {
this.com(node.data);
}
else if (util_2.Guard.isCDATASectionNode(node)) {
this.dat(node.data);
}
else if (util_2.Guard.isProcessingInstructionNode(node)) {
this.ins(node.target, node.data);
}
}, false, true);
const frag = __1.fragment().set(this._options);
try {
frag.ele(p1);
}
catch (err) {
this._onError.call(this, err);
return this;
}
for (const node of frag.node.childNodes) {
this._fromNode(node);
}
return this;

@@ -505,2 +476,43 @@ }

/**
* Reads and serializes an XML tree.
*
* @param node - root node
*/
_fromNode(node) {
if (util_2.Guard.isElementNode(node)) {
const name = node.prefix ? node.prefix + ":" + node.localName : node.localName;
if (node.namespaceURI !== null) {
this.ele(node.namespaceURI, name);
}
else {
this.ele(name);
}
for (const attr of node.attributes) {
const name = attr.prefix ? attr.prefix + ":" + attr.localName : attr.localName;
if (attr.namespaceURI !== null) {
this.att(attr.namespaceURI, name, attr.value);
}
else {
this.att(name, attr.value);
}
}
for (const child of node.childNodes) {
this._fromNode(child);
}
this.up();
}
else if (util_2.Guard.isExclusiveTextNode(node) && node.data) {
this.txt(node.data);
}
else if (util_2.Guard.isCommentNode(node)) {
this.com(node.data);
}
else if (util_2.Guard.isCDATASectionNode(node)) {
this.dat(node.data);
}
else if (util_2.Guard.isProcessingInstructionNode(node)) {
this.ins(node.target, node.data);
}
}
/**
* Produces an XML serialization of the attributes of an element node.

@@ -507,0 +519,0 @@ *

@@ -1,2 +0,2 @@

import { XMLBuilderCreateOptions, ExpandObject, XMLBuilder, WriterOptions, XMLSerializedValue, XMLBuilderCB, XMLBuilderCBOptions } from './interfaces';
import { XMLBuilderCreateOptions, ExpandObject, XMLBuilder, WriterOptions, XMLSerializedValue, XMLBuilderCB, XMLBuilderCBCreateOptions } from './interfaces';
import { Node } from '@oozcitak/dom/lib/dom/interfaces';

@@ -154,3 +154,3 @@ /**

*/
export declare function createCB(options: XMLBuilderCBOptions): XMLBuilderCB;
export declare function createCB(options: XMLBuilderCBCreateOptions): XMLBuilderCB;
/**

@@ -163,2 +163,2 @@ * Creates an XML builder which serializes the fragment in chunks.

*/
export declare function fragmentCB(options: XMLBuilderCBOptions): XMLBuilderCB;
export declare function fragmentCB(options: XMLBuilderCBCreateOptions): XMLBuilderCB;

@@ -903,7 +903,24 @@ import { Node, Document } from "@oozcitak/dom/lib/dom/interfaces";

*/
error?: ((err: Error) => void);
error: ((err: Error) => void);
/**
* Whether nodes with `null` values will be kept or ignored
*/
keepNullNodes: boolean;
/**
* Whether attributes with `null` values will be kept or ignored
*/
keepNullAttributes: boolean;
/**
* Whether converter strings will be ignored when converting JS
* objects to nodes
*/
ignoreConverters: boolean;
/**
* Defines string keys used while converting JS objects to nodes.
*/
convert: ConvertOptions;
/**
* Defines default namespaces to apply to all elements and attributes.
*/
defaultNamespace?: {
defaultNamespace: {
ele?: null | string;

@@ -915,3 +932,3 @@ att?: null | string;

*/
namespaceAlias?: {
namespaceAlias: {
[key: string]: string | null;

@@ -924,7 +941,7 @@ };

*/
wellFormed?: boolean;
wellFormed: boolean;
/**
* Pretty-prints the XML tree. Defaults to `false`.
*/
prettyPrint?: boolean;
prettyPrint: boolean;
/**

@@ -934,7 +951,7 @@ * Determines the indentation string for pretty printing. Defaults to two

*/
indent?: string;
indent: string;
/**
* Determines the newline string for pretty printing. Defaults to `"\n"`.
*/
newline?: string;
newline: string;
/**

@@ -944,3 +961,3 @@ * Defines a fixed number of indentations to add to every line. Defaults to

*/
offset?: number;
offset: number;
/**

@@ -950,3 +967,3 @@ * Wraps attributes to the next line if the column width exceeds the given

*/
width?: number;
width: number;
/**

@@ -964,3 +981,3 @@ * Produces closing tags for empty element nodes. Defaults to `false`. With

*/
allowEmptyTags?: boolean;
allowEmptyTags: boolean;
/**

@@ -974,5 +991,14 @@ * Inserts a space character before the slash character of self-closing tags.

*/
spaceBeforeSlash?: boolean;
spaceBeforeSlash: boolean;
};
/**
* Defines the options passed to the callback builder.
*/
export interface XMLBuilderCBCreateOptions extends RecursivePartial<XMLBuilderCBOptions> {
/** @inheritdoc */
data: ((chunk: string, level: number) => void);
/** @inheritdoc */
end: (() => void);
}
/**
* Defines default values for builder options.

@@ -979,0 +1005,0 @@ */

@@ -51,2 +51,12 @@ "use strict";

spaceBeforeSlash: false,
keepNullNodes: false,
keepNullAttributes: false,
ignoreConverters: false,
convert: {
att: "@",
ins: "?",
text: "#",
cdata: "$",
comment: "!"
},
defaultNamespace: {

@@ -53,0 +63,0 @@ ele: undefined,

{
"name": "xmlbuilder2",
"version": "1.5.0",
"version": "1.6.0",
"keywords": [

@@ -29,3 +29,3 @@ "xml",

"dependencies": {
"@oozcitak/util": "8.3.1",
"@oozcitak/util": "8.3.3",
"@oozcitak/dom": "1.15.4",

@@ -32,0 +32,0 @@ "@oozcitak/infra": "1.0.5"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet