Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from(): Close synchronous iterators properly #192

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ urlPrefix: https://tc39.es/ecma262/#; spec: ECMASCRIPT
type: dfn
text: current realm
text: Object; url: sec-object-type
text: normal completion; url: sec-normalcompletion
text: throw completion; url: sec-throwcompletion
text: normal completion; url: sec-completion-record-specification-type
text: NormalCompletion; url: sec-normalcompletion
text: throw completion; url: sec-completion-record-specification-type
url: sec-returnifabrupt-shorthands
text: ?
text: !
Expand Down Expand Up @@ -502,6 +503,9 @@ An <dfn>internal observer</dfn> is a [=struct=] with the following [=struct/item
Otherwise, return a [=new=] {{Observable}} whose [=Observable/subscribe callback=] is an
algorithm that takes a {{Subscriber}} |subscriber| and does the following:

1. If |subscriber|'s [=Subscriber/subscription controller=]'s [=AbortController/signal=] is
[=AbortSignal/aborted=], then return.

1. Let |iteratorRecordCompletion| be [$GetIterator$](|value|, sync).

1. If |iteratorRecordCompletion| is a [=throw completion=], then run |subscriber|'s
Expand All @@ -510,6 +514,14 @@ An <dfn>internal observer</dfn> is a [=struct=] with the following [=struct/item

1. Let |iteratorRecord| be [=!=] |iteratorRecordCompletion|.

1. If |subscriber|'s [=Subscriber/subscription controller=]'s [=AbortController/signal=] is
[=AbortSignal/aborted=], then return.

1. [=AbortSignal/add|Add the following abort algorithm=] to |subscriber|'s
[=Subscriber/subscription controller=]'s [=AbortController/signal=]:

1. Run [$IteratorClose$](|iteratorRecord|, [=NormalCompletion=](UNUSED)).

1. [=iteration/While=] true:

1. Let |next| be [$IteratorStepValue$](|iteratorRecord|).
Expand All @@ -529,6 +541,9 @@ An <dfn>internal observer</dfn> is a [=struct=] with the following [=struct/item

1. Run |subscriber|'s {{Subscriber/next()}} given |next|.

1. If |subscriber|'s [=Subscriber/subscription controller=]'s [=AbortController/signal=]
is [=AbortSignal/aborted=], then [=iteration/break=].

1. <i id=from-promise-conversion><b>From Promise</b></i>: If [$IsPromise$](|value|) is true,
then:

Expand Down
Loading