automerge / automerge-classic

A JSON-like data structure (a CRDT) that can be modified concurrently by different users, and merged again automatically.
http://automerge.org/
MIT License
14.75k stars 467 forks source link

frontend: splice's deleteCount can overflow #301

Closed pierreprinetti closed 3 years ago

pierreprinetti commented 3 years ago

Before to this patch, calling splice on an Automerge list with a deleteCount that overflows the list results in a RangeError.

However, according to Mozilla's documentation (and tested on Node v14.15.4), splice's deleteCount argument can be equal or greater than the list. In that case, all the elements from start to the end of the array should be deleted.

With this patch, deleteCount can overflow the list's length and the behaviour is like no deleteCount was passed.

ept commented 3 years ago

Thank you @pierreprinetti, this is a nice contribution!