Does this pattern synchronize the specified part of this function?
let mutex = Promise.resolve()
async function sync(): Promise<void> {
await (mutex = (async () => {
await mutex.catch((err) => console.error(err));
// Start of synchronization.
await new Promise((r) => setTimeout(r));
// End of synchronization.
})());
}