Skip to content

Commit 2aae535

Browse files
committed
Editorial: Split out an 'iterator result' algorithm.
1 parent 13c7e8f commit 2aae535

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

index.bs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11783,6 +11783,33 @@ for the interface.
1178311783
The \[[Prototype]] [=internal slot=] of an [=iterator prototype object=]
1178411784
must be {{%IteratorPrototype%}}.
1178511785

11786+
<div algorithm>
11787+
The <dfn>iterator result</dfn> for a pair of IDL values |pair| and a kind |kind| is given by the
11788+
following steps:
11789+
11790+
1. Let |result| be a value determined by the value of |kind|:
11791+
<dl class="switch">
11792+
: "<code>key</code>"
11793+
:: 1. Let |idlKey| be |pair|’s key.
11794+
1. Let |key| be the result of [=converted to an ECMAScript value|converting=] |idlKey| to an ECMAScript value.
11795+
1. |result| is |key|.
11796+
: "<code>value</code>"
11797+
:: 1. Let |idlValue| be |pair|’s value.
11798+
1. Let |value| be the result of [=converted to an ECMAScript value|converting=] |idlValue| to an ECMAScript value.
11799+
1. |result| is |value|.
11800+
: "<code>key+value</code>"
11801+
:: 1. Let |idlKey| be |pair|’s key.
11802+
1. Let |idlValue| be |pair|’s value.
11803+
1. Let |key| be the result of [=converted to an ECMAScript value|converting=] |idlKey| to an ECMAScript value.
11804+
1. Let |value| be the result of [=converted to an ECMAScript value|converting=] |idlValue| to an ECMAScript value.
11805+
1. Let |array| be the result of performing [$ArrayCreate$](2).
11806+
1. Call [$CreateDataProperty$](|array|, "<code>0</code>", |key|).
11807+
1. Call [$CreateDataProperty$](|array|, "<code>1</code>", |value|).
11808+
1. |result| is |array|.
11809+
</dl>
11810+
1. Return [$CreateIterResultObject$](|result|, <emu-val>false</emu-val>).
11811+
</div>
11812+
1178611813
<div algorithm="to invoke the next property of iterators">
1178711814

1178811815
An [=iterator prototype object=] must have a <code class="idl">next</code> data property with attributes
@@ -11807,27 +11834,7 @@ must be {{%IteratorPrototype%}}.
1180711834
return <a abstract-op>CreateIterResultObject</a>(<emu-val>undefined</emu-val>, <emu-val>true</emu-val>).
1180811835
1. Let |pair| be the entry in |values| at index |index|.
1180911836
1. Set |object|’s index to |index| + 1.
11810-
1. Let |result| be a value determined by the value of |kind|:
11811-
<dl class="switch">
11812-
: "<code>key</code>"
11813-
:: 1. Let |idlKey| be |pair|’s key.
11814-
1. Let |key| be the result of [=converted to an ECMAScript value|converting=] |idlKey| to an ECMAScript value.
11815-
1. |result| is |key|.
11816-
: "<code>value</code>"
11817-
:: 1. Let |idlValue| be |pair|’s value.
11818-
1. Let |value| be the result of [=converted to an ECMAScript value|converting=] |idlValue| to an ECMAScript value.
11819-
1. |result| is |value|.
11820-
: "<code>key+value</code>"
11821-
:: 1. Let |idlKey| be |pair|’s key.
11822-
1. Let |idlValue| be |pair|’s value.
11823-
1. Let |key| be the result of [=converted to an ECMAScript value|converting=] |idlKey| to an ECMAScript value.
11824-
1. Let |value| be the result of [=converted to an ECMAScript value|converting=] |idlValue| to an ECMAScript value.
11825-
1. Let |array| be the result of performing <a abstract-op>ArrayCreate</a>(2).
11826-
1. Call <a abstract-op>CreateDataProperty</a>(|array|, "<code>0</code>", |key|).
11827-
1. Call <a abstract-op>CreateDataProperty</a>(|array|, "<code>1</code>", |value|).
11828-
1. |result| is |array|.
11829-
</dl>
11830-
1. Return <a abstract-op>CreateIterResultObject</a>(|result|, <emu-val>false</emu-val>).
11837+
1. Return the [=iterator result=] for |pair| and |kind|.
1183111838
</div>
1183211839

1183311840
The [=class string=] of an [=iterator prototype object=] for a given [=interface=]

0 commit comments

Comments
 (0)