Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const promises = Object.keys(layer).map(key => {
// Only fetch links & restrict total search queries to maxBreadth ^ maxDepth requests
if (!Gun.val.link.is(layer[key]) || ++bcount >= opts.maxBreadth) {
return;
}
// During one recursive lookup, don't fetch the same key multiple times
if (opts.cache[key]) {
return opts.cache[key].then(data => {
layer[key] = data;
});
}
return opts.cache[key] = loadGunDepth(chain.get(key), maxDepth - 1, opts).then(data => {
layer[key] = data;
});
});