It's difficult to mentally follow the chain of promises here, because you have an async function (const asyncLimit = async...) which returns an async function (return async function) which itself awaits at least two promises (one in a loop) before resolving.
const asyncLimit = async...
return async function
Note that asyncLimit does not have to be async, as it does not use await; removing async from the function signature would help comprehension a bit, since you would reduce one level of Promise-ception and stay out of limbo.
I guess it doesn't really matter, because the promise returned by asyncLimit can be used by the calling code. But attaching a finally clause to p instead of awaiting it allows the function to return immediately, instead of waiting for p to resolve.
oh, I mistyped haha! Thanks for catching this!
asyncLimit shouldn't be an async function.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.