git ssb

1+

Matt McKegg / mutant



Tree: 0d72eea7c7d75e11ba0f148f6a9db9db0eeccdeb

Files: 0d72eea7c7d75e11ba0f148f6a9db9db0eeccdeb / lib / walk.js

375 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 || current.nextSibling
11 if (!result && current.parentNode && current.parentNode !== root) {
12 return current.nextSibling
13 } else {
14 return result
15 }
16}
17

Built with git-ssb-web