Skip to content

Commit 9cabc8b

Browse files
committed
add "throw" option
1 parent ab56d45 commit 9cabc8b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

spec.emu

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ copyright: false
5050
1. Let _error_ be ThrowCompletion(a newly created *RangeError* object).
5151
1. Return ? IteratorClose(_iterated_, _error_).
5252
1. If _undersized_ is *undefined*, set _undersized_ to *"discard"*.
53-
1. If _undersized_ is neither *"discard"* nor *"truncate"*, then
53+
1. If _undersized_ is not one of *"discard"*, *"truncate"*, or *"throw"*, then
5454
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
5555
1. Return ? IteratorClose(_iterated_, _error_).
5656
1. Set _iterated_ to ? GetIteratorDirect(_O_).
@@ -59,8 +59,13 @@ copyright: false
5959
1. Repeat,
6060
1. Let _value_ be ? IteratorStepValue(_iterated_).
6161
1. If _value_ is ~done~, then
62-
1. If _undersized_ is *"truncate"*, _buffer_ is not empty, and the number of elements in _buffer_ < ℝ(_windowSize_), then
63-
1. Perform Completion(Yield(CreateArrayFromList(_buffer_))).
62+
1. If _buffer_ is not empty and the number of elements in _buffer_ < ℝ(_windowSize_), then
63+
1. If _undersized_ is *"truncate"*, then
64+
1. Perform Completion(Yield(CreateArrayFromList(_buffer_))).
65+
1. Else if _undersized_ is *"throw"*, then
66+
1. Throw a newly created *RangeError* object.
67+
1. Else,
68+
1. Assert: _undersized_ is *"discard"*.
6469
1. Return ReturnCompletion(*undefined*).
6570
1. If the number of elements in _buffer_ is ℝ(_windowSize_), then
6671
1. Remove the first element from _buffer_.

0 commit comments

Comments
 (0)