MCPcopy Index your code
hub / github.com/TanStack/db / checkIfReverted

Function checkIfReverted

packages/db/src/proxy.ts:718–783  ·  view source on GitHub ↗
(
    state: ChangeTracker<Record<string | symbol, unknown>>,
  )

Source from the content-addressed store, hash-verified

716
717 // Check if all properties in the current state have reverted to original values
718 function checkIfReverted(
719 state: ChangeTracker<Record<string | symbol, unknown>>,
720 ): boolean {
721 debugLog(
722 `checkIfReverted called with assigned keys:`,
723 Object.keys(state.assigned_),
724 )
725
726 // If there are no assigned properties, object is unchanged
727 if (
728 Object.keys(state.assigned_).length === 0 &&
729 Object.getOwnPropertySymbols(state.assigned_).length === 0
730 ) {
731 debugLog(`No assigned properties, returning true`)
732 return true
733 }
734
735 // Check each assigned regular property
736 for (const prop in state.assigned_) {
737 // If this property is marked as assigned
738 if (state.assigned_[prop] === true) {
739 const currentValue = state.copy_[prop]
740 const originalValue = (state.originalObject as any)[prop]
741
742 debugLog(
743 `Checking property ${String(prop)}, current:`,
744 currentValue,
745 `original:`,
746 originalValue,
747 )
748
749 // If the value is not equal to original, something is still changed
750 if (!deepEquals(currentValue, originalValue)) {
751 debugLog(`Property ${String(prop)} is different, returning false`)
752 return false
753 }
754 } else if (state.assigned_[prop] === false) {
755 // Property was deleted, so it's different from original
756 debugLog(`Property ${String(prop)} was deleted, returning false`)
757 return false
758 }
759 }
760
761 // Check each assigned symbol property
762 const symbolProps = Object.getOwnPropertySymbols(state.assigned_)
763 for (const sym of symbolProps) {
764 if (state.assigned_[sym] === true) {
765 const currentValue = (state.copy_ as any)[sym]
766 const originalValue = (state.originalObject as any)[sym]
767
768 // If the value is not equal to original, something is still changed
769 if (!deepEquals(currentValue, originalValue)) {
770 debugLog(`Symbol property is different, returning false`)
771 return false
772 }
773 } else if (state.assigned_[sym] === false) {
774 // Property was deleted, so it's different from original
775 debugLog(`Symbol property was deleted, returning false`)

Callers 2

checkParentStatusFunction · 0.85
setFunction · 0.85

Calls 3

deepEqualsFunction · 0.90
debugLogFunction · 0.85
keysMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…