4 ms·
If you rewrite it so it's no longer a cryptic one-liner, it's probably easier to understand this way without a comment than the other way with one. return
by ninthcat 5y ago
If you rewrite it so it's no longer a cryptic one-liner, it's probably easier to understand this way without a comment than the other way with one.
return this.page.$eval(selector, (node) => Array
.from(node.childNodes)
.filter((child) => child.nodeType == Node.TEXT_NODE)
.map((child) => child.nodeValue)
.join('')
.replace(/\s+/g, ' ')
.trim()
);
- dmurray 5y agoHope this refactor was well unit tested, because it looks to do something a lot different from the original code.