Skip to content

add "throw" option #25

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

Open
wants to merge 1 commit into
base: parameter
Choose a base branch
from
Open
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
11 changes: 8 additions & 3 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ copyright: false
1. Let _error_ be ThrowCompletion(a newly created *RangeError* object).
1. Return ? IteratorClose(_iterated_, _error_).
1. If _undersized_ is *undefined*, set _undersized_ to *"discard"*.
1. If _undersized_ is neither *"discard"* nor *"truncate"*, then
1. If _undersized_ is not one of *"discard"*, *"truncate"*, or *"throw"*, then
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
1. Return ? IteratorClose(_iterated_, _error_).
1. Set _iterated_ to ? GetIteratorDirect(_O_).
Expand All @@ -59,8 +59,13 @@ copyright: false
1. Repeat,
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, then
1. If _undersized_ is *"truncate"*, _buffer_ is not empty, and the number of elements in _buffer_ < ℝ(_windowSize_), then
1. Perform Completion(Yield(CreateArrayFromList(_buffer_))).
1. If _buffer_ is not empty and the number of elements in _buffer_ < ℝ(_windowSize_), then
1. If _undersized_ is *"truncate"*, then
1. Perform Completion(Yield(CreateArrayFromList(_buffer_))).
1. Else if _undersized_ is *"throw"*, then
1. Throw a newly created *RangeError* object.
1. Else,
1. Assert: _undersized_ is *"discard"*.
1. Return ReturnCompletion(*undefined*).
1. If the number of elements in _buffer_ is ℝ(_windowSize_), then
1. Remove the first element from _buffer_.
Expand Down