MCPcopy Index your code
hub / github.com/plotly/dash / crawlLayout

Function crawlLayout

dash/dash-renderer/src/actions/utils.js:40–169  ·  view source on GitHub ↗
(
    object,
    func,
    currentPath = [],
    extraPath = undefined
)

Source from the content-addressed store, hash-verified

38
39// crawl a layout object or children array, apply a function on every object
40export const crawlLayout = (
41 object,
42 func,
43 currentPath = [],
44 extraPath = undefined
45) => {
46 if (Array.isArray(object)) {
47 // children array
48 object.forEach((child, i) => {
49 if (extraPath) {
50 const objOf = findIndex(p => includes('{}', p), extraPath);
51 if (objOf !== -1) {
52 const front = slice(0, objOf, extraPath);
53 const back = slice(objOf, extraPath.length, extraPath);
54 if (front.length) {
55 crawlLayout(
56 path(front, child),
57 func,
58 concat(currentPath, concat([i], front)),
59 back
60 );
61 } else {
62 const backPath = back
63 .map(p => p.replace('{}', ''))
64 .filter(e => e);
65 let childObj,
66 childPath = concat([i], backPath);
67 if (backPath.length) {
68 childObj = path(backPath, child);
69 } else {
70 childObj = child;
71 }
72 for (const key in childObj) {
73 const value = childObj[key];
74 crawlLayout(
75 value,
76 func,
77 concat(currentPath, childPath.concat([key]))
78 );
79 }
80 }
81 } else {
82 crawlLayout(
83 path(extraPath, child),
84 func,
85 concat(currentPath, concat([i], extraPath))
86 );
87 }
88 } else {
89 crawlLayout(child, func, append(i, currentPath));
90 }
91 });
92 } else if (type(object) === 'Object') {
93 func(object, currentPath);
94
95 const children = path(propsChildren, object);
96 if (children) {
97 const newPath = concat(currentPath, propsChildren);

Callers 2

computePathsFunction · 0.90

Calls 3

funcFunction · 0.85
filterMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…