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

Function get

packages/db/src/proxy.ts:821–921  ·  view source on GitHub ↗
(ptarget, prop)

Source from the content-addressed store, hash-verified

819 // Create a proxy for the object
820 const proxy = new Proxy(obj, {
821 get(ptarget, prop) {
822 debugLog(`get`, ptarget, prop)
823 const value =
824 changeTracker.copy_[prop as keyof T] ??
825 changeTracker.originalObject[prop as keyof T]
826
827 const originalValue = changeTracker.originalObject[prop as keyof T]
828
829 debugLog(`value (at top of proxy get)`, value)
830
831 // If it's a getter, return the value directly
832 const desc = Object.getOwnPropertyDescriptor(ptarget, prop)
833 if (desc?.get) {
834 return value
835 }
836
837 // If the value is a function, bind it to the ptarget
838 if (typeof value === `function`) {
839 // For Array methods that modify the array
840 if (Array.isArray(ptarget)) {
841 const methodName = prop.toString()
842
843 if (ARRAY_MODIFYING_METHODS.has(methodName)) {
844 return createModifyingMethodHandler(
845 value,
846 changeTracker,
847 markChanged,
848 )
849 }
850
851 // Handle array iteration methods (find, filter, forEach, etc.)
852 const iterationHandler = createArrayIterationHandler(
853 methodName,
854 value,
855 changeTracker,
856 memoizedCreateChangeProxy,
857 )
858 if (iterationHandler) {
859 return iterationHandler
860 }
861
862 // Handle array Symbol.iterator for for...of loops
863 if (prop === Symbol.iterator) {
864 return createArrayIteratorHandler(
865 changeTracker,
866 memoizedCreateChangeProxy,
867 )
868 }
869 }
870
871 // For Map and Set methods that modify the collection
872 if (ptarget instanceof Map || ptarget instanceof Set) {
873 const methodName = prop.toString()
874
875 if (MAP_SET_MODIFYING_METHODS.has(methodName)) {
876 return createModifyingMethodHandler(
877 value,
878 changeTracker,

Callers

nothing calls this directly

Calls 10

debugLogFunction · 0.85
isProxiableObjectFunction · 0.85
toStringMethod · 0.45
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected