I was writing a web crawler and my code ended up looking like this:http.get(...) .then((res) => { if ( /* ... something to do with res ... */ ) { http.get(f(res)) .then((data) => { database.set(data) .then(/*... on and on ...*/) }) } }) And at the end of the day I was just thinking, why? Why isn't the compiler1 intelligent enough to realize that if I have a function that operates on promises, I'm going to want to operate on the promise's resolve and not the promise itself. Why have the programmer deal with this?var res = http.get(...); if (/* ... something to do with res ... */) { var data = http.get(f(res)); database.set(data) /*... on and on...*/ } 1: Node.js actually compiles JavaScript, right?
Submitted February 12, 2019 at 05:07PM by lolololololololol_ha
No comments:
Post a Comment