Resolve and reject
The Promise.resolve
and Promise.reject
functions create Promise
objects that immediately resolve or reject with the given values.
It's a useful shorthand for writing a full function to initialize a Promise
object and immediately call resolve
or reject
with a particular value.
The benefit of doing this, even for synchronous function that don't depend on asynchronous result, is that you can now use the function in a configurable chain of transformations that can include both synchronous and asynchronous work.
Loading TypeScript...