From 6bd08d932af247402f38714c5a5b9eb95e13057b Mon Sep 17 00:00:00 2001 From: Dominic Farolino Date: Tue, 23 Apr 2024 15:09:55 -0400 Subject: [PATCH] Fix predicate. Fix #140. --- spec.bs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/spec.bs b/spec.bs index c057324..d2de1bc 100644 --- a/spec.bs +++ b/spec.bs @@ -337,7 +337,7 @@ dictionary SubscribeOptions { AbortSignal signal; }; -callback Predicate = boolean (any value); +callback Predicate = boolean (any value, unsigned long long index); callback Reducer = any (any accumulator, any currentValue); callback Mapper = any (any element, unsigned long long index); // Differs from Mapper only in return type, since this callback is exclusively @@ -726,16 +726,20 @@ For now, see [https://github.com/wicg/observable#operators](https://github.com/w 1. Let |observable| be a [=new=] {{Observable}} whose [=Observable/subscribe callback=] is an algorithm that takes a {{Subscriber}} |subscriber| and does the following: + 1. Let |idx| be an {{unsigned long long}}, initially 0. + 1. Let |sourceObserver| be a new [=internal observer=], initialized as follows: : [=internal observer/next steps=] - :: 1. [=Invoke=] |predicate| with the passed in |value|, and let |matches| - be the returned value. + :: 1. [=Invoke=] |predicate| with the passed in |value| and |idx}, and let |matches| be + the returned value. If an exception |E| was thrown, then run |subscriber|'s {{Subscriber/error()}} method, given |E|, and abort these steps. + 1. Set |idx| to |idx| + 1. + 1. If |matches| is true, then run |subscriber|'s {{Subscriber/next()}} method, given |value|.