A simple TOML subset parser. ~540 bytes minified with brotli.
- key / value pairs
- quoted or non-quoted, optionally dotted (within tables and arrays of tables), keys such as
key
orkey.sub
or"my-key.same"
- no spaces around dots in keys
- quoted or non-quoted, optionally dotted (within tables and arrays of tables), keys such as
- strings
- prefer double quotes but it works with single quotes too
- no multiline
- integers and floats
- must be compatible with JSON
- boleans
- all JSON compatible dates
- arrays
- also multiline arrays
- tables
- inline tables
- arrays of tables
# any single line comment
packages = ['a', 'b'] # or end comment
# any propety as object (or nested objects)
[field]
simple = true
version = 0 # any JSON compatible value ... and ...
# ... dates are returned as Date instance
when = 1979-05-27T07:32:00-08:00
# quoted keys
"inline" = { OK = true, key = "value" }
# array of JSON compatible entries
[[externals]]
src = 'https://cdn.spot.on'
name = 'spot-on'
[[externals."special.case"]]
ok = true
[[preload]]
files = [
'./3rd-party.js',
'./other.js'
]
The benchmark has been borrowed from @iarna/toml and compared against iarna and fast-toml.
@iarna/toml | basic-toml | fast-toml | |
---|---|---|---|
Overall | 26MB/sec 1.66% |
- | - |
01-small-doc-mixed-type-inline-array | 4.7MB/sec 1.29% |
7.1MB/sec 0.29% |
14MB/sec 0.72% |
Spec Example: v0.4.0 | 26MB/sec 0.80% |
- | - |
Spec Example: Hard Unicode | 60MB/sec 1.30% |
- | 90MB/sec 0.23% |
Types: Array, Inline | 6.4MB/sec 1.00% |
7.1MB/sec 0.40% |
8.9MB/sec 0.63% |
Types: Array | 6.2MB/sec 0.65% |
10MB/sec 0.63% |
25MB/sec 0.71% |
Types: Boolean, | 22MB/sec 0.78% |
9.2MB/sec 0.54% |
8.7MB/sec 0.49% |
Types: Datetime | 17MB/sec 0.72% |
- | 6.8MB/sec 0.68% |
Types: Float | 8.2MB/sec 0.63% |
9.2MB/sec 0.41% |
8.5MB/sec 0.44% |
Types: Int | 5.2MB/sec 0.73% |
7.7MB/sec 0.71% |
8.3MB/sec 0.45% |
Types: Literal String, 7 char | 28MB/sec 0.65% |
9.2MB/sec 0.53% |
13MB/sec 0.40% |
Types: Literal String, 92 char | 39MB/sec 0.70% |
38MB/sec 0.81% |
7
6515
5MB/sec 0.26% |
Types: Literal String, Multiline, 1079 char | 17MB/sec 2.17% |
- | 648MB/sec 0.72% |
Types: Basic String, 7 char | 28MB/sec 0.60% |
9.3MB/sec 0.33% |
13MB/sec 0.37% |
Types: Basic String, 92 char | 38MB/sec 0.74% |
39MB/sec 0.50% |
75MB/sec 0.28% |
Types: Basic String, 1079 char | 17MB/sec 1.99% |
- | 647MB/sec 0.45% |
Types: Table, Inline | 9MB/sec 0.64% |
7MB/sec 0.54% |
8.8MB/sec 0.44% |
Types: Table | 6.1MB/sec 0.39% |
10MB/sec 0.63% |
18MB/sec 0.29% |
Scaling: Array, Inline, 1000 elements | 37MB/sec 1.04% |
12MB/sec 0.53% |
42MB/sec 0.21% |
Scaling: Array, Nested, 1000 deep | 1.4MB/sec 1.09% |
0.9MB/sec 0.36% |
12MB/sec 0.63% |
Scaling: Literal String, 40kb | 57MB/sec 0.60% |
136MB/sec 0.30% |
19kMB/sec 0.31% |
Scaling: Literal String, Multiline, 40kb | 57MB/sec 0.49% |
- | 19kMB/sec 0.37% |
Scaling: Basic String, Multiline, 40kb | 58MB/sec 0.38% |
- | 23kMB/sec 0.47% |
Scaling: Basic String, 40kb | 55MB/sec 0.47% |
132MB/sec 0.74% |
16kMB/sec 0.28% |
Scaling: Table, Inline, 1000 elements | 29MB/sec 0.53% |
17MB/sec 0.45% |
12MB/sec 0.67% |
Scaling: Table, Inline, Nested, 1000 deep | 7MB/sec 0.69% |
- | 8.7MB/sec 0.38% |