Skip to content

Be more strict and less custom - #655

Merged
eemeli merged 7 commits into
mainfrom
less-custom
Feb 13, 2026
Merged

Be more strict and less custom#655
eemeli merged 7 commits into
mainfrom
less-custom

Conversation

@eemeli

@eemeli eemeli commented Feb 7, 2026

Copy link
Copy Markdown
Owner

This PR includes a bunch of breaking changes for v3.

The general thrust here is ensure/enforce that values within a Document are wrapped in Node values, and to remove the custom instance checks. By only releasing the package as an ESM module, we avoid any dual package hazard, and so can simply rely on native isinstance checks.

With the changes here, when a value is added using e.g. doc.add() or .addIn(), the values are automatically wrapped/represented using appropriate Node instances. Node creation is also refactored, but that should be an implementation detail.

The root value of a document is now available as its .value (previously .contents), and it is no longer allowed to be null, but must instead be a Node. Similarly, all mapping keys (i.e. pair.key values) must be Nodes, and cannot be null. Mapping values (pair.value) can still be null, or a Node value.

Internally, the Node-ness of Document values is no longer checked, but is assumed. So assigning non-Node values to doc.value or to collection .items is likely to cause misbehaviour.

@eemeli eemeli added this to the v3 milestone Feb 7, 2026
@eemeli

eemeli commented Feb 13, 2026

Copy link
Copy Markdown
Owner Author

This PR also drops the second keepScalar argument of the .get() and .getIn() accessors. This used to default to false, which meant that scalar values were returned "unwrapped" from their surrounding Scalar.

The new behaviour corresponds to having this argument set true, as the accessors always return a Node value.

I'm going to merge this to unblock further changes. It's pretty likely that this will mean that a number of other PRs will need to be updated to accommodate these changes.

@eemeli
eemeli merged commit bac121e into main Feb 13, 2026
19 checks passed
@eemeli
eemeli deleted the less-custom branch February 13, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant