UNPKG

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