Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 42x 97060x 53886x 43174x 43174x 482x 42692x 42692x 42692x 42468x 96236x 224x 42x | const walk = function(obj, path, validation) { if (typeof obj !== 'object' || obj === null) { return; } // don't walk down examples or extensions const current = path[path.length - 1]; if ( current === 'example' || current === 'examples' || (current && current.slice(0, 2) === 'x-') ) { return; } // run the validation code validation(obj, path); // recursively walk through the spec const childProperties = Object.keys(obj); if (childProperties.length) { return childProperties.map(key => { return walk(obj[key], [...path, key], validation); }); } else { return null; } }; module.exports = walk; |