Promise.prototype.finally ( _onFinally_ )
When the `finally` method is called with argument _onFinally_, the following steps are taken:
@@ -39248,54 +39248,24 @@ Promise.prototype.finally ( _onFinally_ )
1. Let _thenFinally_ be _onFinally_.
1. Let _catchFinally_ be _onFinally_.
1. Else,
- 1. Let _stepsThenFinally_ be the algorithm steps defined in .
- 1. Let _lengthThenFinally_ be the number of non-optional parameters of the function definition in .
- 1. Let _thenFinally_ be ! CreateBuiltinFunction(_stepsThenFinally_, _lengthThenFinally_, *""*, « [[Constructor]], [[OnFinally]] »).
- 1. Set _thenFinally_.[[Constructor]] to _C_.
- 1. Set _thenFinally_.[[OnFinally]] to _onFinally_.
- 1. Let _stepsCatchFinally_ be the algorithm steps defined in .
- 1. Let _lengthCatchFinally_ be the number of non-optional parameters of the function definition in .
- 1. Let _catchFinally_ be ! CreateBuiltinFunction(_stepsCatchFinally_, _lengthCatchFinally_, *""*, « [[Constructor]], [[OnFinally]] »).
- 1. Set _catchFinally_.[[Constructor]] to _C_.
- 1. Set _catchFinally_.[[OnFinally]] to _onFinally_.
+ 1. Let _thenFinallyClosure_ be a new Abstract Closure with parameters (_value_) that captures _onFinally_ and _C_ and performs the following steps when called:
+ 1. Let _result_ be ? Call(_onFinally_, *undefined*).
+ 1. Let _promise_ be ? PromiseResolve(_C_, _result_).
+ 1. Let _returnValue_ be a new Abstract Closure with no parameters that captures _value_ and performs the following steps when called:
+ 1. Return _value_.
+ 1. Let _valueThunk_ be ! CreateBuiltinFunction(_returnValue_, 0, *""*, « »).
+ 1. Return ? Invoke(_promise_, *"then"*, « _valueThunk_ »).
+ 1. Let _thenFinally_ be ! CreateBuiltinFunction(_thenFinallyClosure_, 1, *""*, « »).
+ 1. Let _catchFinallyClosure_ be a new Abstract Closure with parameters (_reason_) that captures _onFinally_ and _C_ and performs the following steps when called:
+ 1. Let _result_ be ? Call(_onFinally_, *undefined*).
+ 1. Let _promise_ be ? PromiseResolve(_C_, _result_).
+ 1. Let _throwReason_ be a new Abstract Closure with no parameters that captures _reason_ and performs the following steps when called:
+ 1. Return ThrowCompletion(_reason_).
+ 1. Let _thrower_ be ! CreateBuiltinFunction(_throwReason_, 0, *""*, « »).
+ 1. Return ? Invoke(_promise_, *"then"*, « _thrower_ »).
+ 1. Let _catchFinally_ be ! CreateBuiltinFunction(_catchFinallyClosure_, 1, *""*, « »).
1. Return ? Invoke(_promise_, *"then"*, « _thenFinally_, _catchFinally_ »).
-
-
- Then Finally Functions
- A Then Finally function is an anonymous built-in function that has a [[Constructor]] and an [[OnFinally]] internal slot. The value of the [[Constructor]] internal slot is a `Promise`-like constructor function object, and the value of the [[OnFinally]] internal slot is a function object.
- When a Then Finally function is called with argument _value_, the following steps are taken:
-
- 1. Let _F_ be the active function object.
- 1. Let _onFinally_ be _F_.[[OnFinally]].
- 1. Assert: IsCallable(_onFinally_) is *true*.
- 1. Let _result_ be ? Call(_onFinally_, *undefined*).
- 1. Let _C_ be _F_.[[Constructor]].
- 1. Assert: IsConstructor(_C_) is *true*.
- 1. Let _promise_ be ? PromiseResolve(_C_, _result_).
- 1. Let _valueThunk_ be equivalent to a function that returns _value_.
- 1. Return ? Invoke(_promise_, *"then"*, « _valueThunk_ »).
-
- The *"length"* property of a Then Finally function is *1*𝔽.
-
-
-
- Catch Finally Functions
- A Catch Finally function is an anonymous built-in function that has a [[Constructor]] and an [[OnFinally]] internal slot. The value of the [[Constructor]] internal slot is a `Promise`-like constructor function object, and the value of the [[OnFinally]] internal slot is a function object.
- When a Catch Finally function is called with argument _reason_, the following steps are taken:
-
- 1. Let _F_ be the active function object.
- 1. Let _onFinally_ be _F_.[[OnFinally]].
- 1. Assert: IsCallable(_onFinally_) is *true*.
- 1. Let _result_ be ? Call(_onFinally_, *undefined*).
- 1. Let _C_ be _F_.[[Constructor]].
- 1. Assert: IsConstructor(_C_) is *true*.
- 1. Let _promise_ be ? PromiseResolve(_C_, _result_).
- 1. Let _thrower_ be equivalent to a function that throws _reason_.
- 1. Return ? Invoke(_promise_, *"then"*, « _thrower_ »).
-
- The *"length"* property of a Catch Finally function is *1*𝔽.
-