MCPcopy Create free account
hub / github.com/adobe/react-spectrum / recurse

Function recurse

packages/dev/docs/src/utils.js:14–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12
13export function walk(obj, fn, k = null) {
14 let recurse = obj => {
15 if (Array.isArray(obj)) {
16 return obj.map((item, i) => walk(item, fn, k));
17 } else if (obj && typeof obj === 'object') {
18 let res = {};
19 for (let key in obj) {
20 res[key] = walk(obj[key], fn, key);
21 }
22 return res;
23 } else {
24 return obj;
25 }
26 };
27 return fn(obj, k, recurse);
28}
29

Callers 1

getUsedLinksFunction · 0.70

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected