Repository navigation
Conversation
|
Review requested:
|
This comment was marked as outdated.
This comment was marked as outdated.
Add the header-only toml++ library, its updater script and license entry, for use by node:formats/toml.
Add a TOML parser and serializer backed by toml++, available behind `--experimental-toml` as the scheme-only `node:formats/toml` builtin. Assisted-by: Devin
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
This can be reverted once at least one serializer it documents is enabled by default. Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Version changes
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67874 +/- ##
==========================================
- Coverage 90.58% 90.56% -0.03%
==========================================
Files 802 804 +2
Lines 286656 286816 +160
Branches 55369 55378 +9
==========================================
+ Hits 259668 259753 +85
- Misses 17089 17184 +95
+ Partials 9899 9879 -20
🚀 New features to boost your workflow:
|
jsumners-nr
left a comment
There was a problem hiding this comment.
Love seeing this move so quickly. Just a bit concerned that the docs attempt to enforce the same API across all formats/ namespaced modules.
| Every format module exports two functions: | ||
|
|
||
| * `parse(input[, options])` turns a document into JavaScript values. | ||
| * `stringify(value)` turns JavaScript values into a document. |
There was a problem hiding this comment.
I think this may be too restrictive. Each module should strive for such a simple API, but it should also be allowed to export an interface that makes sense for the module.
There was a problem hiding this comment.
The docs are not a spec, they only document the existing behavior. If another format is added, the docs will need to be updated anyway. In any case, happy to update if you have a suggestion
There was a problem hiding this comment.
I think the opening paragraph is sufficient. Lines 11 through 14 can be removed and everything will still make sense.
| An attempt was made to issue Server Name Indication from a TLS server-side | ||
| socket, which is only valid from a client. | ||
|
|
||
| <a id="ERR_TOML_PARSE"></a> |
There was a problem hiding this comment.
Nit... Let's just make sure the err codes with the various formats are consistently named.
| * `input` {string|ArrayBuffer|SharedArrayBuffer|TypedArray|DataView} The TOML | ||
| document. Binary input must be UTF-8. A leading byte order mark is ignored. | ||
| * `options` {Object} | ||
| * `bigint` {boolean} If `true`, every integer is returned as a {bigint}. |
There was a problem hiding this comment.
This should also support a non-throwing parse mode, like the yaml case.
|
|
||
| // Basic document. | ||
| { | ||
| const doc = TOML.parse(` |
There was a problem hiding this comment.
It might be worthwhile using fixtures here to help the tests be more readable
| for (const auto& [key, node] : entries) { | ||
| Local<String> name; | ||
| Local<Value> value; | ||
| if (!String::NewFromUtf8(isolate_, |
| KeyCollectionMode::kOwnOnly, | ||
| static_cast<PropertyFilter>(PropertyFilter::ONLY_ENUMERABLE | | ||
| PropertyFilter::SKIP_SYMBOLS), | ||
| v8::IndexFilter::kIncludeIndices, |
| out->push_back(std::move(*node)); | ||
| } | ||
| Leave(); | ||
| return Just(true); |
There was a problem hiding this comment.
This never returns Just(false)?
Would MaybeVoid be better?
| return std::make_unique<::toml::value<int64_t>>(integer); | ||
| } | ||
| if (value->IsArray()) { | ||
| auto array = std::make_unique<::toml::array>(); |
There was a problem hiding this comment.
Would be nice if this could accept sequences/sync iterators
| Local<Array> info = args[3].As<Array>(); | ||
| Local<String> message; | ||
| if (!String::NewFromUtf8(isolate, | ||
| description.data(), |
|
|
||
| Local<String> result; | ||
| if (!String::NewFromUtf8(isolate, | ||
| output.data(), |
| case kLocalDate: | ||
| return Temporal.PlainDate.from(text); | ||
| default: | ||
| return Temporal.PlainTime.from(text); |
There was a problem hiding this comment.
I'm not familiar yet with the primordial captures for Temporal yet... Are these safe captures?
Related to #67157 //cc @marcopiraccini
Opt-in with a configure flag, so it can be backported. The plan is to make it opt-out in a future semver-major.