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

@jdalton/simple-xml-to-json

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jdalton/simple-xml-to-json - npm Package Compare versions

Comparing version

to
1.2.14

9

lib/simpleXmlToJson.js

@@ -23,2 +23,3 @@ 'use strict';

let pos = 0;
let seenRootTagName = false;
let erroredMessage;

@@ -361,2 +362,3 @@

if (
seenRootTagName &&
typeof knownElement === 'function' &&

@@ -374,2 +376,4 @@ !knownElement(peekedTagName)

break
} else if (seenRootTagName === false) {
seenRootTagName = true;
}

@@ -920,5 +924,4 @@ }

// Use a queue to avoid call stack limits.
const queue = Array(1000);
queue[0] = [root, json, -1];
let queueLength = 1;
const queue = [[root, json, -1]];
let { length: queueLength } = queue;
let pos = 0;

@@ -925,0 +928,0 @@ while (pos < queueLength) {

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

"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const t={type:9,value:""};var r={createLexer:function(e,{knownAttrib:r,knownElement:n}={}){const{length:o}=e,a=[];let c,s=0,l=t,u=0,h=0,i=0,f="",d=0,p=0;const A=()=>{const t=p;for(;p<o;){const t=e.charCodeAt(p);if(60===t||61===t||62===t)break;p+=1}const r=e.slice(t,p);return y(r)},C=()=>{if(p<o)switch(e.charCodeAt(p)){case 60:return p+=1,p<o&&47===e.charCodeAt(p)?(p+=1,3):p+2<o&&33===e.charCodeAt(p)&&45===e.charCodeAt(p+1)&&45===e.charCodeAt(p+2)?(p+=3,32):p+7<o&&33===e.charCodeAt(p)&&91===e.charCodeAt(p+1)&&67===e.charCodeAt(p+2)&&68===e.charCodeAt(p+3)&&65===e.charCodeAt(p+4)&&84===e.charCodeAt(p+5)&&65===e.charCodeAt(p+6)&&91===e.charCodeAt(p+7)?(p+=8,16):2;case 47:return p+=1,p<o&&62===e.charCodeAt(p)?(p+=1,5):1;case 61:return p+=1,8;case 62:return p+=1,4}return 0},v=()=>{const t=p;for(;!(p<o&&(p+2>=o||62===e.charCodeAt(p+2)&&93===e.charCodeAt(p+1)&&93===e.charCodeAt(p)));)p+=1;const r=e.slice(t,p);return p!==o&&(p+=3),r},k=()=>{const t=p;let r=!0;for(;p<o;){const t=e.charCodeAt(p);if(r){if(r=!1,t>=97&&t<=122||t>=65&&t<=90){p+=1;continue}h=1}if(!(t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||58===t||46===t||45===t))break;p+=1}return e.slice(t,p)},y=e=>{let t="",r=0,n=0;for(;-1!==(n=e.indexOf("'",r));)t=t+e.slice(r,n)+'"',r=n+1;return r?t+e.slice(r):e},b=()=>{for(;p<o;){const t=e.charCodeAt(p);if(60===t||61===t||62===t)break;p+=1}},w=()=>{let t=!0;for(;p<o;){const r=e.charCodeAt(p);if(t){if(t=!1,r>=97&&r<=122||r>=65&&r<=90){p+=1;continue}h=1}if(!(r>=97&&r<=122||r>=65&&r<=90||r>=48&&r<=57||95===r||58===r||46===r||45===r))break;p+=1}};for(;p<o;){const t=e.charCodeAt(p);if(32!==t&&10!==t&&13!==t&&9!==t)break;p+=1}if(60===e.charCodeAt(p)&&63===e.charCodeAt(p+1)&&120===e.charCodeAt(p+2)&&109===e.charCodeAt(p+3)&&108===e.charCodeAt(p+4))for(;p<o;)if(63!==e.charCodeAt(p))p+=1;else{if(62===e.charCodeAt(p+1)){p+=2;break}p+=1}return{hasNext:()=>p<o,next:()=>{if(h)throw h=1,new Error(c);let T=null,g=!1;for(;;)if(null===T){let b=p;if(0===i)for(;p<o;){const t=e.charCodeAt(p);if(32!==t&&10!==t&&13!==t&&9!==t)break;p+=1}else 9===d&&(p=i,i=0,f="",d=0);if(!(p<o))return l=t,u=9,l;if(1===u){const e=f;return p=i,i=0,f="",d=0,s={tagName:e},u=2,l={type:2,value:e},a.push(s),l}if(5===u){if(p<o){const t=e.charCodeAt(p);34!==t&&39!==t||(p+=1)}let t=p;for(;p<o;){const t=e.charCodeAt(p);if(34===t||39===t)break;p+=1}if(u=4,g){g=!1,p+=1;continue}const r=e.slice(t,p),n=y(r);return p+=1,l={type:4,value:n},l}const w=p-b;for(;p<o;){const t=e.charCodeAt(p);if(32!==t&&10!==t&&13!==t&&9!==t)break;p+=1}switch(C()){case 2:{const t=p;for(;p<o;){const t=e.charCodeAt(p);if(32!==t&&10!==t&&13!==t&&9!==t)break;p+=1}if(i=p,p<o){const e=p;if(f=k(),h|=p===e,h)throw h=1,c=`Invalid tag name: "${f}"`,new Error(`Invalid tag name: "${f}"`);if(d=2,i=p,"function"==typeof n&&!n(f)){const e=f;i=0,f="",s={tagName:e},u=2,T=s,g=!0,a.push(s);break}}else d=9;return p=t,u=1,l={type:1,value:""},l}case 3:{a.pop();const t=p;for(;62!==e.charCodeAt(p);)p+=1;return s=a[a.length-1],u=8,l={type:8,value:e.slice(t,p)},p+=1,l}case 4:return u=7,l={type:7,value:""},l;case 5:{const{tagName:e}=a.pop();return s=a[a.length-1],u=8,l={type:8,value:e},l}case 8:if(3===u){if(u=5,g)break;return l={type:5,value:""},l}return u=6,l={type:6,value:"="},l;case 16:return u=6,l={type:6,value:v()},l;case 32:for(;!(p<o&&(p+2>=o||62===e.charCodeAt(p+2)&&45===e.charCodeAt(p+1)&&45===e.charCodeAt(p)));)p+=1;p!==o&&(p+=3);break;default:{const t=A();if(0===t.length)throw h=1,c=`Unknown Syntax : "${e[p]}"`,new Error(`Unknown Syntax : "${e[p]}"`);if(7===u)return u=6,l=60===e.charCodeAt(p)?{type:6,value:t}:{type:6,value:t+A()},l;if(3!==u&&6!==u){if(8===u)return u=6,l={type:6,value:" ".repeat(w)+t},l;if(u=3,"function"==typeof r&&!r(t)){g=!0;break}return l={type:3,value:t},l}return u=6,l={type:6,value:" ".repeat(w)+t},l}}}else{for(;p<o;){const t=e.charCodeAt(p);if(32!==t&&10!==t&&13!==t&&9!==t)break;p+=1}if(!(p<o))return l=t,u=9,l;if(1===u){const t=p;if(w(),h|=p===t,h)throw h=1,c=`Invalid tag name: "${e.slice(t,p)}"`,new Error(`Invalid tag name: "${e.slice(t,p)}"`);s={tagName:""},u=2,a.push(s);continue}if(5===u){if(p<o){const t=e.charCodeAt(p);34!==t&&39!==t||(p+=1)}for(;p<o;){const t=e.charCodeAt(p);if(34===t||39===t)break;p+=1}p+=1,u=4;continue}for(;p<o;){const t=e.charCodeAt(p);if(32!==t&&10!==t&&13!==t&&9!==t)break;p+=1}switch(C()){case 2:u=1;break;case 3:{const t=a.pop()===T;for(;62!==e.charCodeAt(p);)p+=1;s=a[a.length-1],u=8,t&&(T=null),p+=1;break}case 4:u=7;break;case 5:{const e=a.pop()===T;s=a[a.length-1],u=8,e&&(T=null);break}case 8:u=3===u?5:6;break;case 16:for(;!(p<o&&(p+2>=o||62===e.charCodeAt(p+2)&&93===e.charCodeAt(p+1)&&93===e.charCodeAt(p)));)p+=1;p!==o&&(p+=3);break;case 32:for(;!(p<o&&(p+2>=o||62===e.charCodeAt(p+2)&&45===e.charCodeAt(p+1)&&45===e.charCodeAt(p)));)p+=1;p!==o&&(p+=3);break;default:{const t=p;if(b(),p===t)throw h=1,c=`Unknown Syntax : "${e[p]}"`,new Error(`Unknown Syntax : "${e[p]}"`);7===u?(u=6,60!==e.charCodeAt(p)&&b()):u=3!==u&&6!==u?8===u?6:3:6}}}},peek:()=>e.charCodeAt(p),pos:()=>p,scope:()=>s}}};const{createLexer:n}=r;var o,a,c={createAST:(e,t={})=>{const r=n(e,{knownAttrib:t.knownAttrib,knownElement:t.knownElement}),o={type:"ROOT",value:{children:[],loc:{start:0,end:e.length}}},a=[o];for(;r.hasNext();){const e=r.next(),t=r.scope(),{type:n}=e,{value:c}=a[a.length-1];switch(n){case 1:{const e=r.pos()-1,{value:t}=r.next(),n=[];let o=r.next(),s=o.type;for(;7!==s&&8!==s&&9!==s&&r.hasNext();){const e=o;r.next();const t=r.next();n.push({type:"ATTRIBUTE",value:{name:e.value,value:t.value}}),o=r.next(),s=o.type}const l=8===s||9===s,u={type:"ELEMENT",value:{type:t,attributes:n,children:[],loc:{start:e,end:l?r.pos():e}}};c.children.push(u),l||a.push(u);break}case 8:if(t===r.scope()){a.pop(),c.loc.end=r.pos();const{children:e}=c,{length:t}=e,n=t>0?e[0]:void 0;if(n&&"CONTENT"===n.type){let r=n.value;const o=[];for(let n=1;n<t;n+=1){const t=e[n];"CONTENT"===t.type?r+=t.value:(r.length&&(o.push({type:"CONTENT",value:r}),r=""),o.push(t))}r.length&&o.push({type:"CONTENT",value:r}),c.children=o}}break;case 6:c.children.push({type:"CONTENT",value:e.value});break;case 9:return o;default:throw new Error(`Unknown Lexem type: ${n} "${e.value}, scoping element: ${c.type}"`)}}return o}};const{createAST:s}=c;var l={convertXML:function(e,t={}){const r=s(e,{knownAttrib:t.knownAttrib,knownElement:t.knownElement});return(t.converter??(a?o:(a=1,o={convert:e=>{const t=e.value.children[0];if("object"!=typeof t||null===t)return null;const r={},n=Array(1e3);n[0]=[t,r,-1];let o=1,a=0;for(;a<o;){const{0:{value:{attributes:e,children:t,type:r}},1:c,2:s}=n[a++],l={};-1!==s?c[s]={[r]:l}:c[r]=l;for(let t=0,{length:r}=e;t<r;t+=1){const{value:{name:r,value:n}}=e[t];l[r]=n}const{length:u}=t;if(!u)continue;if(1===u&&"CONTENT"===t[0].type){l.content=t[0].value;continue}const h=Array(u);l.children=h;for(let e=0;e<u;e+=1){const r=t[e];"CONTENT"===r.type?h[e]={content:r.value}:n[o++]=[r,h,e]}}return r}}))).convert(r)}};const{createAST:u}=c,{convertXML:h}=l;var i=e({convertXML:h,createAST:u});module.exports=i;
"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const t={type:9,value:""};var r={createLexer:function(e,{knownAttrib:r,knownElement:n}={}){const{length:o}=e,a=[];let c,s=0,l=t,u=0,h=0,i=0,f="",d=0,p=0,A=!1;const C=()=>{const t=p;for(;p<o;){const t=e.charCodeAt(p);if(60===t||61===t||62===t)break;p+=1}const r=e.slice(t,p);return b(r)},v=()=>{if(p<o)switch(e.charCodeAt(p)){case 60:return p+=1,p<o&&47===e.charCodeAt(p)?(p+=1,3):p+2<o&&33===e.charCodeAt(p)&&45===e.charCodeAt(p+1)&&45===e.charCodeAt(p+2)?(p+=3,32):p+7<o&&33===e.charCodeAt(p)&&91===e.charCodeAt(p+1)&&67===e.charCodeAt(p+2)&&68===e.charCodeAt(p+3)&&65===e.charCodeAt(p+4)&&84===e.charCodeAt(p+5)&&65===e.charCodeAt(p+6)&&91===e.charCodeAt(p+7)?(p+=8,16):2;case 47:return p+=1,p<o&&62===e.charCodeAt(p)?(p+=1,5):1;case 61:return p+=1,8;case 62:return p+=1,4}return 0},k=()=>{const t=p;for(;!(p<o&&(p+2>=o||62===e.charCodeAt(p+2)&&93===e.charCodeAt(p+1)&&93===e.charCodeAt(p)));)p+=1;const r=e.slice(t,p);return p!==o&&(p+=3),r},y=()=>{const t=p;let r=!0;for(;p<o;){const t=e.charCodeAt(p);if(r){if(r=!1,t>=97&&t<=122||t>=65&&t<=90){p+=1;continue}h=1}if(!(t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||58===t||46===t||45===t))break;p+=1}return e.slice(t,p)},b=e=>{let t="",r=0,n=0;for(;-1!==(n=e.indexOf("'",r));)t=t+e.slice(r,n)+'"',r=n+1;return r?t+e.slice(r):e},w=()=>{for(;p<o;){const t=e.charCodeAt(p);if(60===t||61===t||62===t)break;p+=1}},g=()=>{let t=!0;for(;p<o;){const r=e.charCodeAt(p);if(t){if(t=!1,r>=97&&r<=122||r>=65&&r<=90){p+=1;continue}h=1}if(!(r>=97&&r<=122||r>=65&&r<=90||r>=48&&r<=57||95===r||58===r||46===r||45===r))break;p+=1}};for(;p<o;){const t=e.charCodeAt(p);if(32!==t&&10!==t&&13!==t&&9!==t)break;p+=1}if(60===e.charCodeAt(p)&&63===e.charCodeAt(p+1)&&120===e.charCodeAt(p+2)&&109===e.charCodeAt(p+3)&&108===e.charCodeAt(p+4))for(;p<o;)if(63!==e.charCodeAt(p))p+=1;else{if(62===e.charCodeAt(p+1)){p+=2;break}p+=1}return{hasNext:()=>p<o,next:()=>{if(h)throw h=1,new Error(c);let T=null,E=!1;for(;;)if(null===T){let w=p;if(0===i)for(;p<o;){const t=e.charCodeAt(p);if(32!==t&&10!==t&&13!==t&&9!==t)break;p+=1}else 9===d&&(p=i,i=0,f="",d=0);if(!(p<o))return l=t,u=9,l;if(1===u){const e=f;return p=i,i=0,f="",d=0,s={tagName:e},u=2,l={type:2,value:e},a.push(s),l}if(5===u){if(p<o){const t=e.charCodeAt(p);34!==t&&39!==t||(p+=1)}let t=p;for(;p<o;){const t=e.charCodeAt(p);if(34===t||39===t)break;p+=1}if(u=4,E){E=!1,p+=1;continue}const r=e.slice(t,p),n=b(r);return p+=1,l={type:4,value:n},l}const g=p-w;for(;p<o;){const t=e.charCodeAt(p);if(32!==t&&10!==t&&13!==t&&9!==t)break;p+=1}switch(v()){case 2:{const t=p;for(;p<o;){const t=e.charCodeAt(p);if(32!==t&&10!==t&&13!==t&&9!==t)break;p+=1}if(i=p,p<o){const e=p;if(f=y(),h|=p===e,h)throw h=1,c=`Invalid tag name: "${f}"`,new Error(`Invalid tag name: "${f}"`);if(d=2,i=p,A&&"function"==typeof n&&!n(f)){const e=f;i=0,f="",s={tagName:e},u=2,T=s,E=!0,a.push(s);break}!1===A&&(A=!0)}else d=9;return p=t,u=1,l={type:1,value:""},l}case 3:{a.pop();const t=p;for(;62!==e.charCodeAt(p);)p+=1;return s=a[a.length-1],u=8,l={type:8,value:e.slice(t,p)},p+=1,l}case 4:return u=7,l={type:7,value:""},l;case 5:{const{tagName:e}=a.pop();return s=a[a.length-1],u=8,l={type:8,value:e},l}case 8:if(3===u){if(u=5,E)break;return l={type:5,value:""},l}return u=6,l={type:6,value:"="},l;case 16:return u=6,l={type:6,value:k()},l;case 32:for(;!(p<o&&(p+2>=o||62===e.charCodeAt(p+2)&&45===e.charCodeAt(p+1)&&45===e.charCodeAt(p)));)p+=1;p!==o&&(p+=3);break;default:{const t=C();if(0===t.length)throw h=1,c=`Unknown Syntax : "${e[p]}"`,new Error(`Unknown Syntax : "${e[p]}"`);if(7===u)return u=6,l=60===e.charCodeAt(p)?{type:6,value:t}:{type:6,value:t+C()},l;if(3!==u&&6!==u){if(8===u)return u=6,l={type:6,value:" ".repeat(g)+t},l;if(u=3,"function"==typeof r&&!r(t)){E=!0;break}return l={type:3,value:t},l}return u=6,l={type:6,value:" ".repeat(g)+t},l}}}else{for(;p<o;){const t=e.charCodeAt(p);if(32!==t&&10!==t&&13!==t&&9!==t)break;p+=1}if(!(p<o))return l=t,u=9,l;if(1===u){const t=p;if(g(),h|=p===t,h)throw h=1,c=`Invalid tag name: "${e.slice(t,p)}"`,new Error(`Invalid tag name: "${e.slice(t,p)}"`);s={tagName:""},u=2,a.push(s);continue}if(5===u){if(p<o){const t=e.charCodeAt(p);34!==t&&39!==t||(p+=1)}for(;p<o;){const t=e.charCodeAt(p);if(34===t||39===t)break;p+=1}p+=1,u=4;continue}for(;p<o;){const t=e.charCodeAt(p);if(32!==t&&10!==t&&13!==t&&9!==t)break;p+=1}switch(v()){case 2:u=1;break;case 3:{const t=a.pop()===T;for(;62!==e.charCodeAt(p);)p+=1;s=a[a.length-1],u=8,t&&(T=null),p+=1;break}case 4:u=7;break;case 5:{const e=a.pop()===T;s=a[a.length-1],u=8,e&&(T=null);break}case 8:u=3===u?5:6;break;case 16:for(;!(p<o&&(p+2>=o||62===e.charCodeAt(p+2)&&93===e.charCodeAt(p+1)&&93===e.charCodeAt(p)));)p+=1;p!==o&&(p+=3);break;case 32:for(;!(p<o&&(p+2>=o||62===e.charCodeAt(p+2)&&45===e.charCodeAt(p+1)&&45===e.charCodeAt(p)));)p+=1;p!==o&&(p+=3);break;default:{const t=p;if(w(),p===t)throw h=1,c=`Unknown Syntax : "${e[p]}"`,new Error(`Unknown Syntax : "${e[p]}"`);7===u?(u=6,60!==e.charCodeAt(p)&&w()):u=3!==u&&6!==u?8===u?6:3:6}}}},peek:()=>e.charCodeAt(p),pos:()=>p,scope:()=>s}}};const{createLexer:n}=r;var o,a,c={createAST:(e,t={})=>{const r=n(e,{knownAttrib:t.knownAttrib,knownElement:t.knownElement}),o={type:"ROOT",value:{children:[],loc:{start:0,end:e.length}}},a=[o];for(;r.hasNext();){const e=r.next(),t=r.scope(),{type:n}=e,{value:c}=a[a.length-1];switch(n){case 1:{const e=r.pos()-1,{value:t}=r.next(),n=[];let o=r.next(),s=o.type;for(;7!==s&&8!==s&&9!==s&&r.hasNext();){const e=o;r.next();const t=r.next();n.push({type:"ATTRIBUTE",value:{name:e.value,value:t.value}}),o=r.next(),s=o.type}const l=8===s||9===s,u={type:"ELEMENT",value:{type:t,attributes:n,children:[],loc:{start:e,end:l?r.pos():e}}};c.children.push(u),l||a.push(u);break}case 8:if(t===r.scope()){a.pop(),c.loc.end=r.pos();const{children:e}=c,{length:t}=e,n=t>0?e[0]:void 0;if(n&&"CONTENT"===n.type){let r=n.value;const o=[];for(let n=1;n<t;n+=1){const t=e[n];"CONTENT"===t.type?r+=t.value:(r.length&&(o.push({type:"CONTENT",value:r}),r=""),o.push(t))}r.length&&o.push({type:"CONTENT",value:r}),c.children=o}}break;case 6:c.children.push({type:"CONTENT",value:e.value});break;case 9:return o;default:throw new Error(`Unknown Lexem type: ${n} "${e.value}, scoping element: ${c.type}"`)}}return o}};const{createAST:s}=c;var l={convertXML:function(e,t={}){const r=s(e,{knownAttrib:t.knownAttrib,knownElement:t.knownElement});return(t.converter??(a?o:(a=1,o={convert:e=>{const t=e.value.children[0];if("object"!=typeof t||null===t)return null;const r={},n=[[t,r,-1]];let{length:o}=n,a=0;for(;a<o;){const{0:{value:{attributes:e,children:t,type:r}},1:c,2:s}=n[a++],l={};-1!==s?c[s]={[r]:l}:c[r]=l;for(let t=0,{length:r}=e;t<r;t+=1){const{value:{name:r,value:n}}=e[t];l[r]=n}const{length:u}=t;if(!u)continue;if(1===u&&"CONTENT"===t[0].type){l.content=t[0].value;continue}const h=Array(u);l.children=h;for(let e=0;e<u;e+=1){const r=t[e];"CONTENT"===r.type?h[e]={content:r.value}:n[o++]=[r,h,e]}}return r}}))).convert(r)}};const{createAST:u}=c,{convertXML:h}=l;var i=e({convertXML:h,createAST:u});module.exports=i;

@@ -25,3 +25,3 @@ {

"license": "MIT",
"version": "1.2.13",
"version": "1.2.14",
"author": "John-David <john.david.dalton@gmail.com>",

@@ -28,0 +28,0 @@ "main": "lib/simpleXmlToJson.min.js",

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.