This is reasonable. The separate functions get queued as microtasks in the event loop and will probably complete in the same loop depending on how fast they return. The overhead of a Promise is minimal and modern javascript engines (if you're running this in a browser) are already well optimized for it.
The downside is you may need to continue using Promises if you want to deal with the result of the entire chain inline with other stuff, or you can just use an await at the beginning.
This is a good point - once you start promising you can't stop! Thanks for pointing that out - it's definitely helpful to keep in mind.
I haven't done speed tests, but I've run tests to see if I can get promises in a chain to run out of order, and I haven't found a way to break it yet. Admittedly, I'm no JavaScript hacker, but I'm generally pleased with the approach thus far.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is reasonable. The separate functions get queued as microtasks in the event loop and will probably complete in the same loop depending on how fast they return. The overhead of a Promise is minimal and modern javascript engines (if you're running this in a browser) are already well optimized for it.
The downside is you may need to continue using Promises if you want to deal with the result of the entire chain inline with other stuff, or you can just use an
await
at the beginning.This is a good point - once you start promising you can't stop! Thanks for pointing that out - it's definitely helpful to keep in mind.
I haven't done speed tests, but I've run tests to see if I can get promises in a chain to run out of order, and I haven't found a way to break it yet. Admittedly, I'm no JavaScript hacker, but I'm generally pleased with the approach thus far.