basic-toml
v0.4.2
Published
A simple TOML subset parser
Readme
basic-toml
A simple TOML subset parser. ~540 bytes minified with brotli.
TOML Subset
- key / value pairs
- quoted or non-quoted, optionally dotted (within tables and arrays of tables), keys such as
keyorkey.subor"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
- also with trailing commas
- 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'
]Benchmark
The benchmark has been borrowed from @iarna/toml and compared against iarna and fast-toml.
| | @iarna/toml | basic-toml | fast-toml | | - | :---------: | :--------: | :-------: | | Overall | 26MB/sec1.66% | - | - | | 01-small-doc-mixed-type-inline-array | 4.7MB/sec1.29% | 7.1MB/sec0.29% | 14MB/sec0.72% | | Spec Example: v0.4.0 | 26MB/sec0.80% | - | - | | Spec Example: Hard Unicode | 60MB/sec1.30% | - | 90MB/sec0.23% | | Types: Array, Inline | 6.4MB/sec1.00% | 7.1MB/sec0.40% | 8.9MB/sec0.63% | | Types: Array | 6.2MB/sec0.65% | 10MB/sec0.63% | 25MB/sec0.71% | | Types: Boolean, | 22MB/sec0.78% | 9.2MB/sec0.54% | 8.7MB/sec0.49% | | Types: Datetime | 17MB/sec0.72% | - | 6.8MB/sec0.68% | | Types: Float | 8.2MB/sec0.63% | 9.2MB/sec0.41% | 8.5MB/sec0.44% | | Types: Int | 5.2MB/sec0.73% | 7.7MB/sec0.71% | 8.3MB/sec0.45% | | Types: Literal String, 7 char | 28MB/sec0.65% | 9.2MB/sec0.53% | 13MB/sec0.40% | | Types: Literal String, 92 char | 39MB/sec0.70% | 38MB/sec0.81% | 75MB/sec0.26% | | Types: Literal String, Multiline, 1079 char | 17MB/sec2.17% | - | 648MB/sec0.72% | | Types: Basic String, 7 char | 28MB/sec0.60% | 9.3MB/sec0.33% | 13MB/sec0.37% | | Types: Basic String, 92 char | 38MB/sec0.74% | 39MB/sec0.50% | 75MB/sec0.28% | | Types: Basic String, 1079 char | 17MB/sec1.99% | - | 647MB/sec0.45% | | Types: Table, Inline | 9MB/sec0.64% | 7MB/sec0.54% | 8.8MB/sec0.44% | | Types: Table | 6.1MB/sec0.39% | 10MB/sec0.63% | 18MB/sec0.29% | | Scaling: Array, Inline, 1000 elements | 37MB/sec1.04% | 12MB/sec0.53% | 42MB/sec0.21% | | Scaling: Array, Nested, 1000 deep | 1.4MB/sec1.09% | 0.9MB/sec0.36% | 12MB/sec0.63% | | Scaling: Literal String, 40kb | 57MB/sec0.60% | 136MB/sec0.30% | 19kMB/sec0.31% | | Scaling: Literal String, Multiline, 40kb | 57MB/sec0.49% | - | 19kMB/sec0.37% | | Scaling: Basic String, Multiline, 40kb | 58MB/sec0.38% | - | 23kMB/sec0.47% | | Scaling: Basic String, 40kb | 55MB/sec0.47% | 132MB/sec0.74% | 16kMB/sec0.28% | | Scaling: Table, Inline, 1000 elements | 29MB/sec0.53% | 17MB/sec0.45% | 12MB/sec0.67% | | Scaling: Table, Inline, Nested, 1000 deep | 7MB/sec0.69% | - | 8.7MB/sec0.38% |
