Hacker News new | past | comments | ask | show | jobs | submit login

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()
    );



Hope this refactor was well unit tested, because it looks to do something a lot different from the original code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: