MCPcopy
hub / github.com/vitest-dev/vitest / getDescriptor

Function getDescriptor

packages/spy/src/index.ts:406–419  ·  view source on GitHub ↗
(obj: any, method: string | symbol | number)

Source from the content-addressed store, hash-verified

404}
405
406function getDescriptor(obj: any, method: string | symbol | number): [any, PropertyDescriptor] | undefined {
407 const objDescriptor = Object.getOwnPropertyDescriptor(obj, method)
408 if (objDescriptor) {
409 return [obj, objDescriptor]
410 }
411 let currentProto = Object.getPrototypeOf(obj)
412 while (currentProto !== null) {
413 const descriptor = Object.getOwnPropertyDescriptor(currentProto, method)
414 if (descriptor) {
415 return [currentProto, descriptor]
416 }
417 currentProto = Object.getPrototypeOf(currentProto)
418 }
419}
420
421function assert(condition: any, message: string): asserts condition {
422 if (!condition) {

Callers 2

spyOnFunction · 0.85

Calls 1

Tested by

no test coverage detected