4 ms·
async/await is still pretty old by now. Maybe they wanted to be consistent with even older examples. I dunno, every single thing Google-related uses promises, s
by hot_gril 4y ago
async/await is still pretty old by now. Maybe they wanted to be consistent with even older examples. I dunno, every single thing Google-related uses promises, so I'm thinking they're partial to that for some reason.
Another example from 4mo ago: https://github.com/kubernetes-client/javascript/blob/master/examples/ingress.js https://github.com/kubernetes-client/javascript/blob/master/... (the catch at the end is a promise catch)
- WorldMaker 4y agoThere's a tiny benefit of the doubt to be given here that while async/await is several years old, support for "top-level await" was only more recently standardized and took too long for common LTS versions of Node to also support it. All of these examples appear to be top-level and perhaps they didn't want to write them as async functions or IIFEs, especially for error-handling code.
- hot_gril 4y agoThat makes sense, someone copy-pasting async code into a JS console would get errors not too long ago. There's nobody to blame for this but myself, just wish I discovered earlier on how async/await works, along with other modern JS stuff that you won't see everywhere because it's new.