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

Function walk

packages/dev/docs/src/utils.js:13–28  ·  view source on GitHub ↗
(obj, fn, k = null)

Source from the content-addressed store, hash-verified

11 */
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
30export function getUsedLinks(obj, links, usedLinks = {}) {
31 walk(obj, (t, k, recurse) => {

Callers 2

recurseFunction · 0.70
getUsedLinksFunction · 0.70

Calls 1

fnFunction · 0.85

Tested by

no test coverage detected