ottypes / json0

Version 0 of the JSON OT type
447 stars 64 forks source link

Why return path.length - 1 for object operations? #36

Open happy15 opened 3 years ago

happy15 commented 3 years ago

It makes sense to return path.length-1 as common length for list operations since the last element of path for list operations are index.

But why the same for object operations? If object operation A can be transformed regarding object operation B, A.p should be a strict prefix array of B.p. The part to transform object operations did that by checking c.p[common] and otherC.p[common] again.

From the code using the result common of json0.transformComponent(...) I see that it will access the last element by p[common], so it's just for implementation convenience (no more p[common-1]) or serve other purposes?

json0 rocks and looking forward to some hints.