From d35a8676fc4f9ea2166652978805e2a576aa1270 Mon Sep 17 00:00:00 2001 From: Dominic Farolino Date: Tue, 27 Aug 2024 15:24:45 -0400 Subject: [PATCH] Finish --- spec.bs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/spec.bs b/spec.bs index 7fd51ae..79c1e27 100644 --- a/spec.bs +++ b/spec.bs @@ -1628,17 +1628,19 @@ For now, see [https://github.com/wicg/observable#operators](https://github.com/w 1. Let |idx| be an {{unsigned long long}}, initially 0. - 1. Let |accumulator| be |initialValue| if it is given, and the string "unset" otherwise. + 1. Let |accumulator| be |initialValue| if it is given, and the string "unset" + otherwise. 1. Let |observer| be a new [=internal observer=], initialized as follows: : [=internal observer/next steps=] - :: 1. If |accumulator| is the string "unset", then set |accumulator| to the - passed in |value| and abort these steps. + :: + 1. If |accumulator| is the string "unset", then set |accumulator| to the + passed in |value|, set |idx| to |idx| + 1, and abort these steps. Note: This means that |reducer| will not be called with the first |value| that [=this=] produces set as the {{Reducer/currentValue}}. Rather, when the *second* value is - eventually emitted, we will call |reducer| with *it* as the {[Reducer/currentValue}}, + eventually emitted, we will call |reducer| with *it* as the {{Reducer/currentValue}}, and the first value (that we're saving here) as the {{Reducer/accumulator}}. 1. [=Invoke=] |reducer| with |accumulator| as {{Reducer/accumulator}}, the passed in @@ -1648,15 +1650,17 @@ For now, see [https://github.com/wicg/observable#operators](https://github.com/w If an exception |E| was thrown, then [=reject=] |p| with |E|, and [=AbortController/signal abort=] |controller| with |E|. - 1. Set |idx| to |idx| + 1. + 1. Set |idx| to |idx| + 1. - 1. Set |accumulator| to |result|. + 1. Set |accumulator| to |result|. : [=internal observer/error steps=] :: [=Reject=] |p| with the passed in error. : [=internal observer/complete steps=] - :: [=Resolve=] |p| with false. + :: 1. If |accumulator| is not "unset", then [=resolve=] |p| with |accumulator|. + + Otherwise, [=reject=] |p| with a {{TypeError}}. 1. Subscribe to [=this=] given |observer| and |internal options|.