smol-toml 1.5.2 → 1.7.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/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # smol-toml
2
- [![TOML 1.0.0](https://img.shields.io/badge/TOML-1.0.0-9c4221?style=flat-square)](https://toml.io/en/v1.0.0)
2
+ [![TOML 1.1.0](https://img.shields.io/badge/TOML-1.1.0-9c4221?style=flat-square)](https://toml.io/en/v1.1.0)
3
3
  [![License](https://img.shields.io/github/license/squirrelchat/smol-toml.svg?style=flat-square)](https://github.com/squirrelchat/smol-toml/blob/mistress/LICENSE)
4
- [![npm](https://img.shields.io/npm/v/smol-toml?style=flat-square)](https://npm.im/smol-toml)
4
+ [![npm](https://img.shields.io/npm/v/smol-toml?style=flat-square)](https://npmx.dev/smol-toml)
5
5
  [![Build](https://img.shields.io/github/actions/workflow/status/squirrelchat/smol-toml/build.yaml?style=flat-square&logo=github)](https://github.com/squirrelchat/smol-toml/actions/workflows/build.yaml)
6
6
 
7
7
  [![GitHub Sponsors](https://img.shields.io/badge/GitHub%20Sponsors-support%20me-EA4AAA?style=flat-square)](https://github.com/sponsors/cyyynthia)
8
- [![Weekly downloads](https://img.shields.io/npm/dw/smol-toml?style=flat-square)](https://npm.im/smol-toml)
9
- [![Monthly downloads](https://img.shields.io/npm/dm/smol-toml?style=flat-square)](https://npm.im/smol-toml)
8
+ [![Weekly downloads](https://img.shields.io/npm/dw/smol-toml?style=flat-square)](https://npmx.dev/smol-toml)
9
+ [![Monthly downloads](https://img.shields.io/npm/dm/smol-toml?style=flat-square)](https://npmx.dev/smol-toml)
10
10
 
11
- A small, fast, and correct TOML parser and serializer. smol-toml is fully(ish) spec-compliant with TOML v1.0.0.
11
+ A small, fast, and correct TOML parser and serializer. smol-toml is fully(ish) spec-compliant with TOML v1.1.0.
12
12
 
13
13
  Why yet another TOML parser? Well, the ecosystem of TOML parsers in JavaScript is quite underwhelming, most likely due
14
14
  to a lack of interest. With most parsers being outdated, unmaintained, non-compliant, or a combination of these, a new
@@ -22,8 +22,7 @@ has been battle-tested and is actively used in production systems.
22
22
  smol-toml passes most of the tests from the [`toml-test` suite](https://github.com/toml-lang/toml-test); use the
23
23
  `run-toml-test.bash` script to run the tests. Due to the nature of JavaScript and the limits of the language,
24
24
  it doesn't pass certain tests, namely:
25
- - Invalid UTF-8 strings are not rejected
26
- - Certain invalid UTF-8 codepoints are not rejected
25
+ - Invalid UTF-8 strings (and comments) are not rejected
27
26
  - Certain invalid dates are not rejected
28
27
  - For instance, `2023-02-30` would be accepted and parsed as `2023-03-02`. While additional checks could be performed
29
28
  to reject these, they've not been added for performance reasons.
@@ -55,7 +54,7 @@ console.log(toml)
55
54
 
56
55
  Alternatively, if you prefer something similar to the JSON global, you can import the library as follows
57
56
  ```js
58
- import TOML from 'smol-toml'
57
+ import * as TOML from 'smol-toml'
59
58
 
60
59
  TOML.stringify({ ... })
61
60
  ```
@@ -73,7 +72,8 @@ A few notes on the `stringify` function:
73
72
  When parsing, both integers and floats are read as plain JavaScript numbers, which essentially are floats. This means
74
73
  loss of type information, and makes it impossible to safely represent integers beyond 53 bits.
75
74
 
76
- When serializing, numbers without a decimal part are serialized as integers. This allows in most cases to preserve
75
+ When serializing, numbers without a decimal part are serialized as integers (except if they're outside of the safe
76
+ range; i.e. they cannot be represented as a signed 53-bit integer). This allows in most cases to preserve
77
77
  whether a number is an integer or not, but fails to preserve type information for numbers like `1.0`.
78
78
 
79
79
  #### Enabling BigInt support and type preservation
@@ -143,94 +143,262 @@ const localTime = TomlDate.wrapAsLocalTime(jsDate)
143
143
  ```
144
144
 
145
145
  ## Performance
146
- > [!NOTE]
147
- > These benchmarks are starting to get a bit old. They will be updated in the (hopefully near) future to better
148
- > reflect numbers of the latest version of smol-toml on the latest version of Node.js.
146
+ The benchmark is ran using [mitata](https://github.com/evanwashere/mitata).
149
147
 
150
- A note on these performance numbers: in some highly synthetic tests, other parsers such as `fast-toml` greatly
151
- outperform other parsers, mostly due to their lack of compliance with the spec. For example, to parse a string,
152
- `fast-toml` skips the entire string while `smol-toml` does validate the string, costing a fair share of performance.
148
+ Parsers and serializers are tested in 2 scenarios: using the example from TOML's homepage and specification, and
149
+ using a ~5MB randomly generated[^generator] file.
153
150
 
154
- The ~5MB test file used for benchmark here is filled with random data which attempts to be close-ish to reality in
155
- terms of structure. The idea is to have a file relatively close to a real-world application, with moderately sized
156
- strings etc.
151
+ [^generator]: The TOML generator used can be found [here](https://gist.github.com/cyyynthia/e77c744cb6494dabe37d0182506526b9)
157
152
 
158
- The large TOML generator can be found [here](https://gist.github.com/cyyynthia/e77c744cb6494dabe37d0182506526b9)
153
+ While `fast-toml` is included as it's a challenging candidate, it takes a lot of shortcuts that makes it very fast,
154
+ but at the expense of correctness (it has significant defects and does not pass the TOML test suite). `smol-toml` is
155
+ almost as fast, without sacrificing correctness. 😎
159
156
 
160
- | **Parse** | smol-toml | @iarna/toml@3.0.0 | @ltd/j-toml | fast-toml |
161
- |----------------|---------------------|-------------------|-----------------|-----------------|
162
- | Spec example | **71,356.51 op/s** | 33,629.31 op/s | 16,433.86 op/s | 29,421.60 op/s |
163
- | ~5MB test file | **3.8091 op/s** | *DNF* | 2.4369 op/s | 2.6078 op/s |
157
+ | **Parse** | smol-toml@1.7.0 | @iarna/toml@3.0.0 | @ltd/j-toml@1.38.0 | fast-toml@0.5.4 | @std/toml@1.0.11 | toml@4.1.1 | js-toml@1.1.2 | @decimalturn/toml-patch@2.0.0 |
158
+ |----------------|--------------------|-------------------|--------------------|-----------------|------------------|----------------|----------------|-------------------------------|
159
+ | Spec example | **4.90 µs/iter** | 12.36 µs/iter | 33.17 µs/iter | *4.80 µs/iter* | 22.94 µs/iter | 29.86 µs/iter | 23.67 µs/iter | 17.81 µs/iter |
160
+ | ~5MB test file | **116.74 ms/iter** | *DNF* | 198.57 ms/iter | *93.51 ms/iter* | 429.91 ms/iter | 415.92 ms/iter | 361.89 ms/iter | 176.94 ms/iter |
164
161
 
165
- | **Stringify** | smol-toml | @iarna/toml@3.0.0 | @ltd/j-toml |
166
- |----------------|----------------------|-------------------|----------------|
167
- | Spec example | **195,191.99 op/s** | 46,583.07 op/s | 5,670.12 op/s |
168
- | ~5MB test file | **14.6709 op/s** | 3.5941 op/s | 0.7856 op/s |
162
+ | **Stringify** | smol-toml@1.7.0 | @iarna/toml@3.0.0 | @ltd/j-toml@1.38.0 | fast-toml@0.5.4 | @std/toml@1.0.11 | toml@4.1.1 | js-toml@1.1.2 | @decimalturn/toml-patch@2.0.0 |
163
+ |----------------|--------------------|-------------------|--------------------|-----------------|------------------|----------------|----------------|-------------------------------|
164
+ | Spec example | **2.24 µs/iter** | 8.68 µs/iter | 89.89 µs/iter | N/A | 3.86 µs/iter | N/A | 3.53 µs/iter | N/A[^toml-patch-note] |
165
+ | ~5MB test file | **42.34 ms/iter** | 132.74 ms/iter | 921.98 ms/iter | N/A | 68.37 ms/iter | N/A | 106.14 ms/iter | N/A[^toml-patch-note] |
166
+
167
+ [^toml-patch-note]: Stringify performance is not included here, as the library is not meant to be fast, but rather
168
+ capable of doing precise non-destructive edits that preserve the entire document's shape and format. Putting it here
169
+ wouldn't be fair.
169
170
 
170
171
  <details>
171
172
  <summary>Detailed benchmark data</summary>
172
173
 
173
- Tests ran using Vitest v0.31.0 on commit f58cb6152e667e9cea09f31c93d90652e3b82bf5
174
-
175
- CPU: Intel Core i7 7700K (4.2GHz)
176
-
177
174
  ```
178
- RUN v0.31.0
179
-
180
- bench/parseSpecExample.bench.ts (4) 2462ms
181
- name hz min max mean p75 p99 p995 p999 rme samples
182
- · smol-toml 71,356.51 0.0132 0.2633 0.0140 0.0137 0.0219 0.0266 0.1135 ±0.37% 35679 fastest
183
- · @iarna/toml 33,629.31 0.0272 0.2629 0.0297 0.0287 0.0571 0.0650 0.1593 ±0.45% 16815
184
- · @ltd/j-toml 16,433.86 0.0523 1.3088 0.0608 0.0550 0.1140 0.1525 0.7348 ±1.47% 8217 slowest
185
- · fast-toml 29,421.60 0.0305 0.2995 0.0340 0.0312 0.0618 0.0640 0.1553 ±0.47% 14711
186
- ✓ bench/parseLargeMixed.bench.ts (3) 16062ms
187
- name hz min max mean p75 p99 p995 p999 rme samples
188
- · smol-toml 3.8091 239.60 287.30 262.53 274.17 287.30 287.30 287.30 ±3.66% 10 fastest
189
- · @ltd/j-toml 2.4369 376.73 493.49 410.35 442.58 493.49 493.49 493.49 ±7.08% 10 slowest
190
- · fast-toml 2.6078 373.88 412.79 383.47 388.62 412.79 412.79 412.79 ±2.72% 10
191
- bench/stringifySpecExample.bench.ts (3) 1886ms
192
- name hz min max mean p75 p99 p995 p999 rme samples
193
- · smol-toml 195,191.99 0.0047 0.2704 0.0051 0.0050 0.0099 0.0110 0.0152 ±0.41% 97596 fastest
194
- · @iarna/toml 46,583.07 0.0197 0.2808 0.0215 0.0208 0.0448 0.0470 0.1704 ±0.47% 23292
195
- · @ltd/j-toml 5,670.12 0.1613 0.5768 0.1764 0.1726 0.3036 0.3129 0.4324 ±0.56% 2836 slowest
196
- bench/stringifyLargeMixed.bench.ts (3) 24057ms
197
- name hz min max mean p75 p99 p995 p999 rme samples
198
- · smol-toml 14.6709 65.1071 79.2199 68.1623 67.1088 79.2199 79.2199 79.2199 ±5.25% 10 fastest
199
- · @iarna/toml 3.5941 266.48 295.24 278.24 290.10 295.24 295.24 295.24 ±2.83% 10
200
- · @ltd/j-toml 0.7856 1,254.33 1,322.05 1,272.87 1,286.82 1,322.05 1,322.05 1,322.05 ±1.37% 10 slowest
201
-
202
-
203
- BENCH Summary
204
-
205
- smol-toml - bench/parseLargeMixed.bench.ts >
206
- 1.46x faster than fast-toml
207
- 1.56x faster than @ltd/j-toml
208
-
209
- smol-toml - bench/parseSpecExample.bench.ts >
210
- 2.12x faster than @iarna/toml
211
- 2.43x faster than fast-toml
212
- 4.34x faster than @ltd/j-toml
213
-
214
- smol-toml - bench/stringifyLargeMixed.bench.ts >
215
- 4.00x faster than @iarna/toml
216
- 18.33x faster than @ltd/j-toml
217
-
218
- smol-toml - bench/stringifySpecExample.bench.ts >
219
- 4.19x faster than @iarna/toml
220
- 34.42x faster than @ltd/j-toml
175
+ node --expose-gc bench/parse.bench.ts
176
+ clk: ~5.47 GHz
177
+ cpu: AMD Ryzen 9 9950X3D 16-Core Processor
178
+ runtime: node 26.3.1 (x64-linux)
179
+
180
+ benchmark avg (min … max) p75 / p99 (min … top 1%)
181
+ ------------------------------------------- -------------------------------
182
+ spec document
183
+ ------------------------------------------- -------------------------------
184
+ smol-toml 4.90 µs/iter 4.85 µs
185
+ (4.72 µs … 96.03 µs) 6.13 µs █▅
186
+ ( 2.09 kb … 325.14 kb) 12.96 kb ▁██▄▃▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
187
+ 4.01 ipc ( 99.63% cache) 21.59 branch misses
188
+ 27.50k cycles 110.19k instructions 4.09k c-refs 15.27 c-misses
189
+
190
+ @iarna/toml 12.36 µs/iter 12.19 µs
191
+ (11.86 µs … 131.24 µs) 16.53 µs
192
+ (176.00 b … 360.27 kb) 24.00 kb ▅█▅▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
193
+ 3.97 ipc ( 99.71% cache) 60.52 branch misses
194
+ 68.38k cycles 271.17k instructions 12.01k c-refs 35.06 c-misses
195
+
196
+ @ltd/j-toml 33.17 µs/iter 32.50 µs ▇█
197
+ (31.03 µs … 1.10 ms) 36.36 µs ███▆
198
+ ( 40.00 b … 537.94 kb) 27.61 kb ▁▃▇████▆▂▁▁▂▂▁▁▁▁▁▁▁▁
199
+ 3.15 ipc ( 99.50% cache) 305.47 branch misses
200
+ 183.96k cycles 579.46k instructions 32.33k c-refs 160.93 c-misses
201
+
202
+ fast-toml 4.80 µs/iter 4.77 µs █
203
+ (4.61 µs 96.44 µs) 5.58 µs █▃
204
+ (256.00 b 329.85 kb) 12.55 kb ▁▆██▅▄▃▂▂▁▁▁▁▁▁▁▁▁▁▁▁
205
+ 4.61 ipc ( 99.61% cache) 18.02 branch misses
206
+ 26.90k cycles 123.90k instructions 3.73k c-refs 14.45 c-misses
207
+
208
+ deno's @std/toml 22.94 µs/iter 22.84 µs █
209
+ (21.43 µs 183.90 µs) 27.22 µs ██
210
+ (800.00 b … 619.62 kb) 64.88 kb ▁▄▄▆██▅▂▁▁▁▁▁▁▁▁▁▁▁▁▁
211
+ 3.73 ipc ( 99.67% cache) 106.77 branch misses
212
+ 126.43k cycles 472.03k instructions 23.79k c-refs 79.52 c-misses
213
+
214
+ node-toml 29.86 µs/iter 29.51 µs █
215
+ (28.17 µs … 200.95 µs) 42.50 µs █▇
216
+ (976.00 b 785.96 kb) 104.23 kb ▄██▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
217
+ 4.01 ipc ( 99.36% cache) 146.79 branch misses
218
+ 163.80k cycles 657.50k instructions 27.26k c-refs 174.37 c-misses
219
+
220
+ js-toml 23.67 µs/iter 23.31 µs █▃
221
+ (22.10 µs … 196.26 µs) 34.04 µs ██
222
+ ( 2.55 kb … 678.23 kb) 96.06 kb ▃██▄▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁
223
+ 4.14 ipc ( 98.56% cache) 141.38 branch misses
224
+ 129.53k cycles 536.67k instructions 18.52k c-refs 266.18 c-misses
225
+
226
+ @decimalturn/toml-patch 17.81 µs/iter 17.68 µs █▇
227
+ (16.82 µs … 159.63 µs) 23.01 µs ██▅
228
+ (264.00 b … 651.59 kb) 56.03 kb ▃███▄▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁
229
+ 3.60 ipc ( 99.55% cache) 73.51 branch misses
230
+ 98.49k cycles 354.88k instructions 20.21k c-refs 90.93 c-misses
231
+
232
+ summary
233
+ fast-toml
234
+ 1.02x faster than smol-toml
235
+ 2.57x faster than @iarna/toml
236
+ 3.71x faster than @decimalturn/toml-patch
237
+ 4.77x faster than deno's @std/toml
238
+ 4.93x faster than js-toml
239
+ 6.22x faster than node-toml
240
+ 6.9x faster than @ltd/j-toml (nice)
241
+
242
+ • 5MB document
243
+ ------------------------------------------- -------------------------------
244
+ smol-toml 116.74 ms/iter 118.39 ms █ █
245
+ (110.52 ms … 127.54 ms) 123.91 ms █ ▅ ▅ █ ▅ ▅▅ ▅ ▅
246
+ ( 32.98 mb … 49.20 mb) 42.93 mb █▁█▁█▁▁█▁█▁██▁▁█▁▁▁▁█
247
+ 2.48 ipc ( 98.45% cache) 3.17M branch misses
248
+ 629.10M cycles 1.56G instructions 101.49M c-refs 1.58M c-misses
249
+
250
+ @iarna/toml error: Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z at row 5, col 45, pos 569:
251
+ 4: NfF6LuAerfn5mDPI7Cp 2qsrB4vGmJTyb5jNubOIBYYWrWlAsrw PX93S57gjb5GEhR8qOU5blDQmwfVJTA YvmJ9cE3cUZU NAJQgAbIdpZLhc4lOs4ZhMEWehhZqXCsVD1YP1vN2GEoM2WX''', 1986-05-27T18:36:13Z, -5460, "2ZAV3fYlb23hf7r7QoftVlicWE2iuwp", 4790.2253 ]
252
+ 5> SzeC4Me8T = [ 5928.9340, 1991-04-28 19:24:24, 7807, -782.4516, 0b1000011111, "YvXRZKBGle9d51sqE90t8hP" ]
253
+ ^
254
+ 6: SLMvBirT.pmpX1D.9PivpfFBo = 2010-09-29
255
+
256
+
257
+
258
+ @ltd/j-toml 198.57 ms/iter 196.77 ms █
259
+ (181.11 ms … 291.66 ms) 209.47 ms ██
260
+ ( 8.55 mb … 55.95 mb) 35.95 mb ████▁▁▁▁▁█▁█▁▁▁█▁▁▁▁█
261
+ 2.32 ipc ( 97.82% cache) 3.98M branch misses
262
+ 1.08G cycles 2.50G instructions 166.94M c-refs 3.63M c-misses
263
+
264
+ fast-toml 93.51 ms/iter 95.06 ms █
265
+ (89.98 ms … 96.83 ms) 95.74 ms ▅ ▅ ▅ █▅ ▅▅ ▅▅▅
266
+ ( 13.30 mb … 34.88 mb) 24.04 mb █▁▁▁█▁█▁██▁▁▁▁▁██▁███
267
+ 2.83 ipc ( 98.14% cache) 2.36M branch misses
268
+ 507.32M cycles 1.44G instructions 66.44M c-refs 1.23M c-misses
269
+
270
+ deno's @std/toml 429.91 ms/iter 436.58 ms █
271
+ (419.32 ms … 441.05 ms) 437.63 ms ▅ ▅▅▅ ▅ ▅ ▅ ▅ ▅█
272
+ (180.32 mb … 204.05 mb) 191.51 mb █▁███▁▁█▁█▁▁▁▁▁█▁█▁██
273
+ 3.15 ipc ( 97.05% cache) 6.63M branch misses
274
+ 2.36G cycles 7.45G instructions 255.14M c-refs 7.54M c-misses
275
+
276
+ node-toml 415.92 ms/iter 413.57 ms ██
277
+ (404.84 ms … 448.96 ms) 438.33 ms ██ █
278
+ ( 45.80 mb … 78.18 mb) 50.13 mb ████▁█▁▁▁▁▁▁▁▁▁▁▁▁▁▁█
279
+ 4.26 ipc ( 97.29% cache) 6.53M branch misses
280
+ 2.25G cycles 9.59G instructions 194.56M c-refs 5.27M c-misses
281
+
282
+ js-toml 361.89 ms/iter 369.39 ms █
283
+ (346.05 ms … 406.77 ms) 394.74 ms ▅█ ▅
284
+ (249.62 mb … 282.33 mb) 265.65 mb ██▁█▁▁▁▁▁▁▇▁▁▁▇▁▁▁▁▁▇
285
+ 2.55 ipc ( 94.91% cache) 5.64M branch misses
286
+ 1.73G cycles 4.43G instructions 112.66M c-refs 5.74M c-misses
287
+
288
+ @decimalturn/toml-patch 176.94 ms/iter 174.86 ms █
289
+ (172.74 ms … 197.94 ms) 182.08 ms █ ██
290
+ ( 27.14 mb … 38.55 mb) 28.81 mb █▁████▁▁▁▁▁█▁▁▁▁▁▁▁▁█
291
+ 3.18 ipc ( 97.69% cache) 3.58M branch misses
292
+ 947.48M cycles 3.02G instructions 130.37M c-refs 3.01M c-misses
293
+
294
+ summary
295
+ fast-toml
296
+ 1.25x faster than smol-toml
297
+ 1.89x faster than @decimalturn/toml-patch
298
+ 2.12x faster than @ltd/j-toml
299
+ 3.87x faster than js-toml
300
+ 4.45x faster than node-toml
301
+ 4.6x faster than deno's @std/toml
302
+
303
+
304
+ node --expose-gc bench/stringify.bench.ts
305
+ clk: ~5.48 GHz
306
+ cpu: AMD Ryzen 9 9950X3D 16-Core Processor
307
+ runtime: node 26.3.1 (x64-linux)
308
+
309
+ benchmark avg (min … max) p75 / p99 (min … top 1%)
310
+ ------------------------------------------- -------------------------------
311
+ • spec document
312
+ ------------------------------------------- -------------------------------
313
+ smol-toml 2.24 µs/iter 2.24 µs ▄ █
314
+ (2.22 µs … 2.27 µs) 2.27 µs █▃ ▅▆ █▃
315
+ ( 4.60 kb … 4.71 kb) 4.61 kb ▅███▃██████▃▇▃▃▅▃▁▁▃▅
316
+ 4.62 ipc ( 99.64% cache) 5.08 branch misses
317
+ 12.21k cycles 56.44k instructions 1.12k c-refs 4.08 c-misses
318
+
319
+ @iarna/toml 8.68 µs/iter 8.67 µs █
320
+ (8.65 µs … 8.89 µs) 8.73 µs ▅█▅ ▅
321
+ (654.88 b … 1.53 kb) 720.60 b ▇███▇▁█▁▁▁▁▁▇▇▁▁▁▁▁▁▇
322
+ 4.00 ipc ( 99.49% cache) 23.53 branch misses
323
+ 47.95k cycles 191.80k instructions 7.11k c-refs 36.09 c-misses
324
+
325
+ @ltd/j-toml 89.89 µs/iter 90.21 µs █
326
+ (69.82 µs … 209.14 µs) 95.93 µs █
327
+ ( 4.04 kb … 389.75 kb) 37.49 kb ▁▁▁▁▁▁▁▂▁▁▁▁▁▁▁█▄▄▃▂▂
328
+ 4.20 ipc ( 99.76% cache) 544.09 branch misses
329
+ 490.58k cycles 2.06M instructions 35.22k c-refs 82.84 c-misses
330
+
331
+ deno's @std/toml 3.86 µs/iter 3.86 µs █
332
+ (3.83 µs … 4.24 µs) 3.88 µs ▅ ▅ █▅▅██▅
333
+ (836.05 b … 4.28 kb) 0.98 kb █▁██▅█▅████████▁▁▁▁▁▅
334
+ 4.00 ipc ( 99.60% cache) 6.22 branch misses
335
+ 21.36k cycles 85.36k instructions 3.32k c-refs 13.27 c-misses
336
+
337
+ js-toml 3.53 µs/iter 3.54 µs █▂▄
338
+ (3.52 µs … 3.58 µs) 3.58 µs ▆███
339
+ ( 5.76 kb … 7.29 kb) 6.98 kb ▃▇████▃▅▁▃▁▃▁▁▁▁▁▁▁▁▃
340
+ 4.37 ipc ( 99.11% cache) 10.24 branch misses
341
+ 19.45k cycles 84.99k instructions 2.10k c-refs 18.67 c-misses
342
+
343
+ @decimalturn/toml-patch 81.54 µs/iter 81.22 µs █
344
+ (78.63 µs … 341.24 µs) 103.14 µs █▂
345
+ (872.00 b … 831.95 kb) 113.00 kb ▃██▅▃▂▁▂▁▁▁▁▁▁▁▁▁▁▁▁▁
346
+ 4.56 ipc ( 99.28% cache) 567.51 branch misses
347
+ 443.97k cycles 2.02M instructions 52.63k c-refs 381.28 c-misses
348
+
349
+ summary
350
+ smol-toml
351
+ 1.58x faster than js-toml
352
+ 1.73x faster than deno's @std/toml
353
+ 3.88x faster than @iarna/toml
354
+ 36.44x faster than @decimalturn/toml-patch
355
+ 40.18x faster than @ltd/j-toml
356
+
357
+ • 5MB document
358
+ ------------------------------------------- -------------------------------
359
+ smol-toml 42.34 ms/iter 43.06 ms █ █
360
+ (40.50 ms … 45.33 ms) 43.51 ms █ ▅▅▅▅ ▅ ▅▅▅ █
361
+ ( 9.46 mb … 35.74 mb) 12.91 mb █▁▁▁▁████▁▁▁█▁▁███▁▁█
362
+ 2.12 ipc ( 95.19% cache) 1.59M branch misses
363
+ 217.80M cycles 462.56M instructions 14.99M c-refs 720.67k c-misses
364
+
365
+ @iarna/toml 132.74 ms/iter 134.02 ms █
366
+ (125.91 ms … 138.18 ms) 137.02 ms █ █
367
+ ( 27.35 mb … 54.08 mb) 41.53 mb █▁▁█▁▁▁▁█▁▁█▁███▁▁▁▁█
368
+ 2.56 ipc ( 97.08% cache) 4.44M branch misses
369
+ 704.85M cycles 1.80G instructions 85.83M c-refs 2.50M c-misses
370
+
371
+ @ltd/j-toml 921.98 ms/iter 927.58 ms █ ██ █
372
+ (889.05 ms … 937.02 ms) 929.09 ms ▅ █ ▅██▅█
373
+ ( 4.20 mb … 33.46 mb) 18.59 mb █▁▁▁▁▁▁▁▁▁▁▁▁▁█▁█████
374
+ 4.06 ipc ( 99.42% cache) 6.75M branch misses
375
+ 5.04G cycles 20.45G instructions 243.67M c-refs 1.41M c-misses
376
+
377
+ deno's @std/toml 68.37 ms/iter 69.68 ms █ █
378
+ (61.79 ms … 78.19 ms) 77.23 ms ▅ ▅█▅ ▅ ▅█ ▅ ▅
379
+ ( 29.04 mb … 62.29 mb) 33.86 mb █▁███▁▁█▁██▁█▁▁▁▁▁▁▁█
380
+ 2.21 ipc ( 95.21% cache) 1.74M branch misses
381
+ 332.33M cycles 732.79M instructions 30.06M c-refs 1.44M c-misses
382
+
383
+ js-toml 106.14 ms/iter 107.44 ms █
384
+ (102.35 ms … 117.91 ms) 108.69 ms ▅█ ▅▅ ▅ ▅▅ ▅ ▅▅
385
+ ( 34.03 mb … 62.21 mb) 44.13 mb ██▁▁██▁▁█▁██▁▁▁▁█▁▁██
386
+ 2.39 ipc ( 96.23% cache) 3.05M branch misses
387
+ 570.22M cycles 1.36G instructions 50.24M c-refs 1.90M c-misses
388
+
389
+ @decimalturn/toml-patch 1.07 s/iter 1.08 s █ █ █
390
+ (1.05 s … 1.14 s) 1.09 s █▅ ▅▅ █ █ ▅ ▅
391
+ (116.61 mb … 147.62 mb) 121.20 mb ██▁██▁▁▁█▁▁▁▁▁█▁▁█▁▁█
392
+ 3.67 ipc ( 93.69% cache) 12.18M branch misses
393
+ 5.77G cycles 21.17G instructions 780.26M c-refs 49.26M c-misses
394
+
395
+ summary
396
+ smol-toml
397
+ 1.61x faster than deno's @std/toml
398
+ 2.51x faster than js-toml
399
+ 3.13x faster than @iarna/toml
400
+ 21.77x faster than @ltd/j-toml
401
+ 25.29x faster than @decimalturn/toml-patch
221
402
  ```
222
403
 
223
- ---
224
- Additional notes:
225
-
226
- I initially tried to benchmark `toml-nodejs`, but the 0.3.0 package is broken.
227
- I initially reported this to the library author, but the author decided to
228
- - a) advise to use a custom loader (via *experimental* flag) to circumvent the invalid imports.
229
- - Said flag, `--experimental-specifier-resolution`, has been removed in Node v20.
230
- - b) [delete the issue](https://github.com/huan231/toml-nodejs/issues/12) when pointed out links to the Node.js
231
- documentation about the flag removal and standard resolution algorithm.
232
-
233
- For the reference anyway, `toml-nodejs` (with proper imports) is ~8x slower on both parse benchmark with:
234
- - spec example: 7,543.47 op/s
235
- - 5mb mixed: 0.7006 op/s
236
404
  </details>
package/dist/date.d.ts CHANGED
@@ -39,3 +39,4 @@ export declare class TomlDate extends Date {
39
39
  static wrapAsLocalDate(jsDate: Date): TomlDate;
40
40
  static wrapAsLocalTime(jsDate: Date): TomlDate;
41
41
  }
42
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../src/date.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AASH,qBAAa,QAAS,SAAQ,IAAI;;IAKjC,YAAY,IAAI,EAAE,MAAM,GAAG,IAAI,EAmC9B;IAED,UAAU,YAET;IAED,OAAO,YAEN;IAED,MAAM,YAEL;IAED,MAAM,YAEL;IAED,OAAO,YAEN;IAEQ,WAAW,WA2BnB;IAED,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,SAAM,YAIrD;IAED,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,YAItC;IAED,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,YAKlC;IAED,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,YAKlC;CACD"}
package/dist/date.js CHANGED
@@ -25,7 +25,7 @@
25
25
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
26
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
27
  */
28
- let DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;
28
+ let DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
29
29
  export class TomlDate extends Date {
30
30
  #hasDate = false;
31
31
  #hasTime = false;
@@ -125,3 +125,4 @@ export class TomlDate extends Date {
125
125
  return date;
126
126
  }
127
127
  }
128
+ //# sourceMappingURL=date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.js","sourceRoot":"","sources":["../src/date.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAOH,IAAI,YAAY,GAAG,yFAAyF,CAAA;AAE5G,MAAM,OAAO,QAAS,SAAQ,IAAI;IACjC,QAAQ,GAAG,KAAK,CAAA;IAChB,QAAQ,GAAG,KAAK,CAAA;IAChB,OAAO,GAAW,IAAI,CAAA;IAEtB,YAAY,IAAmB;QAC9B,IAAI,OAAO,GAAG,IAAI,CAAA;QAClB,IAAI,OAAO,GAAG,IAAI,CAAA;QAClB,IAAI,MAAM,GAAW,GAAG,CAAA;QAExB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9B,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;YACpC,IAAI,KAAK,EAAE,CAAC;gBACX,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;oBACf,OAAO,GAAG,KAAK,CAAA;oBACf,IAAI,GAAG,cAAc,IAAI,EAAE,CAAA;gBAC5B,CAAC;gBAED,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;gBACpB,qFAAqF;gBACrF,OAAO,IAAI,IAAI,CAAC,EAAE,CAAC,KAAK,GA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GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAA;QAC/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QACrB,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAC,MAAY;QACtC,IAAI,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAA;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,MAAY;QAClC,IAAI,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAA;QAC/B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;QACrB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,MAAY;QAClC,IAAI,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAA;QAC/B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;QACrB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,OAAO,IAAI,CAAA;IACZ,CAAC;CACD"}
package/dist/error.d.ts CHANGED
@@ -36,3 +36,4 @@ export declare class TomlError extends Error {
36
36
  constructor(message: string, options: TomlErrorOptions);
37
37
  }
38
38
  export {};
39
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,KAAK,gBAAgB,GAAG,YAAY,GAAG;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACX,CAAA;AA+BD,qBAAa,SAAU,SAAQ,KAAK;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IAEjB,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAQrD;CACD"}
package/dist/error.js CHANGED
@@ -61,3 +61,4 @@ export class TomlError extends Error {
61
61
  this.codeblock = codeblock;
62
62
  }
63
63
  }
64
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAOH,SAAS,iBAAiB,CAAC,MAAc,EAAE,GAAW;IACrD,IAAI,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IACrD,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AAC/C,CAAC;AAED,SAAS,aAAa,CAAC,MAAc,EAAE,IAAY,EAAE,MAAc;IAClE,IAAI,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IACvC,IAAI,SAAS,GAAG,EAAE,CAAA;IAElB,IAAI,SAAS,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;IAE9C,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QACpB,IAAI,CAAC,CAAC;YAAE,SAAQ;QAEhB,SAAS,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;QAChD,SAAS,IAAI,KAAK,CAAA;QAClB,SAAS,IAAI,CAAC,CAAA;QACd,SAAS,IAAI,IAAI,CAAA;QAEjB,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAChB,SAAS,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,GAAG,MAAM,GAAG,CAAC,CAAC,CAAA;YAC/C,SAAS,IAAI,KAAK,CAAA;QACnB,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAA;AACjB,CAAC;AAED,MAAM,OAAO,SAAU,SAAQ,KAAK;IACnC,IAAI,CAAQ;IACZ,MAAM,CAAQ;IACd,SAAS,CAAQ;IAEjB,YAAY,OAAe,EAAE,OAAyB;QACrD,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;QACnE,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;QAE3D,KAAK,CAAC,0BAA0B,OAAO,OAAO,SAAS,EAAE,EAAE,OAAO,CAAC,CAAA;QACnE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC3B,CAAC;CACD"}
package/dist/extract.js CHANGED
@@ -27,9 +27,9 @@
27
27
  */
28
28
  import { parseString, parseValue } from './primitive.js';
29
29
  import { parseArray, parseInlineTable } from './struct.js';
30
- import { indexOfNewline, skipVoid, skipUntil, skipComment, getStringEnd } from './util.js';
30
+ import { skipVoid, skipUntil, skipComment } from './util.js';
31
31
  import { TomlError } from './error.js';
32
- function sliceAndTrimEndOf(str, startPtr, endPtr, allowNewLines) {
32
+ function sliceAndTrimEndOf(str, startPtr, endPtr) {
33
33
  let value = str.slice(startPtr, endPtr);
34
34
  let commentIdx = value.indexOf('#');
35
35
  if (commentIdx > -1) {
@@ -38,23 +38,14 @@ function sliceAndTrimEndOf(str, startPtr, endPtr, allowNewLines) {
38
38
  skipComment(str, commentIdx);
39
39
  value = value.slice(0, commentIdx);
40
40
  }
41
- let trimmed = value.trimEnd();
42
- if (!allowNewLines) {
43
- let newlineIdx = value.indexOf('\n', trimmed.length);
44
- if (newlineIdx > -1) {
45
- throw new TomlError('newlines are not allowed in inline tables', {
46
- toml: str,
47
- ptr: startPtr + newlineIdx
48
- });
49
- }
50
- }
51
- return [trimmed, commentIdx];
41
+ return [value.trimEnd(), commentIdx];
52
42
  }
43
+ /** @internal */
53
44
  export function extractValue(str, ptr, end, depth, integersAsBigInt) {
54
45
  if (depth === 0) {
55
46
  throw new TomlError('document contains excessively nested structures. aborting.', {
56
47
  toml: str,
57
- ptr: ptr
48
+ ptr: ptr,
58
49
  });
59
50
  }
60
51
  let c = str[ptr];
@@ -62,48 +53,50 @@ export function extractValue(str, ptr, end, depth, integersAsBigInt) {
62
53
  let [value, endPtr] = c === '['
63
54
  ? parseArray(str, ptr, depth, integersAsBigInt)
64
55
  : parseInlineTable(str, ptr, depth, integersAsBigInt);
65
- let newPtr = end ? skipUntil(str, endPtr, ',', end) : endPtr;
66
- if (endPtr - newPtr && end === '}') {
67
- let nextNewLine = indexOfNewline(str, endPtr, newPtr);
68
- if (nextNewLine > -1) {
69
- throw new TomlError('newlines are not allowed in inline tables', {
56
+ if (end) {
57
+ endPtr = skipVoid(str, endPtr);
58
+ if (str[endPtr] === ',')
59
+ endPtr++;
60
+ else if (str[endPtr] !== end) {
61
+ throw new TomlError('expected comma or end of structure', {
70
62
  toml: str,
71
- ptr: nextNewLine
63
+ ptr: endPtr,
72
64
  });
73
65
  }
74
66
  }
75
- return [value, newPtr];
67
+ return [value, endPtr];
76
68
  }
77
- let endPtr;
78
69
  if (c === '"' || c === "'") {
79
- endPtr = getStringEnd(str, ptr);
80
- let parsed = parseString(str, ptr, endPtr);
70
+ let [parsed, endPtr] = parseString(str, ptr);
81
71
  if (end) {
82
- endPtr = skipVoid(str, endPtr, end !== ']');
72
+ endPtr = skipVoid(str, endPtr);
83
73
  if (str[endPtr] && str[endPtr] !== ',' && str[endPtr] !== end && str[endPtr] !== '\n' && str[endPtr] !== '\r') {
84
74
  throw new TomlError('unexpected character encountered', {
85
75
  toml: str,
86
76
  ptr: endPtr,
87
77
  });
88
78
  }
89
- endPtr += (+(str[endPtr] === ','));
79
+ if (str[endPtr] === ',')
80
+ endPtr++;
90
81
  }
91
82
  return [parsed, endPtr];
92
83
  }
93
- endPtr = skipUntil(str, ptr, ',', end);
94
- let slice = sliceAndTrimEndOf(str, ptr, endPtr - (+(str[endPtr - 1] === ',')), end === ']');
84
+ let endPtr = skipUntil(str, ptr, ',', end);
85
+ let slice = sliceAndTrimEndOf(str, ptr, endPtr - (str[endPtr - 1] === ',' ? 1 : 0));
95
86
  if (!slice[0]) {
96
87
  throw new TomlError('incomplete key-value declaration: no value specified', {
97
88
  toml: str,
98
- ptr: ptr
89
+ ptr: ptr,
99
90
  });
100
91
  }
101
92
  if (end && slice[1] > -1) {
102
93
  endPtr = skipVoid(str, ptr + slice[1]);
103
- endPtr += +(str[endPtr] === ',');
94
+ if (str[endPtr] === ',')
95
+ endPtr++;
104
96
  }
105
97
  return [
106
98
  parseValue(slice[0], str, ptr, integersAsBigInt),
107
99
  endPtr,
108
100
  ];
109
101
  }
102
+ //# sourceMappingURL=extract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract.js","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAyB,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC/E,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAkB,MAAM,WAAW,CAAA;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC,SAAS,iBAAiB,CAAC,GAAW,EAAE,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