Promise.try
Less than 1 minute
Promise.try
Note
This proposal is dead and will be removed from the next major Core-JS version.
Module
Types
interface PromiseConstructor {
try<T>(callbackfn: () => T | Promise<T>): Promise<T>;
}
Entry points
core-js/proposals/promise-try
core-js(-pure)/full/promise/try
Example
Promise.try(() => 42).then((it) => console.log(`Promise, resolved as ${it}`));
Promise.try(() => {
throw 42;
}).catch((it) => console.log(`Promise, rejected as ${it}`));