@office-open/xml 0.9.0 → 0.9.1

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.
package/dist/index.d.mts CHANGED
@@ -45,6 +45,18 @@ declare function escapeXml(str: string): string;
45
45
  * // => ' id="1" name="foo"'
46
46
  */
47
47
  declare function attrs(record: Record<string, string | number | boolean | undefined>): string;
48
+ /**
49
+ * Build an XML attribute string without escaping.
50
+ *
51
+ * Same as `attrs()` but skips `typeof` checks and `escapeXml` — use only when
52
+ * all values are known-safe (numbers, booleans, or strings free of `& " ' < >`).
53
+ * Avoids per-call array and `Object.keys()` allocation in hot loops.
54
+ *
55
+ * @example
56
+ * attrsRaw({ r: "A1", s: 5 })
57
+ * // => ' r="A1" s="5"'
58
+ */
59
+ declare function attrsRaw(record: Record<string, string | number | boolean | undefined>): string;
48
60
  /**
49
61
  * Build a self-closing XML element: `<tag attrStr/>`.
50
62
  * `attrStr` is a pre-serialized attribute string (from `attrs()`) or undefined.
@@ -72,4 +84,4 @@ declare function element(name: string, attrRecord?: Readonly<Record<string, stri
72
84
  /** Convert XML string to JSON string — xml-js compatible export */
73
85
  declare function xml2json(xml: string, options?: Xml2JsOptions): string;
74
86
  //#endregion
75
- export { type Attributes, type DeclarationAttributes, type Element, type ElementCompact, type ElementObject, type IgnoreOptions, type Js2XmlOptions, type Xml2JsOptions, type XmlAtom, type XmlAttrs, type XmlDesc, type XmlDescArray, type XmlObject, type XmlOption, allChildren, attr, attrBool, attrNum, attrs, childCount, childText, children, collectText, colorAttr, element, escapeXml, findChild, findDeep, hasChild, stringify as js2xml, stringify, json2xml, nativeTypeValue, parse, parse as xml2js, parseAttributes, selfCloseElement, textOf, toElement, unescapeXml, xml, xml2json };
87
+ export { type Attributes, type DeclarationAttributes, type Element, type ElementCompact, type ElementObject, type IgnoreOptions, type Js2XmlOptions, type Xml2JsOptions, type XmlAtom, type XmlAttrs, type XmlDesc, type XmlDescArray, type XmlObject, type XmlOption, allChildren, attr, attrBool, attrNum, attrs, attrsRaw, childCount, childText, children, collectText, colorAttr, element, escapeXml, findChild, findDeep, hasChild, stringify as js2xml, stringify, json2xml, nativeTypeValue, parse, parse as xml2js, parseAttributes, selfCloseElement, textOf, toElement, unescapeXml, xml, xml2json };
package/dist/index.mjs CHANGED
@@ -50,6 +50,25 @@ function attrs(record) {
50
50
  return parts.join("");
51
51
  }
52
52
  /**
53
+ * Build an XML attribute string without escaping.
54
+ *
55
+ * Same as `attrs()` but skips `typeof` checks and `escapeXml` — use only when
56
+ * all values are known-safe (numbers, booleans, or strings free of `& " ' < >`).
57
+ * Avoids per-call array and `Object.keys()` allocation in hot loops.
58
+ *
59
+ * @example
60
+ * attrsRaw({ r: "A1", s: 5 })
61
+ * // => ' r="A1" s="5"'
62
+ */
63
+ function attrsRaw(record) {
64
+ let s = "";
65
+ for (const key in record) {
66
+ const v = record[key];
67
+ if (v !== void 0) s += ` ${key}="${v}"`;
68
+ }
69
+ return s;
70
+ }
71
+ /**
53
72
  * Build a self-closing XML element: `<tag attrStr/>`.
54
73
  * `attrStr` is a pre-serialized attribute string (from `attrs()`) or undefined.
55
74
  */
@@ -580,4 +599,4 @@ function xml2json(xml, options) {
580
599
  return JSON.stringify(parse(xml, options));
581
600
  }
582
601
  //#endregion
583
- export { allChildren, attr, attrBool, attrNum, attrs, childCount, childText, children, collectText, colorAttr, element, escapeXml, findChild, findDeep, hasChild, stringify as js2xml, stringify, json2xml, nativeTypeValue, parse, parse as xml2js, parseAttributes, selfCloseElement, textOf, toElement, unescapeXml, xml, xml2json };
602
+ export { allChildren, attr, attrBool, attrNum, attrs, attrsRaw, childCount, childText, children, collectText, colorAttr, element, escapeXml, findChild, findDeep, hasChild, stringify as js2xml, stringify, json2xml, nativeTypeValue, parse, parse as xml2js, parseAttributes, selfCloseElement, textOf, toElement, unescapeXml, xml, xml2json };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@office-open/xml",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "XML parsing and serialization for Office Open XML. Zero dependencies, drop-in replacement for xml + xml-js.",
5
5
  "keywords": [
6
6
  "office-open",