From 6562a42563fa2b62e199e37d5011e4f7dcec4261 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 14 May 2024 15:12:48 -0700 Subject: [PATCH] Normative: add `Promise.try` (#3327) See https://github.com/tc39/proposal-promise-try/issues/15 --- spec.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec.html b/spec.html index 79650ed87f..61a186e898 100644 --- a/spec.html +++ b/spec.html @@ -46990,6 +46990,25 @@

+ +

Promise.try ( _callbackfn_, ..._args_ )

+

When the `try` method is called with argument _callbackfn_, the following steps are taken:

+ + 1. Let _C_ be the *this* value. + 1. If _C_ is not an Object, throw a *TypeError* exception. + 1. Let _promiseCapability_ be ? NewPromiseCapability(_C_). + 1. Let _status_ be Completion(Call(_callbackfn_, *undefined*, _args_)). + 1. If _status_ is an abrupt completion, then + 1. Perform ? Call(_promiseCapability_.[[Reject]], *undefined*, « _status_.[[Value]] »). + 1. Else, + 1. Perform ? Call(_promiseCapability_.[[Resolve]], *undefined*, « _status_.[[Value]] »). + 1. Return _promiseCapability_.[[Promise]]. + + +

This function expects its *this* value to be a constructor function that supports the parameter conventions of the Promise constructor.

+
+
+

Promise.withResolvers ( )

This function returns an object with three properties: a new promise together with the `resolve` and `reject` functions associated with it.