Validity checking insert/delete/retain operations
Closed this issue · 1 comments
I saw that the documentation calls out the lack of validity checks on operations/deltas provided to the constructor of a Delta
, but is there any interest in providing basic checks on insert
/delete
/retain
operations?
For example, if you call .insert(undefined)
on any well-formed Delta
and use diff
to compare that Delta
to another, it will raise an exception. Likewise, you can call .retain
or .delete
with a non-number value and it can produce an ill-formed Delta
. I've been using this library in a few projects (and it's fantastic) but was bitten after not guarding the type of a network call, inserting undefined
.
If that's of interest, I'd be happy to make a PR. I already opened up a fork with a simple undefined
check.
No there are many cases of invalidity and we'd rather keep logic simple and performant rather than partial solutions. As for invalidity due to types this should be addressed by Typescript. We understand not all projects are in Typescript but that is the point of Typescript.