Re:Skills Poor Programmers Lack
by kevsim on Sunday July 21, 2019 @02:29PM
(#20492851)
I guess because inside of a then() you can simply return the success case and throw the error case, no need to create a new Promise and call the resolve/reject functions.
[ Parent
| on HN ]
Was trying to think of exceptions to this when I read and and could only think of one: When you need to wrap a callback API with unusual callback arguments, where a `promisify` like helper won't work. Then again, I still feel the wrapping function should be defined outside of the `then`, as it feels like this is a separate utility to the work being done in the Promise chain.
This is the context I’ve used it in