mirror of
https://github.com/documentationjs/documentation.git
synced 2026-01-18 14:17:30 +00:00
20 lines
495 B
JavaScript
20 lines
495 B
JavaScript
/**
|
|
* 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
|
|
* @returns {Array<Object>} comments
|
|
*/
|
|
function walk(comments, fn) {
|
|
comments.forEach(function (comment) {
|
|
fn(comment);
|
|
for (var scope in comment.members) {
|
|
walk(comment.members[scope], fn);
|
|
}
|
|
});
|
|
return comments;
|
|
}
|
|
|
|
module.exports = walk;
|