Promise.try
Specification
Proposal repo
Modules
es.promise.try.
Built-ins signatures
class Promise {
static try(callbackfn: Function, ...args: Array<mixed>): Promise;
}
core-js/proposals/promise-try
core-js(-pure)/es|stable|actual|full/promise/try
Examples
Promise.try(() => 42).then(it => console.log(`Promise, resolved as ${ it }`));
Promise.try(() => { throw new Error('42'); }).catch(error => console.log(`Promise, rejected as ${ error }`));
Promise.try(async () => 42).then(it => console.log(`Promise, resolved as ${ it }`));
Promise.try(async () => { throw new Error('42'); }).catch(error => console.log(`Promise, rejected as ${ error }`));
Promise.try(it => it, 42).then(it => console.log(`Promise, resolved as ${ it }`));