Skip to content

Commit ca13b07

Browse files
align sliding algo with chunks/windows algos more and fix bug
1 parent d8975db commit ca13b07

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

spec.emu

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ copyright: false
5555
1. Repeat,
5656
1. Let _value_ be ? IteratorStepValue(_iterated_).
5757
1. If _value_ is ~done~, then
58-
1. If _buffer_ is not empty and the number of elements in _buffer_ < ℝ(_windowSize_), perform ? Yield(CreateArrayFromList(_buffer_)).
58+
1. If _buffer_ is not empty and the number of elements in _buffer_ < ℝ(_windowSize_), then
59+
1. Perform Completion(Yield(CreateArrayFromList(_buffer_))).
5960
1. Return ReturnCompletion(*undefined*).
61+
1. If the number of elements in _buffer_ is ℝ(_windowSize_), then
62+
1. Remove the first element from _buffer_.
6063
1. Append _value_ to _buffer_.
6164
1. If the number of elements in _buffer_ is ℝ(_windowSize_), then
6265
1. Let _completion_ be Completion(Yield(CreateArrayFromList(_buffer_))).
6366
1. IfAbruptCloseIterator(_completion_, _iterated_).
64-
1. Remove the first element from _buffer_.
6567
1. Let _result_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
6668
1. Set _result_.[[UnderlyingIterators]] to « _iterated_ ».
6769
1. Return _result_.
@@ -84,11 +86,12 @@ copyright: false
8486
1. Repeat,
8587
1. Let _value_ be ? IteratorStepValue(_iterated_).
8688
1. If _value_ is ~done~, return ReturnCompletion(*undefined*).
89+
1. If the number of elements in _buffer_ is ℝ(_windowSize_), then
90+
1. Remove the first element from _buffer_.
8791
1. Append _value_ to _buffer_.
8892
1. If the number of elements in _buffer_ is ℝ(_windowSize_), then
8993
1. Let _completion_ be Completion(Yield(CreateArrayFromList(_buffer_))).
9094
1. IfAbruptCloseIterator(_completion_, _iterated_).
91-
1. Remove the first element from _buffer_.
9295
1. Let _result_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
9396
1. Set _result_.[[UnderlyingIterators]] to « _iterated_ ».
9497
1. Return _result_.

0 commit comments

Comments
 (0)