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

Function get

packages/angular-virtual/src/proxy.ts:18–76  ·  view source on GitHub ↗
(target, property)

Source from the content-addressed store, hash-verified

16 return virtualizerSignal()
17 },
18 get(target, property) {
19 const untypedTarget = target as any
20 if (untypedTarget[property]) {
21 return untypedTarget[property]
22 }
23 let virtualizer = untracked(virtualizerSignal)
24 if (virtualizer == null) {
25 virtualizer = lazyInit()
26 untracked(() => virtualizerSignal.set(virtualizer))
27 }
28
29 // Create computed signals for each property that represents a reactive value
30 if (
31 typeof property === 'string' &&
32 [
33 'getTotalSize',
34 'getVirtualItems',
35 'isScrolling',
36 'options',
37 'range',
38 'scrollDirection',
39 'scrollElement',
40 'scrollOffset',
41 'scrollRect',
42 'measureElementCache',
43 'measurementsCache',
44 ].includes(property)
45 ) {
46 const isFunction =
47 typeof virtualizer[property as keyof V] === 'function'
48 Object.defineProperty(untypedTarget, property, {
49 value: isFunction
50 ? computed(() => (target()[property as keyof V] as Function)())
51 : computed(() => target()[property as keyof V]),
52 configurable: true,
53 enumerable: true,
54 })
55 }
56
57 // Create plain signals for functions that accept arguments and return reactive values
58 if (
59 typeof property === 'string' &&
60 [
61 'getOffsetForAlignment',
62 'getOffsetForIndex',
63 'getVirtualItemForOffset',
64 'indexFromElement',
65 ].includes(property)
66 ) {
67 const fn = virtualizer[property as keyof V] as Function
68 Object.defineProperty(untypedTarget, property, {
69 value: toComputed(virtualizerSignal, fn),
70 configurable: true,
71 enumerable: true,
72 })
73 }
74
75 return untypedTarget[property] || virtualizer[property as keyof V]

Callers

nothing calls this directly

Calls 2

lazyInitFunction · 0.85
toComputedFunction · 0.85

Tested by

no test coverage detected