From 6d4281bd521a40a1681ed7690429af9d97f5a035 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 7 Apr 2026 16:07:14 -0700 Subject: [PATCH] [spec] close iterator if abrupt during StepValue --- spec.emu | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec.emu b/spec.emu index 1eeb8fa..9dcc1ac 100644 --- a/spec.emu +++ b/spec.emu @@ -23,7 +23,9 @@ copyright: false 1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _chunkSize_ and performs the following steps when called: 1. Let _buffer_ be a new empty List. 1. Repeat, - 1. Let _value_ be ? IteratorStepValue(_iterated_). + 1. Let _result_ be Completion(IteratorStepValue(_iterated_)). + 1. IfAbruptCloseIterator(_result_, _iterated_). + 1. Let _value_ be ! _result_. 1. If _value_ is ~done~, then 1. If _buffer_ is not empty, then 1. Perform Completion(Yield(CreateArrayFromList(_buffer_))). @@ -57,7 +59,9 @@ copyright: false 1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_, _windowSize_, and _undersized_ and performs the following steps when called: 1. Let _buffer_ be a new empty List. 1. Repeat, - 1. Let _value_ be ? IteratorStepValue(_iterated_). + 1. Let _result_ be Completion(IteratorStepValue(_iterated_)). + 1. IfAbruptCloseIterator(_result_, _iterated_). + 1. Let _value_ be ! _result_. 1. If _value_ is ~done~, then 1. If _undersized_ is *"allow-partial"*, _buffer_ is not empty, and the number of elements in _buffer_ < ℝ(_windowSize_), then 1. Perform Completion(Yield(CreateArrayFromList(_buffer_))).