git ssb

1+

Matt McKegg / mutant



Tree: 01e9e1d516a0bcf09d486425ab7cba0f919f5a1a

Files: 01e9e1d516a0bcf09d486425ab7cba0f919f5a1a / lib / walk.js

355 bytesRaw
1module.exports = function walk (node, fn) {
2 var current = node
3 while (current) {
4 fn(current)
5 current = nextNode(current, node)
6 }
7}
8
9function nextNode (current, root) {
10 var result = current.firstChild
11 while (current && !result && current !== root) {
12 result = current.nextSibling
13 current = current.parentNode
14 }
15 return result
16}
17

Built with git-ssb-web