News for hackers. Stuff that matters.
Re:Rust’s async isn’t colored by moron4hire on Thursday March 11, 2021 @10:58AM (#26425394)
In JavaScript, you can await a non-promise returning function and it's a NO-OP. So if you are taking a function as a parameter, you can await it safely, regardless of whether it's async or not.

   function giveMe3() { return 3; }
   function giveMe3Async() { return Promise.resolve(3); }

   async function logger(func) { return console.log(await func()); }

   await logger(giveMe3);
   await logger(giveMe3Async);

There are no comments on this comment yet.