I have long-running function that can be called several times in short period of time. I dont realy need to await her, so I want following: If previous instance of function is still running, next runs should wait for previous one to finish.
Simplest/correct way to solve?
I have created a tiny package called mutually-exclusive-functions that is capable of doing what you want.
const { exclude } = require("mutually-exclusive-functions");
async function f1() {};
[f1] = exclude([f1]);
Now if you execute f1, it will queue further calls and only execute them after the previous calls have finished execution.