Closed iacore closed 4 weeks ago
Thanks! This is definitely an issue. Part of the issue is with the readme. The readme claims that sequence.generate_braid
will generate [0, 0, 'hello']
. There are two problems with this. First, it should generate an array within an array: [[0, 0, 'hello']]
. Second, as it stands, it returns []
; this can be fixed with this new code:
var sequence = require('./antimatter').sequence_crdt
// modified line:
var root_node = sequence.create_node('root', '')
// new line:
sequence.add_version(root_node, 'alice1', [[0, 0, 'hello']], null, x => true)
console.log(sequence.generate_braid(root_node, 'alice1', x => false))
This code adds a line with add_version
. This creates a tree with two nodes: "root" and "alice1", whereas the original readme code creates a tree with just one node "alice1".
This issue is that generate_braid
treats the root node in a special way, and in particular, never includes the root node text in the returned splices.
I say "part of the issue" is with the readme because another part may be with this decision to treat the root node in a special way.. I'll need to ponder that a bit. If it makes sense to not treat the root node in a special way, then the readme can stay the same, except for the array-within-an-array [[...]]
bit which I have just fixed.
So, I've done a couple things to hopefully satisfy this issue for the moment.
add_version
line, in addition to returning an array-of-arrays.
The output doesn't match what the readme says.