(obj)
| 222 | walkLinks(result); |
| 223 | |
| 224 | function walkLinks(obj) { |
| 225 | let fn = t => { |
| 226 | // don't follow the link if it's already in links, that's circular |
| 227 | if (t && t.type === 'link' && !links[t.id]) { |
| 228 | links[t.id] = nodes[t.id]; |
| 229 | recurse(nodes[t.id], fn); |
| 230 | } |
| 231 | |
| 232 | if (t != null) { |
| 233 | return recurse(t, fn); |
| 234 | } |
| 235 | }; |
| 236 | |
| 237 | for (let k in obj) { |
| 238 | fn(obj[k]); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | return {contents: JSON.stringify({exports: result, links}, false, 2)}; |
| 243 | } |