-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathspec.emu
More file actions
38 lines (37 loc) · 1.59 KB
/
spec.emu
File metadata and controls
38 lines (37 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!doctype html>
<meta charset="utf8">
<pre class="metadata">
title: Iterator Includes
status: proposal
stage: 2.7
contributors: Michael Ficarra
location: https://tc39.es/proposal-iterator-includes/
copyright: false
</pre>
<emu-clause id="sec-iterator.prototype.includes">
<h1>Iterator.prototype.includes ( _searchElement_ [ , _skippedElements_ ] )</h1>
<emu-alg>
1. Let _O_ be the *this* value.
1. If _O_ is not an Object, throw a *TypeError* exception.
1. Let _iterated_ be the Iterator Record { [[Iterator]]: _O_, [[NextMethod]]: *undefined*, [[Done]]: *false* }.
1. If _skippedElements_ is *undefined*, then
1. Let _toSkip_ be 0.
1. Else,
1. If _skippedElements_ is not one of *+∞<sub>𝔽</sub>*, *-∞<sub>𝔽</sub>*, or an integral Number, then
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
1. Return ? IteratorClose(_iterated_, _error_).
1. Let _toSkip_ be the extended mathematical value of _skippedElements_.
1. If _toSkip_ < 0, then
1. Let _error_ be ThrowCompletion(a newly created *RangeError* object).
1. Return ? IteratorClose(_iterated_, _error_).
1. Let _skipped_ be 0.
1. Set _iterated_ to ? GetIteratorDirect(_O_).
1. Repeat,
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return *false*.
1. If _skipped_ < _toSkip_, then
1. Set _skipped_ to _skipped_ + 1.
1. Else if SameValueZero(_value_, _searchElement_) is *true*, then
1. Return ? IteratorClose(_iterated_, NormalCompletion(*true*)).
</emu-alg>
</emu-clause>