Handle empty items in arrays and arraylike objects#75
Handle empty items in arrays and arraylike objects#75ninevra wants to merge 11 commits intoconcordancejs:mainfrom
Conversation
Having an EmptyList descriptor type seems like a clearer description of the underlying data model than having an Empty primitive that can by construction only occur in PrimitiveItems.
|
There's a bug in the alignment code that I need to figure out. |
novemberborn
left a comment
There was a problem hiding this comment.
This is great!
Maybe the item text should be configurable, or maybe the brackets should be part of the item text and not part of the open/close wrappers?
Perhaps the entire <empty item> could be the theme string, and then tools like AVA can color it however they like?
I initially implemented this with an
Emptyprimitive descriptor, but I thinkEmptyItembetter matches the data model. I can't think of a non-list context whereEmptywould be valid.
👍
This PR does not collapse empty items into e.g.
<5 empty items>likeutil.inspectdoes; that functionality seemed like a subset of #12.
👍
This is a breaking change & bumps the serialization format version to 4.
👍
| test('empty array slots do not equal undefined', t => { | ||
| t.false(compare(new Array(1), Array.from({ length: 1 })).pass) | ||
| }) | ||
|
|
||
| test('empty arraylike slots do not equal undefined', t => { | ||
| t.false(compare({ length: 2, 0: 'a' }, { length: 2, 0: 'a', 1: undefined }).pass) | ||
| }) |
There was a problem hiding this comment.
Perhaps this needs some tests for equality between arrays with empty items?
Adds an
EmptyItemdescriptor to represent the gaps in sparse arrays. Formats gaps as<empty item>, and treats them as unequal to anything other than empty items for comparison and diffing.Adds theme keys
for controlling the formatting; I'm not sure if this is the best way to do this. Maybe the item text should be configurable, or maybe the brackets should be part of the item text and not part of the open/close wrappers?
I initially implemented this with an
Emptyprimitive descriptor, but I thinkEmptyItembetter matches the data model. I can't think of a non-list context whereEmptywould be valid.This PR does not collapse empty items into e.g.
<5 empty items>likeutil.inspectdoes; that functionality seemed like a subset of #12.Closes #74.
This is a breaking change & bumps the serialization format version to 4.