@lowlighter/xml 5.2.1 → 5.3.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/LICENSE +21 -0
- package/README.md +33 -0
- package/_types.ts +37 -0
- package/_types_test.ts +1 -0
- package/bench/assets/medium.xml +291 -0
- package/bench/assets/small.xml +7 -0
- package/bench/bench.ts +17 -0
- package/deno.jsonc +93 -0
- package/deno.lock +86 -0
- package/mod.mjs +1 -1
- package/mod.ts +3 -0
- package/package.json +7 -1
- package/parse.mjs +1 -1
- package/parse.ts +445 -0
- package/parse_test.ts +1303 -0
- package/stringify.ts +241 -0
- package/stringify_test.ts +284 -0
- package/wasm_xml_parser/Cargo.lock +159 -0
- package/wasm_xml_parser/Cargo.toml +16 -0
- package/wasm_xml_parser/src/lib.rs +232 -0
- package/wasm_xml_parser/wasm_xml_parser.js +2 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Simon Lecoq
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# 📃 XML parser and stringifier
|
|
2
|
+
|
|
3
|
+
[](https://jsr.io/@libs/xml) [](https://jsr.io/@libs/xml)
|
|
4
|
+
[](https://www.npmjs.com/package/@lowlighter/xml) [](https://libs-coverage.lecoq.io/xml)
|
|
5
|
+
|
|
6
|
+
- [`🦕 Playground`](https://libs.lecoq.io/xml)
|
|
7
|
+
- [`📚 Documentation`](https://jsr.io/@libs/xml/doc)
|
|
8
|
+
|
|
9
|
+
## ✨ Features
|
|
10
|
+
|
|
11
|
+
- Based on [quick-xml](https://github.com/tafia/quick-xml) rust package (compiled to WASM)
|
|
12
|
+
- Support `XML.parse` and `XML.stringify`
|
|
13
|
+
- Support `<!-- -->` comments
|
|
14
|
+
- Support XML entities (`&`, `&`, `&`, ...)
|
|
15
|
+
- Support mixed content (text and nodes)
|
|
16
|
+
- Large output transformation options
|
|
17
|
+
- Auto-flattening of nodes with a single child, text or attributes
|
|
18
|
+
- Auto-revival of `boolean`, `number`, etc.
|
|
19
|
+
- Auto-group same-named nodes into arrays
|
|
20
|
+
- Formatting options (indentation, break lines, etc.)
|
|
21
|
+
- Custom `reviver` and `replacer` functions
|
|
22
|
+
- Metadata stored into non-enumerable properties for advanced usage
|
|
23
|
+
|
|
24
|
+
## 📜 License and credits
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
Copyright (c) Lecoq Simon <@lowlighter>. (MIT License)
|
|
28
|
+
https://github.com/lowlighter/libs/blob/main/LICENSE
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This library used to be published at [deno.land/x/xml](https://deno.land/x/xml) and [jsr.io/@lowlighter/xml](https://jsr.io/@lowlighter/xml). It was moved into [jsr.io/@libs/xml](https://jsr.io/@libs/xml) starting version `5.0.0`.
|
|
32
|
+
|
|
33
|
+
Version prior to `5.0.0` used to be fully written in TypeScript but it was rewritten in Rust to improve performances and support more features.
|
package/_types.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** XML text node. */
|
|
2
|
+
export type xml_text = {
|
|
3
|
+
/** Parent node. */
|
|
4
|
+
readonly ["~parent"]: xml_node
|
|
5
|
+
/** Tag name (`~text` for text nodes, `~cdata` for CDATA nodes and `~comment` for comment nodes). */
|
|
6
|
+
readonly ["~name"]: string
|
|
7
|
+
/** Text content. */
|
|
8
|
+
["#text"]: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** XML node. */
|
|
12
|
+
export type xml_node = {
|
|
13
|
+
/** Tag name (`~xml` for XML prolog, other nodes will be given their respective tag name). */
|
|
14
|
+
readonly ["~name"]: string
|
|
15
|
+
/** Child nodes. */
|
|
16
|
+
readonly ["~children"]: Array<xml_node | xml_text>
|
|
17
|
+
/** Comments. */
|
|
18
|
+
readonly ["#comments"]?: Array<string>
|
|
19
|
+
/** Text content. */
|
|
20
|
+
readonly ["#text"]: string
|
|
21
|
+
// Signature
|
|
22
|
+
[key: string]: unknown
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** XML document. */
|
|
26
|
+
export type xml_document = xml_node & {
|
|
27
|
+
/** XML version. */
|
|
28
|
+
["@version"]?: `1.${number}`
|
|
29
|
+
/** XML character encoding. */
|
|
30
|
+
["@encoding"]?: string
|
|
31
|
+
/** XML standalone. */
|
|
32
|
+
["@standalone"]?: "yes" | "no"
|
|
33
|
+
/** XML doctype. */
|
|
34
|
+
["#doctype"]?: xml_node
|
|
35
|
+
/** XML instructions. */
|
|
36
|
+
["#instructions"]?: { [key: string]: xml_node | Array<xml_node> }
|
|
37
|
+
}
|
package/_types_test.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./_types.ts"
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
<!-- From https://www.w3schools.com/xml/plant_catalog.xml -->
|
|
2
|
+
<CATALOG>
|
|
3
|
+
<PLANT>
|
|
4
|
+
<COMMON>Bloodroot</COMMON>
|
|
5
|
+
<BOTANICAL>Sanguinaria canadensis</BOTANICAL>
|
|
6
|
+
<ZONE>4</ZONE>
|
|
7
|
+
<LIGHT>Mostly Shady</LIGHT>
|
|
8
|
+
<PRICE>$2.44</PRICE>
|
|
9
|
+
<AVAILABILITY>031599</AVAILABILITY>
|
|
10
|
+
</PLANT>
|
|
11
|
+
<PLANT>
|
|
12
|
+
<COMMON>Columbine</COMMON>
|
|
13
|
+
<BOTANICAL>Aquilegia canadensis</BOTANICAL>
|
|
14
|
+
<ZONE>3</ZONE>
|
|
15
|
+
<LIGHT>Mostly Shady</LIGHT>
|
|
16
|
+
<PRICE>$9.37</PRICE>
|
|
17
|
+
<AVAILABILITY>030699</AVAILABILITY>
|
|
18
|
+
</PLANT>
|
|
19
|
+
<PLANT>
|
|
20
|
+
<COMMON>Marsh Marigold</COMMON>
|
|
21
|
+
<BOTANICAL>Caltha palustris</BOTANICAL>
|
|
22
|
+
<ZONE>4</ZONE>
|
|
23
|
+
<LIGHT>Mostly Sunny</LIGHT>
|
|
24
|
+
<PRICE>$6.81</PRICE>
|
|
25
|
+
<AVAILABILITY>051799</AVAILABILITY>
|
|
26
|
+
</PLANT>
|
|
27
|
+
<PLANT>
|
|
28
|
+
<COMMON>Cowslip</COMMON>
|
|
29
|
+
<BOTANICAL>Caltha palustris</BOTANICAL>
|
|
30
|
+
<ZONE>4</ZONE>
|
|
31
|
+
<LIGHT>Mostly Shady</LIGHT>
|
|
32
|
+
<PRICE>$9.90</PRICE>
|
|
33
|
+
<AVAILABILITY>030699</AVAILABILITY>
|
|
34
|
+
</PLANT>
|
|
35
|
+
<PLANT>
|
|
36
|
+
<COMMON>Dutchman's-Breeches</COMMON>
|
|
37
|
+
<BOTANICAL>Dicentra cucullaria</BOTANICAL>
|
|
38
|
+
<ZONE>3</ZONE>
|
|
39
|
+
<LIGHT>Mostly Shady</LIGHT>
|
|
40
|
+
<PRICE>$6.44</PRICE>
|
|
41
|
+
<AVAILABILITY>012099</AVAILABILITY>
|
|
42
|
+
</PLANT>
|
|
43
|
+
<PLANT>
|
|
44
|
+
<COMMON>Ginger, Wild</COMMON>
|
|
45
|
+
<BOTANICAL>Asarum canadense</BOTANICAL>
|
|
46
|
+
<ZONE>3</ZONE>
|
|
47
|
+
<LIGHT>Mostly Shady</LIGHT>
|
|
48
|
+
<PRICE>$9.03</PRICE>
|
|
49
|
+
<AVAILABILITY>041899</AVAILABILITY>
|
|
50
|
+
</PLANT>
|
|
51
|
+
<PLANT>
|
|
52
|
+
<COMMON>Hepatica</COMMON>
|
|
53
|
+
<BOTANICAL>Hepatica americana</BOTANICAL>
|
|
54
|
+
<ZONE>4</ZONE>
|
|
55
|
+
<LIGHT>Mostly Shady</LIGHT>
|
|
56
|
+
<PRICE>$4.45</PRICE>
|
|
57
|
+
<AVAILABILITY>012699</AVAILABILITY>
|
|
58
|
+
</PLANT>
|
|
59
|
+
<PLANT>
|
|
60
|
+
<COMMON>Liverleaf</COMMON>
|
|
61
|
+
<BOTANICAL>Hepatica americana</BOTANICAL>
|
|
62
|
+
<ZONE>4</ZONE>
|
|
63
|
+
<LIGHT>Mostly Shady</LIGHT>
|
|
64
|
+
<PRICE>$3.99</PRICE>
|
|
65
|
+
<AVAILABILITY>010299</AVAILABILITY>
|
|
66
|
+
</PLANT>
|
|
67
|
+
<PLANT>
|
|
68
|
+
<COMMON>Jack-In-The-Pulpit</COMMON>
|
|
69
|
+
<BOTANICAL>Arisaema triphyllum</BOTANICAL>
|
|
70
|
+
<ZONE>4</ZONE>
|
|
71
|
+
<LIGHT>Mostly Shady</LIGHT>
|
|
72
|
+
<PRICE>$3.23</PRICE>
|
|
73
|
+
<AVAILABILITY>020199</AVAILABILITY>
|
|
74
|
+
</PLANT>
|
|
75
|
+
<PLANT>
|
|
76
|
+
<COMMON>Mayapple</COMMON>
|
|
77
|
+
<BOTANICAL>Podophyllum peltatum</BOTANICAL>
|
|
78
|
+
<ZONE>3</ZONE>
|
|
79
|
+
<LIGHT>Mostly Shady</LIGHT>
|
|
80
|
+
<PRICE>$2.98</PRICE>
|
|
81
|
+
<AVAILABILITY>060599</AVAILABILITY>
|
|
82
|
+
</PLANT>
|
|
83
|
+
<PLANT>
|
|
84
|
+
<COMMON>Phlox, Woodland</COMMON>
|
|
85
|
+
<BOTANICAL>Phlox divaricata</BOTANICAL>
|
|
86
|
+
<ZONE>3</ZONE>
|
|
87
|
+
<LIGHT>Sun or Shade</LIGHT>
|
|
88
|
+
<PRICE>$2.80</PRICE>
|
|
89
|
+
<AVAILABILITY>012299</AVAILABILITY>
|
|
90
|
+
</PLANT>
|
|
91
|
+
<PLANT>
|
|
92
|
+
<COMMON>Phlox, Blue</COMMON>
|
|
93
|
+
<BOTANICAL>Phlox divaricata</BOTANICAL>
|
|
94
|
+
<ZONE>3</ZONE>
|
|
95
|
+
<LIGHT>Sun or Shade</LIGHT>
|
|
96
|
+
<PRICE>$5.59</PRICE>
|
|
97
|
+
<AVAILABILITY>021699</AVAILABILITY>
|
|
98
|
+
</PLANT>
|
|
99
|
+
<PLANT>
|
|
100
|
+
<COMMON>Spring-Beauty</COMMON>
|
|
101
|
+
<BOTANICAL>Claytonia Virginica</BOTANICAL>
|
|
102
|
+
<ZONE>7</ZONE>
|
|
103
|
+
<LIGHT>Mostly Shady</LIGHT>
|
|
104
|
+
<PRICE>$6.59</PRICE>
|
|
105
|
+
<AVAILABILITY>020199</AVAILABILITY>
|
|
106
|
+
</PLANT>
|
|
107
|
+
<PLANT>
|
|
108
|
+
<COMMON>Trillium</COMMON>
|
|
109
|
+
<BOTANICAL>Trillium grandiflorum</BOTANICAL>
|
|
110
|
+
<ZONE>5</ZONE>
|
|
111
|
+
<LIGHT>Sun or Shade</LIGHT>
|
|
112
|
+
<PRICE>$3.90</PRICE>
|
|
113
|
+
<AVAILABILITY>042999</AVAILABILITY>
|
|
114
|
+
</PLANT>
|
|
115
|
+
<PLANT>
|
|
116
|
+
<COMMON>Wake Robin</COMMON>
|
|
117
|
+
<BOTANICAL>Trillium grandiflorum</BOTANICAL>
|
|
118
|
+
<ZONE>5</ZONE>
|
|
119
|
+
<LIGHT>Sun or Shade</LIGHT>
|
|
120
|
+
<PRICE>$3.20</PRICE>
|
|
121
|
+
<AVAILABILITY>022199</AVAILABILITY>
|
|
122
|
+
</PLANT>
|
|
123
|
+
<PLANT>
|
|
124
|
+
<COMMON>Violet, Dog-Tooth</COMMON>
|
|
125
|
+
<BOTANICAL>Erythronium americanum</BOTANICAL>
|
|
126
|
+
<ZONE>4</ZONE>
|
|
127
|
+
<LIGHT>Shade</LIGHT>
|
|
128
|
+
<PRICE>$9.04</PRICE>
|
|
129
|
+
<AVAILABILITY>020199</AVAILABILITY>
|
|
130
|
+
</PLANT>
|
|
131
|
+
<PLANT>
|
|
132
|
+
<COMMON>Trout Lily</COMMON>
|
|
133
|
+
<BOTANICAL>Erythronium americanum</BOTANICAL>
|
|
134
|
+
<ZONE>4</ZONE>
|
|
135
|
+
<LIGHT>Shade</LIGHT>
|
|
136
|
+
<PRICE>$6.94</PRICE>
|
|
137
|
+
<AVAILABILITY>032499</AVAILABILITY>
|
|
138
|
+
</PLANT>
|
|
139
|
+
<PLANT>
|
|
140
|
+
<COMMON>Adder's-Tongue</COMMON>
|
|
141
|
+
<BOTANICAL>Erythronium americanum</BOTANICAL>
|
|
142
|
+
<ZONE>4</ZONE>
|
|
143
|
+
<LIGHT>Shade</LIGHT>
|
|
144
|
+
<PRICE>$9.58</PRICE>
|
|
145
|
+
<AVAILABILITY>041399</AVAILABILITY>
|
|
146
|
+
</PLANT>
|
|
147
|
+
<PLANT>
|
|
148
|
+
<COMMON>Anemone</COMMON>
|
|
149
|
+
<BOTANICAL>Anemone blanda</BOTANICAL>
|
|
150
|
+
<ZONE>6</ZONE>
|
|
151
|
+
<LIGHT>Mostly Shady</LIGHT>
|
|
152
|
+
<PRICE>$8.86</PRICE>
|
|
153
|
+
<AVAILABILITY>122698</AVAILABILITY>
|
|
154
|
+
</PLANT>
|
|
155
|
+
<PLANT>
|
|
156
|
+
<COMMON>Grecian Windflower</COMMON>
|
|
157
|
+
<BOTANICAL>Anemone blanda</BOTANICAL>
|
|
158
|
+
<ZONE>6</ZONE>
|
|
159
|
+
<LIGHT>Mostly Shady</LIGHT>
|
|
160
|
+
<PRICE>$9.16</PRICE>
|
|
161
|
+
<AVAILABILITY>071099</AVAILABILITY>
|
|
162
|
+
</PLANT>
|
|
163
|
+
<PLANT>
|
|
164
|
+
<COMMON>Bee Balm</COMMON>
|
|
165
|
+
<BOTANICAL>Monarda didyma</BOTANICAL>
|
|
166
|
+
<ZONE>4</ZONE>
|
|
167
|
+
<LIGHT>Shade</LIGHT>
|
|
168
|
+
<PRICE>$4.59</PRICE>
|
|
169
|
+
<AVAILABILITY>050399</AVAILABILITY>
|
|
170
|
+
</PLANT>
|
|
171
|
+
<PLANT>
|
|
172
|
+
<COMMON>Bergamot</COMMON>
|
|
173
|
+
<BOTANICAL>Monarda didyma</BOTANICAL>
|
|
174
|
+
<ZONE>4</ZONE>
|
|
175
|
+
<LIGHT>Shade</LIGHT>
|
|
176
|
+
<PRICE>$7.16</PRICE>
|
|
177
|
+
<AVAILABILITY>042799</AVAILABILITY>
|
|
178
|
+
</PLANT>
|
|
179
|
+
<PLANT>
|
|
180
|
+
<COMMON>Black-Eyed Susan</COMMON>
|
|
181
|
+
<BOTANICAL>Rudbeckia hirta</BOTANICAL>
|
|
182
|
+
<ZONE>Annual</ZONE>
|
|
183
|
+
<LIGHT>Sunny</LIGHT>
|
|
184
|
+
<PRICE>$9.80</PRICE>
|
|
185
|
+
<AVAILABILITY>061899</AVAILABILITY>
|
|
186
|
+
</PLANT>
|
|
187
|
+
<PLANT>
|
|
188
|
+
<COMMON>Buttercup</COMMON>
|
|
189
|
+
<BOTANICAL>Ranunculus</BOTANICAL>
|
|
190
|
+
<ZONE>4</ZONE>
|
|
191
|
+
<LIGHT>Shade</LIGHT>
|
|
192
|
+
<PRICE>$2.57</PRICE>
|
|
193
|
+
<AVAILABILITY>061099</AVAILABILITY>
|
|
194
|
+
</PLANT>
|
|
195
|
+
<PLANT>
|
|
196
|
+
<COMMON>Crowfoot</COMMON>
|
|
197
|
+
<BOTANICAL>Ranunculus</BOTANICAL>
|
|
198
|
+
<ZONE>4</ZONE>
|
|
199
|
+
<LIGHT>Shade</LIGHT>
|
|
200
|
+
<PRICE>$9.34</PRICE>
|
|
201
|
+
<AVAILABILITY>040399</AVAILABILITY>
|
|
202
|
+
</PLANT>
|
|
203
|
+
<PLANT>
|
|
204
|
+
<COMMON>Butterfly Weed</COMMON>
|
|
205
|
+
<BOTANICAL>Asclepias tuberosa</BOTANICAL>
|
|
206
|
+
<ZONE>Annual</ZONE>
|
|
207
|
+
<LIGHT>Sunny</LIGHT>
|
|
208
|
+
<PRICE>$2.78</PRICE>
|
|
209
|
+
<AVAILABILITY>063099</AVAILABILITY>
|
|
210
|
+
</PLANT>
|
|
211
|
+
<PLANT>
|
|
212
|
+
<COMMON>Cinquefoil</COMMON>
|
|
213
|
+
<BOTANICAL>Potentilla</BOTANICAL>
|
|
214
|
+
<ZONE>Annual</ZONE>
|
|
215
|
+
<LIGHT>Shade</LIGHT>
|
|
216
|
+
<PRICE>$7.06</PRICE>
|
|
217
|
+
<AVAILABILITY>052599</AVAILABILITY>
|
|
218
|
+
</PLANT>
|
|
219
|
+
<PLANT>
|
|
220
|
+
<COMMON>Primrose</COMMON>
|
|
221
|
+
<BOTANICAL>Oenothera</BOTANICAL>
|
|
222
|
+
<ZONE>3 - 5</ZONE>
|
|
223
|
+
<LIGHT>Sunny</LIGHT>
|
|
224
|
+
<PRICE>$6.56</PRICE>
|
|
225
|
+
<AVAILABILITY>013099</AVAILABILITY>
|
|
226
|
+
</PLANT>
|
|
227
|
+
<PLANT>
|
|
228
|
+
<COMMON>Gentian</COMMON>
|
|
229
|
+
<BOTANICAL>Gentiana</BOTANICAL>
|
|
230
|
+
<ZONE>4</ZONE>
|
|
231
|
+
<LIGHT>Sun or Shade</LIGHT>
|
|
232
|
+
<PRICE>$7.81</PRICE>
|
|
233
|
+
<AVAILABILITY>051899</AVAILABILITY>
|
|
234
|
+
</PLANT>
|
|
235
|
+
<PLANT>
|
|
236
|
+
<COMMON>Blue Gentian</COMMON>
|
|
237
|
+
<BOTANICAL>Gentiana</BOTANICAL>
|
|
238
|
+
<ZONE>4</ZONE>
|
|
239
|
+
<LIGHT>Sun or Shade</LIGHT>
|
|
240
|
+
<PRICE>$8.56</PRICE>
|
|
241
|
+
<AVAILABILITY>050299</AVAILABILITY>
|
|
242
|
+
</PLANT>
|
|
243
|
+
<PLANT>
|
|
244
|
+
<COMMON>Jacob's Ladder</COMMON>
|
|
245
|
+
<BOTANICAL>Polemonium caeruleum</BOTANICAL>
|
|
246
|
+
<ZONE>Annual</ZONE>
|
|
247
|
+
<LIGHT>Shade</LIGHT>
|
|
248
|
+
<PRICE>$9.26</PRICE>
|
|
249
|
+
<AVAILABILITY>022199</AVAILABILITY>
|
|
250
|
+
</PLANT>
|
|
251
|
+
<PLANT>
|
|
252
|
+
<COMMON>Greek Valerian</COMMON>
|
|
253
|
+
<BOTANICAL>Polemonium caeruleum</BOTANICAL>
|
|
254
|
+
<ZONE>Annual</ZONE>
|
|
255
|
+
<LIGHT>Shade</LIGHT>
|
|
256
|
+
<PRICE>$4.36</PRICE>
|
|
257
|
+
<AVAILABILITY>071499</AVAILABILITY>
|
|
258
|
+
</PLANT>
|
|
259
|
+
<PLANT>
|
|
260
|
+
<COMMON>California Poppy</COMMON>
|
|
261
|
+
<BOTANICAL>Eschscholzia californica</BOTANICAL>
|
|
262
|
+
<ZONE>Annual</ZONE>
|
|
263
|
+
<LIGHT>Sun</LIGHT>
|
|
264
|
+
<PRICE>$7.89</PRICE>
|
|
265
|
+
<AVAILABILITY>032799</AVAILABILITY>
|
|
266
|
+
</PLANT>
|
|
267
|
+
<PLANT>
|
|
268
|
+
<COMMON>Shooting Star</COMMON>
|
|
269
|
+
<BOTANICAL>Dodecatheon</BOTANICAL>
|
|
270
|
+
<ZONE>Annual</ZONE>
|
|
271
|
+
<LIGHT>Mostly Shady</LIGHT>
|
|
272
|
+
<PRICE>$8.60</PRICE>
|
|
273
|
+
<AVAILABILITY>051399</AVAILABILITY>
|
|
274
|
+
</PLANT>
|
|
275
|
+
<PLANT>
|
|
276
|
+
<COMMON>Snakeroot</COMMON>
|
|
277
|
+
<BOTANICAL>Cimicifuga</BOTANICAL>
|
|
278
|
+
<ZONE>Annual</ZONE>
|
|
279
|
+
<LIGHT>Shade</LIGHT>
|
|
280
|
+
<PRICE>$5.63</PRICE>
|
|
281
|
+
<AVAILABILITY>071199</AVAILABILITY>
|
|
282
|
+
</PLANT>
|
|
283
|
+
<PLANT>
|
|
284
|
+
<COMMON>Cardinal Flower</COMMON>
|
|
285
|
+
<BOTANICAL>Lobelia cardinalis</BOTANICAL>
|
|
286
|
+
<ZONE>2</ZONE>
|
|
287
|
+
<LIGHT>Shade</LIGHT>
|
|
288
|
+
<PRICE>$3.02</PRICE>
|
|
289
|
+
<AVAILABILITY>022299</AVAILABILITY>
|
|
290
|
+
</PLANT>
|
|
291
|
+
</CATALOG>
|
package/bench/bench.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { expandGlob } from "@std/fs/expand-glob"
|
|
2
|
+
import { parse } from "../mod.ts"
|
|
3
|
+
import { parse as parse_v5 } from "jsr:@libs/xml@5.0.2/parse"
|
|
4
|
+
import { parse as parse_v4 } from "https://deno.land/x/xml@4.0.0/parse.ts"
|
|
5
|
+
import { parse as parse_v3 } from "https://deno.land/x/xml@3.0.2/parse.ts"
|
|
6
|
+
|
|
7
|
+
for await (const { name, path } of expandGlob("**/!(x-)*.xml", { globstar: true })) {
|
|
8
|
+
const { size } = await (await Deno.open(path)).stat()
|
|
9
|
+
for (const [func, f] of Object.entries({ parse, parse_v5, parse_v4, parse_v3 })) {
|
|
10
|
+
Deno.bench(`${func}(): ${name}, ${size}b)`, async function (t) {
|
|
11
|
+
const content = await Deno.readTextFile(path)
|
|
12
|
+
t.start()
|
|
13
|
+
f(content)
|
|
14
|
+
t.end()
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
}
|
package/deno.jsonc
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"icon": "📃",
|
|
3
|
+
"name": "@libs/xml",
|
|
4
|
+
"version": "5.3.0",
|
|
5
|
+
"description": "XML parser/stringifier with no dependencies.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"xml",
|
|
8
|
+
"parser",
|
|
9
|
+
"stringifier",
|
|
10
|
+
"esm"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT License",
|
|
13
|
+
"author": "lowlighter (Simon Lecoq)",
|
|
14
|
+
"funding": "https://github.com/sponsors/lowlighter",
|
|
15
|
+
"homepage": "https://github.com/lowlighter/libs",
|
|
16
|
+
"playground": "https://libs.lecoq.io/xml",
|
|
17
|
+
"supported": [
|
|
18
|
+
"deno",
|
|
19
|
+
"node",
|
|
20
|
+
"bun",
|
|
21
|
+
"cloudflare-workers",
|
|
22
|
+
"browsers"
|
|
23
|
+
],
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/lowlighter/libs.git"
|
|
27
|
+
},
|
|
28
|
+
"npm": true,
|
|
29
|
+
"exports": {
|
|
30
|
+
".": "./mod.ts",
|
|
31
|
+
"./parse": "./parse.ts",
|
|
32
|
+
"./stringify": "./stringify.ts"
|
|
33
|
+
},
|
|
34
|
+
"imports": {
|
|
35
|
+
"@std/fs/expand-glob": "jsr:@std/fs@0.229.1/expand-glob",
|
|
36
|
+
"@std/path/from-file-url": "jsr:@std/path@0.225.1/from-file-url",
|
|
37
|
+
"@std/fs/exists": "jsr:@std/fs@0.229.1/exists",
|
|
38
|
+
"@libs/typing": "jsr:@libs/typing@2",
|
|
39
|
+
"@libs/testing": "jsr:@libs/testing@1"
|
|
40
|
+
},
|
|
41
|
+
"test:permissions": {
|
|
42
|
+
"read": true,
|
|
43
|
+
"env": [
|
|
44
|
+
"CI"
|
|
45
|
+
],
|
|
46
|
+
"write": [
|
|
47
|
+
"bench"
|
|
48
|
+
],
|
|
49
|
+
"run": [
|
|
50
|
+
"deno",
|
|
51
|
+
"node",
|
|
52
|
+
"bun",
|
|
53
|
+
"npx"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"tasks": {
|
|
57
|
+
"build": "deno run --allow-read --allow-net --allow-env --allow-write --allow-run jsr:@libs/bundle/wasm/cli/build --auto-install --banner='https://github.com/lowlighter/libs' wasm_xml_parser",
|
|
58
|
+
"test": "deno test --allow-read --allow-env=CI --allow-write=bench --allow-run=deno,node,bun,npx --no-prompt --coverage --clean --trace-leaks --doc",
|
|
59
|
+
"dev": "deno fmt && deno task test --filter='/^\\[deno\\]/' && deno coverage --exclude=.js --detailed && deno lint && deno publish --dry-run --quiet --allow-dirty",
|
|
60
|
+
"dev:future": "DENO_FUTURE=1 && deno task dev",
|
|
61
|
+
"coverage": "deno task test --filter='/^\\[deno\\]/' --quiet && deno coverage --exclude=.js",
|
|
62
|
+
"bench": "deno bench --allow-read --allow-write=bench",
|
|
63
|
+
"ci": "deno fmt --check && deno task test --filter='/^\\[node|bun \\]/' --quiet && deno coverage --exclude=.js && deno lint",
|
|
64
|
+
"ci:coverage": "deno task coverage --html && sleep 1 && mkdir -p ../coverage && rm -rf ../coverage/xml && mv coverage/html ../coverage/xml"
|
|
65
|
+
},
|
|
66
|
+
"lint": {
|
|
67
|
+
"rules": {
|
|
68
|
+
"include": [
|
|
69
|
+
"no-throw-literal",
|
|
70
|
+
"no-eval",
|
|
71
|
+
"eqeqeq",
|
|
72
|
+
"ban-untagged-todo"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
"exclude": [
|
|
76
|
+
"**/wasm_*",
|
|
77
|
+
"**/*.mjs"
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
"fmt": {
|
|
81
|
+
"lineWidth": 280,
|
|
82
|
+
"semiColons": false,
|
|
83
|
+
"exclude": [
|
|
84
|
+
"coverage",
|
|
85
|
+
"**/coverage",
|
|
86
|
+
"**/node_modules",
|
|
87
|
+
"**/package.json",
|
|
88
|
+
"**/package-lock.json",
|
|
89
|
+
"**/wasm_*",
|
|
90
|
+
"**/*.mjs"
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
}
|
package/deno.lock
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "3",
|
|
3
|
+
"packages": {
|
|
4
|
+
"specifiers": {
|
|
5
|
+
"jsr:@libs/testing@1": "jsr:@libs/testing@1.0.4",
|
|
6
|
+
"jsr:@libs/typing@2": "jsr:@libs/typing@2.0.3",
|
|
7
|
+
"jsr:@std/assert@^0.224.0": "jsr:@std/assert@0.224.0",
|
|
8
|
+
"jsr:@std/assert@^0.225.2": "jsr:@std/assert@0.225.3",
|
|
9
|
+
"jsr:@std/expect@0.224.0": "jsr:@std/expect@0.224.0",
|
|
10
|
+
"jsr:@std/fmt@^0.224.0": "jsr:@std/fmt@0.224.0",
|
|
11
|
+
"jsr:@std/fs@0.229.1": "jsr:@std/fs@0.229.1",
|
|
12
|
+
"jsr:@std/internal@^0.224.0": "jsr:@std/internal@0.224.0",
|
|
13
|
+
"jsr:@std/path@0.225.1": "jsr:@std/path@0.225.1",
|
|
14
|
+
"jsr:@std/path@^0.225.1": "jsr:@std/path@0.225.1",
|
|
15
|
+
"npm:@types/node": "npm:@types/node@18.16.19"
|
|
16
|
+
},
|
|
17
|
+
"jsr": {
|
|
18
|
+
"@libs/testing@1.0.4": {
|
|
19
|
+
"integrity": "9e3d28f5458a68435b49b870f8a2137ae79a09d2f10f16c4a6603d6ef7bf3873",
|
|
20
|
+
"dependencies": [
|
|
21
|
+
"jsr:@std/expect@0.224.0",
|
|
22
|
+
"jsr:@std/path@0.225.1"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"@libs/typing@2.0.3": {
|
|
26
|
+
"integrity": "e2fb7b9f4a09ffbe322377e05a16dfd48e04249ed667e4c9c06ca166c48b379e"
|
|
27
|
+
},
|
|
28
|
+
"@std/assert@0.224.0": {
|
|
29
|
+
"integrity": "8643233ec7aec38a940a8264a6e3eed9bfa44e7a71cc6b3c8874213ff401967f"
|
|
30
|
+
},
|
|
31
|
+
"@std/assert@0.225.3": {
|
|
32
|
+
"integrity": "b3c2847aecf6955b50644cdb9cf072004ea3d1998dd7579fc0acb99dbb23bd4f"
|
|
33
|
+
},
|
|
34
|
+
"@std/expect@0.224.0": {
|
|
35
|
+
"integrity": "54bc071f7edcbd7bb4531f913e466e5ec3642f401dc3771fe5975f0693f25969",
|
|
36
|
+
"dependencies": [
|
|
37
|
+
"jsr:@std/assert@^0.224.0",
|
|
38
|
+
"jsr:@std/fmt@^0.224.0",
|
|
39
|
+
"jsr:@std/internal@^0.224.0"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"@std/fmt@0.224.0": {
|
|
43
|
+
"integrity": "e20e9a2312a8b5393272c26191c0a68eda8d2c4b08b046bad1673148f1d69851"
|
|
44
|
+
},
|
|
45
|
+
"@std/fs@0.229.1": {
|
|
46
|
+
"integrity": "38d3fb31f0ca0a8c1118e039939188f32e291a3f7f17dc0868fec22024bdfadd",
|
|
47
|
+
"dependencies": [
|
|
48
|
+
"jsr:@std/assert@^0.225.2",
|
|
49
|
+
"jsr:@std/path@^0.225.1"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"@std/internal@0.224.0": {
|
|
53
|
+
"integrity": "afc50644f9cdf4495eeb80523a8f6d27226b4b36c45c7c195dfccad4b8509291"
|
|
54
|
+
},
|
|
55
|
+
"@std/path@0.225.1": {
|
|
56
|
+
"integrity": "8c3220635a73730eb51fe43de9e10b79e2724a5bb8638b9355d35ae012fd9429"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"npm": {
|
|
60
|
+
"@types/node@18.16.19": {
|
|
61
|
+
"integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==",
|
|
62
|
+
"dependencies": {}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"remote": {
|
|
67
|
+
"https://deno.land/x/xml@3.0.2/parse.ts": "057782a8fbee64ebcc608896010016f4579b6799cdd4fe8da9cb1a134b83e92f",
|
|
68
|
+
"https://deno.land/x/xml@3.0.2/utils/parser.ts": "f900943e40bf79f75b7a6effb965ed10a868e3b3134dbddfbf559c7c5e8cd25e",
|
|
69
|
+
"https://deno.land/x/xml@3.0.2/utils/stream.ts": "daa6443695261c1190da38090822d85353e20af3ebaa145e0314b0cf1d6a018e",
|
|
70
|
+
"https://deno.land/x/xml@3.0.2/utils/streamable.ts": "1603a5f10c859b95d4e9502365a0fba0b19d5d068356e20d5a6813cd37fee780",
|
|
71
|
+
"https://deno.land/x/xml@3.0.2/utils/types.ts": "9cd1ee34e70f8ef13815d269b5316f3a3ecc90edf09d4a50e03065986d584ad3",
|
|
72
|
+
"https://deno.land/x/xml@4.0.0/parse.ts": "057782a8fbee64ebcc608896010016f4579b6799cdd4fe8da9cb1a134b83e92f",
|
|
73
|
+
"https://deno.land/x/xml@4.0.0/utils/parser.ts": "1c0701421fd342da5f57dbf3d2ad82956517cb88f15027c3b6628ee1870e59b1",
|
|
74
|
+
"https://deno.land/x/xml@4.0.0/utils/stream.ts": "4cfd7e4daf11cdae80ba636ba0d10ca79cc8812365d66cb9d7b1d777af419e19",
|
|
75
|
+
"https://deno.land/x/xml@4.0.0/utils/streamable.ts": "1603a5f10c859b95d4e9502365a0fba0b19d5d068356e20d5a6813cd37fee780",
|
|
76
|
+
"https://deno.land/x/xml@4.0.0/utils/types.ts": "f5dd32c96f85813a93d155bf8eb2aba88e11c7805c87e97aff12cbaa48db627b"
|
|
77
|
+
},
|
|
78
|
+
"workspace": {
|
|
79
|
+
"dependencies": [
|
|
80
|
+
"jsr:@libs/testing@1",
|
|
81
|
+
"jsr:@libs/typing@2",
|
|
82
|
+
"jsr:@std/fs@0.229.1",
|
|
83
|
+
"jsr:@std/path@0.225.1"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|