MCPcopy Create free account
hub / github.com/activejs/activejs / findRandomPath

Function findRandomPath

packages/core/src/tests/utils.ts:515–525  ·  view source on GitHub ↗
(o: any)

Source from the content-addressed store, hash-verified

513}
514
515export function findRandomPath(o: any): (string | number)[] {
516 if (!isObject(o) || randomBoolean(-0.6)) {
517 return [];
518 }
519 if (Array.isArray(o)) {
520 const randIndex = randomNumber(0, o.length - 1);
521 return !o.length ? [] : [randIndex, ...findRandomPath(o[randIndex])];
522 }
523 const randKey = selectRandom(Object.keys(o));
524 return randKey == null ? [] : [randKey, ...findRandomPath(o[randKey])];
525}
526
527export function findEqualitiesByReference(A: any, B: any): any[] {
528 if (A == null || B == null || typeof A !== 'object' || typeof B !== 'object') {

Callers 3

units.spec.tsFile · 0.90
makeUnitFunction · 0.90
makeCaseFunction · 0.90

Calls 4

isObjectFunction · 0.90
randomBooleanFunction · 0.85
randomNumberFunction · 0.85
selectRandomFunction · 0.85

Tested by 2

makeUnitFunction · 0.72
makeCaseFunction · 0.72