Skip to content

Commit e2c5df7

Browse files
committed
replace extra method with string parameter
1 parent ce8b1cc commit e2c5df7

File tree

1 file changed

+8
-32
lines changed

1 file changed

+8
-32
lines changed

spec.emu

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ copyright: false
3939
</emu-alg>
4040
</emu-clause>
4141

42-
<emu-clause id="sec-iterator.prototype.sliding">
43-
<h1>Iterator.prototype.sliding ( _windowSize_ )</h1>
42+
<emu-clause id="sec-iterator.prototype.windows">
43+
<h1>Iterator.prototype.windows ( _windowSize_ [ , _undersized_ ] )</h1>
4444
<p>This method performs the following steps when called:</p>
4545
<emu-alg>
4646
1. Let _O_ be the *this* value.
@@ -49,13 +49,17 @@ copyright: false
4949
1. If _windowSize_ is not an integral Number in the inclusive interval from *1*<sub>𝔽</sub> to 𝔽(2<sup>32</sup> - 1), then
5050
1. Let _error_ be ThrowCompletion(a newly created *RangeError* object).
5151
1. Return ? IteratorClose(_iterated_, _error_).
52+
1. If _undersized_ is *undefined*, set _undersized_ to *"skip"*.
53+
1. If _undersized_ is neither *"skip"* nor *"truncate"*, then
54+
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
55+
1. Return ? IteratorClose(_iterated_, _error_).
5256
1. Set _iterated_ to ? GetIteratorDirect(_O_).
53-
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _windowSize_ and performs the following steps when called:
57+
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_, _windowSize_, and _undersized_ and performs the following steps when called:
5458
1. Let _buffer_ be a new empty List.
5559
1. Repeat,
5660
1. Let _value_ be ? IteratorStepValue(_iterated_).
5761
1. If _value_ is ~done~, then
58-
1. If _buffer_ is not empty and the number of elements in _buffer_ &lt; ℝ(_windowSize_), then
62+
1. If _undersized_ is *"truncate"*, _buffer_ is not empty, and the number of elements in _buffer_ &lt; ℝ(_windowSize_), then
5963
1. Perform Completion(Yield(CreateArrayFromList(_buffer_))).
6064
1. Return ReturnCompletion(*undefined*).
6165
1. If the number of elements in _buffer_ is ℝ(_windowSize_), then
@@ -69,31 +73,3 @@ copyright: false
6973
1. Return _result_.
7074
</emu-alg>
7175
</emu-clause>
72-
73-
<emu-clause id="sec-iterator.prototype.windows">
74-
<h1>Iterator.prototype.windows ( _windowSize_ )</h1>
75-
<p>This method performs the following steps when called:</p>
76-
<emu-alg>
77-
1. Let _O_ be the *this* value.
78-
1. If _O_ is not an Object, throw a *TypeError* exception.
79-
1. Let _iterated_ be the Iterator Record { [[Iterator]]: _O_, [[NextMethod]]: *undefined*, [[Done]]: *false* }.
80-
1. If _windowSize_ is not an integral Number in the inclusive interval from *1*<sub>𝔽</sub> to 𝔽(2<sup>32</sup> - 1), then
81-
1. Let _error_ be ThrowCompletion(a newly created *RangeError* object).
82-
1. Return ? IteratorClose(_iterated_, _error_).
83-
1. Set _iterated_ to ? GetIteratorDirect(_O_).
84-
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _windowSize_ and performs the following steps when called:
85-
1. Let _buffer_ be a new empty List.
86-
1. Repeat,
87-
1. Let _value_ be ? IteratorStepValue(_iterated_).
88-
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_.
91-
1. Append _value_ to _buffer_.
92-
1. If the number of elements in _buffer_ is ℝ(_windowSize_), then
93-
1. Let _completion_ be Completion(Yield(CreateArrayFromList(_buffer_))).
94-
1. IfAbruptCloseIterator(_completion_, _iterated_).
95-
1. Let _result_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
96-
1. Set _result_.[[UnderlyingIterators]] to « _iterated_ ».
97-
1. Return _result_.
98-
</emu-alg>
99-
</emu-clause>

0 commit comments

Comments
 (0)