@office-open/docx 0.10.15 → 0.12.0

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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  ![npm downloads](https://img.shields.io/npm/dw/@office-open/docx)
5
5
  ![npm license](https://img.shields.io/npm/l/@office-open/docx)
6
6
 
7
- > Generate, parse, and patch .docx documents with a declarative TypeScript API. Works in Node.js and browsers.
7
+ > Create Word documents (.docx) in TypeScript and JavaScript — generate, parse, and patch from plain JSON, no Microsoft Office required. Built for AI agents and hand-written code alike; runs in Node.js, browsers, Deno, and Bun.
8
8
 
9
9
  ## Features
10
10
 
@@ -77,41 +77,53 @@ Check the [demo folder](./demo) for 100+ working examples covering every feature
77
77
 
78
78
  ## Benchmark
79
79
 
80
- Performance vs original `docx` (9.6.1) package (higher ops/s is better, Windows 11 / Node 24).
80
+ Performance vs the original `docx` (9.6.1) package (higher ops/s is better, Windows 11; each scenario runs under both Node 24 and Bun 1.4).
81
81
 
82
- **Default** = XML DEFLATE level 1 (SuperFast); media is split by type, matching MS Office Word — already-compressed formats (PNG/JPEG/GIF) are STOREd, the rest (EMF/WMF/BMP/TIFF/…) use DEFLATE level 6 / Normal (verified on a real MS Office file). **All STORE** = no compression (`{ compression: { xml: 0, media: 0 } }`). **docx** (async only) always uses DEFLATE for ALL entries including images (via JSZip, hardcoded, no STORE option).
82
+ **Default** = XML DEFLATE level 1; media matches MS Office Word — already-compressed formats (PNG/JPEG/GIF) are STOREd, the rest (EMF/WMF/BMP/TIFF/…) use DEFLATE level 6. **All STORE** = no compression (`{ compression: { xml: 0, media: 0 } }`). The `docx` package (async only) always DEFLATEs every entry including images, with no STORE option.
83
83
 
84
84
  ```typescript
85
85
  // Default (matches MS Office)
86
86
  await generateDocument(options);
87
87
  // All STORE (no compression)
88
88
  await generateDocument(options, { compression: { xml: 0, media: 0 } });
89
+ // Stream as ReadableStream<Uint8Array> (pipe to a file / HTTP response)
90
+ generateDocumentStream(options);
89
91
  ```
90
92
 
91
- **Create + toBuffer (end-to-end)**
92
-
93
- | Scenario | Default sync | Default async | All STORE sync | All STORE async | docx |
94
- | ------------------------------ | -----------: | ------------: | -------------: | --------------: | ---------: |
95
- | Simple (2p + 1 img) | 915 ops/s | 584 ops/s | 2,454 ops/s | 2,545 ops/s | 86.3 ops/s |
96
- | Styled paragraphs (20) + 1 img | 935 ops/s | 626 ops/s | 2,721 ops/s | 2,522 ops/s | 90.1 ops/s |
97
- | Table (10x5) | 1,164 ops/s | 659 ops/s | 2,743 ops/s | 2,821 ops/s | 227 ops/s |
98
- | Full featured + 2 imgs | 753 ops/s | 527 ops/s | 1,601 ops/s | 1,615 ops/s | 56.6 ops/s |
99
-
100
- **Large Files Create + toBuffer**
101
-
102
- | Scenario | Default sync | Default async | All STORE sync | All STORE async | docx |
103
- | ------------------------------ | -----------: | ------------: | -------------: | --------------: | ---------: |
104
- | 2000 paragraphs + 20 images | 85.4 ops/s | 77.1 ops/s | 90.5 ops/s | 86.4 ops/s | 2.95 ops/s |
105
- | 200x10 table | 194 ops/s | 175 ops/s | 220 ops/s | 222 ops/s | 33.9 ops/s |
106
- | 20 sections x 100p + 40 images | 80.5 ops/s | 66.2 ops/s | 89.7 ops/s | 91.7 ops/s | 1.80 ops/s |
93
+ **Create + toBuffer / toStream**
94
+
95
+ | Scenario | Runtime | Default sync | Default async | All STORE sync | All STORE async | Default stream | docx |
96
+ | ------------------------------ | ------- | ------------ | ------------- | -------------- | --------------- | -------------- | ---------- |
97
+ | Simple (2p + 1 img) | Node 24 | 905 ops/s | 1,311 ops/s | 2,478 ops/s | 2,985 ops/s | 10.1 ops/s | 91.2 ops/s |
98
+ | | Bun 1.4 | 2,471 ops/s | 758 ops/s | 5,323 ops/s | 5,246 ops/s | 384 ops/s | 63.7 ops/s |
99
+ | Styled paragraphs (20) + 1 img | Node 24 | 1,065 ops/s | 1,405 ops/s | 2,765 ops/s | 2,752 ops/s | 14.2 ops/s | 91.1 ops/s |
100
+ | | Bun 1.4 | 2,994 ops/s | 692 ops/s | 4,567 ops/s | 4,627 ops/s | 443 ops/s | 72.2 ops/s |
101
+ | Table (10x5) | Node 24 | 1,301 ops/s | 1,286 ops/s | 3,154 ops/s | 3,163 ops/s | 14.3 ops/s | 196 ops/s |
102
+ | | Bun 1.4 | 2,791 ops/s | 691 ops/s | 5,107 ops/s | 4,882 ops/s | 543 ops/s | 252 ops/s |
103
+ | Full featured + 2 imgs | Node 24 | 763 ops/s | 1,031 ops/s | 1,671 ops/s | 1,576 ops/s | 12.7 ops/s | 54.2 ops/s |
104
+ | | Bun 1.4 | 1,646 ops/s | 575 ops/s | 2,630 ops/s | 2,456 ops/s | 330 ops/s | 41.1 ops/s |
105
+
106
+ **Large Files Create + toBuffer / toStream**
107
+
108
+ | Scenario | Runtime | Default sync | Default async | All STORE sync | All STORE async | Default stream | docx |
109
+ | ------------------------------ | ------- | ------------ | ------------- | -------------- | --------------- | -------------- | ---------- |
110
+ | 2000 paragraphs + 20 images | Node 24 | 104.5 ops/s | 109.4 ops/s | 111.6 ops/s | 114.9 ops/s | 11.3 ops/s | 2.85 ops/s |
111
+ | | Bun 1.4 | 148.8 ops/s | 126.5 ops/s | 168.0 ops/s | 164.9 ops/s | 37.4 ops/s | 2.18 ops/s |
112
+ | 200x10 table | Node 24 | 252.4 ops/s | 247.3 ops/s | 282.1 ops/s | 288.7 ops/s | 13.7 ops/s | 35.6 ops/s |
113
+ | | Bun 1.4 | 372.0 ops/s | 272.4 ops/s | 441.5 ops/s | 405.6 ops/s | 169 ops/s | 44.5 ops/s |
114
+ | 20 sections x 100p + 40 images | Node 24 | 89.6 ops/s | 94.5 ops/s | 103.6 ops/s | 103.7 ops/s | 3.53 ops/s | 1.73 ops/s |
115
+ | | Bun 1.4 | 141.9 ops/s | 90.9 ops/s | 163.7 ops/s | 170.4 ops/s | 33.2 ops/s | 1.15 ops/s |
107
116
 
108
117
  **Large File (~100MB) — Mixed Content**
109
118
 
110
119
  500 styled paragraphs + 38 mixed-size images (1-5MB, 100MB total) + 50x10 table.
111
120
 
112
- | Scenario | Default sync | Default async | All STORE sync | All STORE async | docx |
113
- | ------------------------ | -----------: | ------------: | -------------: | --------------: | ---------: |
114
- | Mixed (500p+38img+50x10) | 23.7 ops/s | 21.8 ops/s | 23.4 ops/s | 24.5 ops/s | 0.30 ops/s |
121
+ | Scenario | Runtime | Default sync | Default async | All STORE sync | All STORE async | Default stream | docx |
122
+ | ------------------------ | ------- | ------------ | ------------- | -------------- | --------------- | -------------- | ---------- |
123
+ | Mixed (500p+38img+50x10) | Node 24 | 23.1 ops/s | 21.2 ops/s | 23.7 ops/s | 23.9 ops/s | 3.56 ops/s | 0.28 ops/s |
124
+ | | Bun 1.4 | 38.8 ops/s | 32.5 ops/s | 36.5 ops/s | 30.7 ops/s | 5.27 ops/s | 0.21 ops/s |
125
+
126
+ **Stream** = `generateDocumentStream` (default compression, fully drained) — it targets piping and a flat memory profile, not peak throughput.
115
127
 
116
128
  ## License
117
129