Good point! I mainly wanted to explain how to handle it without the help of an additional tool in a still elegant solution. I think a recursive function wouldn't make it too readable. But yeah I agree that you should ideally use something that is a bit more sophisticated. Bluebird is certainly a good solution for this.
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.