From 32e2195d145f94d2e7d8e482b33deb6615ad32b4 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 15 Oct 2024 17:31:15 -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 83ad94623b..05e17a16c5 100644 --- a/spec.html +++ b/spec.html @@ -47589,6 +47589,25 @@

+ +

Promise.try ( _callback_, ..._args_ )

+

When the `try` method is called with argument _callback_, 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(_callback_, *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.