News for hackers. Stuff that matters.
Re:Node.js 16 Available Now by davidkunz on Tuesday April 20, 2021 @04:08PM (#26880822)
... or even more easily by:

const wait = require('util').promisify(setTimeout)

Re:Node.js 16 Available Now by Mogzol on Tuesday April 20, 2021 @04:24PM (#26881077)
That's interesting. util.promisify normally only works with functions where the callback is the final argument, which isn't the case with setTimeout. I didn't know you could customize promisify behaviour, but looking at the docs apparently you can just by setting a property on the object using the util.promisify.custom symbol [1]. That is what setTimeout is doing, which is why that code works.

[1] https://nodejs.org/dist/latest-v16.x/docs/api/util.html#util...