-
-
Save nshahpazov/598e8499491327941973 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function traverse(node) { | |
return Promise.all(R.map(c => Promise.resolve(c), node.children)) | |
.then((nodes) => { | |
return Promise.all(nodes.map(traverse)) | |
.then(R.reduce((prev, arr) => arr.concat(prev), [])) | |
.then(els => els.concat(nodes)); | |
}); | |
} | |
traverse(document.body).then(R.map(e => console.log(e.tagName))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment