Code coverage report for lib/walk.js

Statements: 100% (7 / 7)      Branches: 100% (0 / 0)      Functions: 100% (2 / 2)      Lines: 100% (7 / 7)      Ignored: none     

All files » lib/ » walk.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21                  29 731 309 309 599     731     29  
/**
 * Apply a function to all comments within a hierarchy: this iterates
 * through children in the 'members' property.
 *
 * @param {Array<Object>} comments an array of nested comments
 * @param {Function} fn a walker function
 * @param {Object} [options] options passed through to walker function
 * @returns {Array<Object>} comments
 */
function walk(comments, fn, options) {
  comments.forEach(function (comment) {
    fn(comment, options);
    for (var scope in comment.members) {
      walk(comment.members[scope], fn, options);
    }
  });
  return comments;
}
 
module.exports = walk;