Merged
Conversation
3caba53 to
f2c4f79
Compare
…collection methods
…) methods as .create()
.items Array
Owner
Author
|
The CI failure appears to be due to something breaking in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 is a pretty deep overhaul of the document-level API's collections. Previously, these all extended an internal
Collectionclass and included an.itemsarray of values.The intent with these changes is to make the collections easier to use, more performant, and to make them more like standard JS collections.
YAMLSeq now extends Array, and so works with
[number]accessors. It overrides the array-mutating methods.fill(),.push(),.splice(), and.unshift()so that they can be used with values that aren't already wrapped as nodes. Setting[number]accessed values is not overridden, but a.set()method is provided for that.YAMLMap is now built around an internal
.valuesMap, keyed by a representation of the pair's key. This key can be user-defined with themapKeyoption, which replaces theuniqueKeyscomparator. It provides.delete(),.get(),.getPair(),.has(),.keyOf(),.pairs(), and.set()utility methods for working with its values.YAMLSet no longer extends YAMLMap, but is its own class, with a very similar API as YAMLMap, with
.add(),.delete(),.get(),.has(), and.keyOf()methods. Its.valuesdoes not contain Pair instance as YAMLMap does, but the set's node values directly.The serializations of maps and sets are now distinct from each other, with maps now never leaving out the value (i.e. you'll get
!!set { foo, bar }, but!!map { foo: null, bar: null }). Note that!!setis not enabled by default for serialization, so a Set will be represented by a sequence unless explicitly enabled:sortMapEntriesis now a ToString option rather than a Schema option, and only affects the serialization. In addition to maps, it also affects the serialization of sets.The path-like methods
.addIn(),.deleteIn(),.getIn(),.hasIn(), and.setIn()are dropped from the document and collection APIs. You should instead chain.get()and[]accessors as appropriate. The document's.add(),.delete(), and.has()methods are dropped, adding.getPair();.get()and.set()are adapted to work with the collection updates.