MCPcopy
hub / github.com/vuejs/core / searchProxy

Function searchProxy

packages/reactivity/src/arrayInstrumentations.ts:340–357  ·  view source on GitHub ↗
(
  self: unknown[],
  method: keyof Array<any>,
  args: unknown[],
)

Source from the content-addressed store, hash-verified

338
339// instrument identity-sensitive methods to account for reactive proxies
340function searchProxy(
341 self: unknown[],
342 method: keyof Array<any>,
343 args: unknown[],
344) {
345 const arr = toRaw(self) as any
346 track(arr, TrackOpTypes.ITERATE, ARRAY_ITERATE_KEY)
347 // we run the method using the original args first (which may be reactive)
348 const res = arr[method](...args)
349
350 // if that didn't work, run it again using raw values.
351 if ((res === -1 || res === false) && isProxy(args[0])) {
352 args[0] = toRaw(args[0])
353 return arr[method](...args)
354 }
355
356 return res
357}
358
359// instrument length-altering mutation methods to avoid length being tracked
360// which leads to infinite loops in some cases (#2137)

Callers 3

includesFunction · 0.85
indexOfFunction · 0.85
lastIndexOfFunction · 0.85

Calls 3

toRawFunction · 0.90
trackFunction · 0.90
isProxyFunction · 0.90

Tested by

no test coverage detected