@office-open/docx 0.11.0 → 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
@@ -77,9 +77,9 @@ 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)
@@ -90,32 +90,40 @@ await generateDocument(options, { compression: { xml: 0, media: 0 } });
90
90
  generateDocumentStream(options);
91
91
  ```
92
92
 
93
- **Create + toBuffer / toStream (end-to-end)**
93
+ **Create + toBuffer / toStream**
94
94
 
95
- | Scenario | Default sync | Default async | All STORE sync | All STORE async | Default stream | docx |
96
- | ------------------------------ | -----------: | ------------: | -------------: | --------------: | -------------: | ---------: |
97
- | Simple (2p + 1 img) | 868 ops/s | 562 ops/s | 2,334 ops/s | 2,312 ops/s | 13.9 ops/s | 71.4 ops/s |
98
- | Styled paragraphs (20) + 1 img | 944 ops/s | 567 ops/s | 2,720 ops/s | 2,494 ops/s | 13.0 ops/s | 84.1 ops/s |
99
- | Table (10x5) | 1,081 ops/s | 590 ops/s | 2,583 ops/s | 2,774 ops/s | 12.9 ops/s | 205 ops/s |
100
- | Full featured + 2 imgs | 777 ops/s | 488 ops/s | 1,433 ops/s | 1,645 ops/s | 11.1 ops/s | 49.7 ops/s |
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 |
101
105
 
102
106
  **Large Files — Create + toBuffer / toStream**
103
107
 
104
- | Scenario | Default sync | Default async | All STORE sync | All STORE async | Default stream | docx |
105
- | ------------------------------ | -----------: | ------------: | -------------: | --------------: | -------------: | ---------: |
106
- | 2000 paragraphs + 20 images | 107.9 ops/s | 83.9 ops/s | 112.9 ops/s | 105.3 ops/s | 8.52 ops/s | 2.66 ops/s |
107
- | 200x10 table | 215.8 ops/s | 173.7 ops/s | 215.2 ops/s | 218.4 ops/s | 6.30 ops/s | 33.2 ops/s |
108
- | 20 sections x 100p + 40 images | 83.8 ops/s | 67.4 ops/s | 103.4 ops/s | 103.8 ops/s | 3.14 ops/s | 1.67 ops/s |
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 |
109
116
 
110
117
  **Large File (~100MB) — Mixed Content**
111
118
 
112
119
  500 styled paragraphs + 38 mixed-size images (1-5MB, 100MB total) + 50x10 table.
113
120
 
114
- | Scenario | Default sync | Default async | All STORE sync | All STORE async | Default stream | docx |
115
- | ------------------------ | -----------: | ------------: | -------------: | --------------: | -------------: | ---------: |
116
- | Mixed (500p+38img+50x10) | 23.9 ops/s | 22.9 ops/s | 24.2 ops/s | 24.6 ops/s | 3.59 ops/s | 0.29 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 |
117
125
 
118
- **Stream column** = `generateDocumentStream` (default compression, fully drained). Streaming trades throughput for pipeability: each part is compressed in a Web Worker as it is produced, so a fixed per-part worker handoff dominates small documents — streaming targets memory footprint and piping (file / HTTP response), not peak ops/s.
126
+ **Stream** = `generateDocumentStream` (default compression, fully drained) it targets piping and a flat memory profile, not peak throughput.
119
127
 
120
128
  ## License
121
129