Add missing YAML 1.1 collections: omap, pairs, set #65
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a new instance method
createNode(item, wrapScalars, tag)
to the document schema, along with adding the following tags to theyaml-1.1
schema:!!omap
is an ordered key:value mapping, represented in JS as a Map and in YAML as a sequence of pairs:!!pairs
is very similar to!!omap
, but allows duplicate keys. It does not have an exactly corresponding JS equivalent, and so is represented as an array of{ key: value }
objects:Both
!!omap
and!!pairs
support construction from either a Map, an array of[ key, value ]
tuples, or an array of{ key: value }
objects.!!set
is an unordered set of unique values. In JS it's a Set and in YAML a mapping with null values:To use these collections with e.g. the
core
schema, they may be included as custom tags:With these additions,
yaml
should now directly support all YAML 1.1 tags, except for!!value
and!!yaml
, which are unlikely to get implemented unless someone comes up with a really convincing usage scenario.