MCPcopy Create free account
hub / github.com/eclipsesource/jsonforms / traverse

Function traverse

packages/core/src/testers/testers.ts:480–516  ·  view source on GitHub ↗
(
  any: JsonSchema | JsonSchema[],
  pred: (obj: JsonSchema) => boolean,
  rootSchema: JsonSchema
)

Source from the content-addressed store, hash-verified

478export const isObjectArrayControl = and(uiTypeIs('Control'), isObjectArray);
479
480const traverse = (
481 any: JsonSchema | JsonSchema[],
482 pred: (obj: JsonSchema) => boolean,
483 rootSchema: JsonSchema
484): boolean => {
485 if (Array.isArray(any)) {
486 return reduce(
487 any,
488 (acc, el) => acc || traverse(el, pred, rootSchema),
489 false
490 );
491 }
492
493 if (pred(any)) {
494 return true;
495 }
496
497 if (any.$ref) {
498 const toTraverse = resolveSchema(rootSchema, any.$ref, rootSchema);
499 if (toTraverse && !toTraverse.$ref) {
500 return traverse(toTraverse, pred, rootSchema);
501 }
502 }
503
504 if (any.items) {
505 return traverse(any.items, pred, rootSchema);
506 }
507 if (any.properties) {
508 return reduce(
509 toPairs(any.properties),
510 (acc, [_key, val]) => acc || traverse(val, pred, rootSchema),
511 false
512 );
513 }
514
515 return false;
516};
517
518export const isObjectArrayWithNesting = (
519 uischema: UISchemaElement,

Callers 1

isObjectArrayWithNestingFunction · 0.85

Calls 1

resolveSchemaFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…