xml-tokenizer 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var o=require("./get-q-name.js"),a=require("./tokenizer/tokenize.js");function s(i,l=!1){const e={},t=[e];return a.tokenize(i,l,c=>{r(c,t)}),e}function r(i,l){switch(i.type){case"ElementStart":{const e=o.getQName(i.local,i.prefix),t=`_${e}`,c={},n=l[l.length-1];n!=null&&(n.content!=null?(c.tag=e,n.content.push(c)):n.text!=null?(c.tag=e,n.content=[n.text,c],delete n.text):n[t]==null?n[t]=c:Array.isArray(n[t])?n[t].push(c):n[t]=[n[t],c]),l.push(c);break}case"ElementEnd":{(i.end.type==="Close"||i.end.type==="Empty")&&l.pop();break}case"Attribute":{const e=l[l.length-1];if(e!=null){const t=o.getQName(i.local,i.prefix);e.attributes!=null?e.attributes[t]=i.value:e.attributes={[t]:i.value}}break}case"Text":case"Cdata":{const e=l[l.length-1];if(e!=null){const t=i.text.trim();t.length>0&&(e.content!=null?e.content.push(t):e.text!=null?(e.content=[e.text,t],delete e.text):e.text=t)}break}}}exports.processTokenForSimplifiedObject=r,exports.xmlToSimplifiedObject=s;
1
+ "use strict";var c=require("./get-q-name.js"),o=require("./tokenizer/tokenize.js");function s(i,l=!1){const e={},t=[e];return o.tokenize(i,l,r=>{a(r,t)}),e}function a(i,l){switch(i.type){case"ElementStart":{const e=c.getQName(i.local,i.prefix),t=`_${e}`,r={},n=l[l.length-1];n!=null&&(n.content!=null?(r.tag=e,n.content.push(r)):n.text!=null?(r.tag=e,n.content=[n.text,r],delete n.text):n[t]==null?n[t]=[r]:Array.isArray(n[t])?n[t].push(r):n[t]=[n[t],r]),l.push(r);break}case"ElementEnd":{(i.end.type==="Close"||i.end.type==="Empty")&&l.pop();break}case"Attribute":{const e=l[l.length-1];if(e!=null){const t=c.getQName(i.local,i.prefix);e.attributes!=null?e.attributes[t]=i.value:e.attributes={[t]:i.value}}break}case"Text":case"Cdata":{const e=l[l.length-1];if(e!=null){const t=i.text.trim();t.length>0&&(e.content!=null?e.content.push(t):e.text!=null?(e.content=[e.text,t],delete e.text):e.text=t)}break}}}exports.processTokenForSimplifiedObject=a,exports.xmlToSimplifiedObject=s;
@@ -1 +1 @@
1
- import{getQName as r}from"./get-q-name.js";import{tokenize as i}from"./tokenizer/tokenize.js";function s(o,l=!1){const t={},e=[t];return i(o,l,c=>{a(c,e)}),t}function a(o,l){switch(o.type){case"ElementStart":{const t=r(o.local,o.prefix),e=`_${t}`,c={},n=l[l.length-1];n!=null&&(n.content!=null?(c.tag=t,n.content.push(c)):n.text!=null?(c.tag=t,n.content=[n.text,c],delete n.text):n[e]==null?n[e]=c:Array.isArray(n[e])?n[e].push(c):n[e]=[n[e],c]),l.push(c);break}case"ElementEnd":{(o.end.type==="Close"||o.end.type==="Empty")&&l.pop();break}case"Attribute":{const t=l[l.length-1];if(t!=null){const e=r(o.local,o.prefix);t.attributes!=null?t.attributes[e]=o.value:t.attributes={[e]:o.value}}break}case"Text":case"Cdata":{const t=l[l.length-1];if(t!=null){const e=o.text.trim();e.length>0&&(t.content!=null?t.content.push(e):t.text!=null?(t.content=[t.text,e],delete t.text):t.text=e)}break}}}export{a as processTokenForSimplifiedObject,s as xmlToSimplifiedObject};
1
+ import{getQName as c}from"./get-q-name.js";import{tokenize as i}from"./tokenizer/tokenize.js";function s(o,l=!1){const t={},e=[t];return i(o,l,r=>{a(r,e)}),t}function a(o,l){switch(o.type){case"ElementStart":{const t=c(o.local,o.prefix),e=`_${t}`,r={},n=l[l.length-1];n!=null&&(n.content!=null?(r.tag=t,n.content.push(r)):n.text!=null?(r.tag=t,n.content=[n.text,r],delete n.text):n[e]==null?n[e]=[r]:Array.isArray(n[e])?n[e].push(r):n[e]=[n[e],r]),l.push(r);break}case"ElementEnd":{(o.end.type==="Close"||o.end.type==="Empty")&&l.pop();break}case"Attribute":{const t=l[l.length-1];if(t!=null){const e=c(o.local,o.prefix);t.attributes!=null?t.attributes[e]=o.value:t.attributes={[e]:o.value}}break}case"Text":case"Cdata":{const t=l[l.length-1];if(t!=null){const e=o.text.trim();e.length>0&&(t.content!=null?t.content.push(e):t.text!=null?(t.content=[t.text,e],delete t.text):t.text=e)}break}}}export{a as processTokenForSimplifiedObject,s as xmlToSimplifiedObject};
@@ -6,8 +6,7 @@ export interface TSimplifiedXmlNode {
6
6
  attributes?: Record<string, string>;
7
7
  text?: string;
8
8
  content?: (string | TSimplifiedXmlNode)[];
9
- [key: TSimplifiedXmlNodeTagName]: TSimplifiedXmlNode | TSimplifiedXmlNode[];
9
+ [key: TSimplifiedXmlNodeTagName]: TSimplifiedXmlNode[];
10
10
  }
11
- type TSimplifiedXmlNodeTagName = `_${string}`;
12
- export {};
11
+ export type TSimplifiedXmlNodeTagName = `_${string}`;
13
12
  //# sourceMappingURL=xml-to-simplified-object.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"xml-to-simplified-object.d.ts","sourceRoot":"","sources":["../../src/xml-to-simplified-object.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAEvD,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,UAAQ,GAAG,kBAAkB,CAS7F;AAED,wBAAgB,+BAA+B,CAC9C,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,kBAAkB,EAAE,GACzB,IAAI,CAsEN;AAED,MAAM,WAAW,kBAAkB;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;IAE1C,CAAC,GAAG,EAAE,yBAAyB,GAAG,kBAAkB,GAAG,kBAAkB,EAAE,CAAC;CAC5E;AAED,KAAK,yBAAyB,GAAG,IAAI,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"xml-to-simplified-object.d.ts","sourceRoot":"","sources":["../../src/xml-to-simplified-object.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAEvD,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,UAAQ,GAAG,kBAAkB,CAS7F;AAED,wBAAgB,+BAA+B,CAC9C,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,kBAAkB,EAAE,GACzB,IAAI,CAsEN;AAED,MAAM,WAAW,kBAAkB;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;IAE1C,CAAC,GAAG,EAAE,yBAAyB,GAAG,kBAAkB,EAAE,CAAC;CACvD;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,MAAM,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xml-tokenizer",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "Straightforward and typesafe XML tokenizer that streams tokens through a callback mechanism",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",