encode method
Encode to a JSON-compatible structure. encodeValue maps one element
value to a JSON-compatible form.
Implementation
Object encode(Object? Function(T) encodeValue) {
final rows = <Object?>[];
for (final b in _blocks.values) {
rows.add(<Object?>[
b.start.counter,
b.start.replica,
b.parent.counter,
b.parent.replica,
b.side == Side.right ? 1 : 0,
[for (final v in b.values) encodeValue(v)],
_encodeDeleted(b.deleted),
]);
}
return <String, Object?>{'v': 1, 'b': rows};
}