Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
validateAndApplySequence(tree, sequence) {
try {
// we don't want this changes to generate patches since they originate from server, not client
this.unobserve();
const results = applyPatch(tree, sequence, this.debug);
// notifications have to happen only where observe has been re-enabled
// otherwise some listener might produce changes that would go unnoticed
this.observe();
// the state was fully replaced
if (results.newDocument !== tree) {
// object was reset, proxify it again
this.prepareProxifiedObject(results.newDocument);
this.queue.obj = this.obj;
// validate json response
findRangeErrors(this.obj, this.onIncomingPatchValidationError);
// Catch errors in onStateReset
try {
this.onStateReset(this.obj);
} catch (error) {