Skip to content

Commit

Permalink
Formalize value pairs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Aug 7, 2019
1 parent 2aae535 commit b7ac492
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3990,8 +3990,15 @@ If a single type parameter is given, then the interface has a
values of the specified type.
If two type parameters are given, then the interface has a
<dfn id="dfn-pair-iterator" export>pair iterator</dfn> and provides
value pairs, where the first value is a key and the second is the
value associated with the key.
[=value pairs=] with the given types.

A <dfn>value pair</dfn>, given a key type and a value type, is a [=/struct=] with two
[=struct/items=]:
1. an [=struct/item=] whose [=struct/name=] is "key", which is referred to as the [=value pair=]'s
<dfn for="value pair">key</dfn>, and whose value is an IDL value of the key type;
1. an [=struct/item=] whose [=struct/name=] is "value", which is referred to as the
[=value pair=]'s <dfn for="value pair">value</dfn>, and whose value is an IDL value of the
value type.

A [=value iterator=]
must only be declared on an interface
Expand All @@ -4005,11 +4012,10 @@ defined to iterate over the object’s indexed properties.
A [=pair iterator=]
must not be declared on an interface
that [=support indexed properties|supports indexed properties=].
Prose accompanying an interface with a
[=pair iterator=]
must define what the list of
<dfn id="dfn-value-pairs-to-iterate-over" export>value pairs to iterate over</dfn>
is.

Prose accompanying an [=interface=] with a [=pair iterator=] must define a [=/list=] of
[=value pairs=] for each instance of the [=interface=], which is the list of
<dfn id="dfn-value-pairs-to-iterate-over" export>value pairs to iterate over</dfn>.

<div class="note">

Expand Down Expand Up @@ -4070,8 +4076,9 @@ that have [=members=] with these names.

<blockquote>

The [=value pairs to iterate over=] are the list of key-value pairs with the key being the username and the
value being the open <code class="idl">Session</code> object on the <code class="idl">SessionManager</code>
The [=value pairs to iterate over=] are the list of [=value pairs=] with the
[=value pair/key=] being the username and the [=value pair/value=] being the open
<code class="idl">Session</code> object on the <code class="idl">SessionManager</code>
object corresponding to that username, sorted by username.

</blockquote>
Expand Down Expand Up @@ -11576,8 +11583,8 @@ then the [=function object=] is {{%ArrayProto_forEach%}}.
1. Let |i| be 0.
1. While |i| is less than the length of |pairs|:
1. Let |pair| be the entry in |pairs| at index |i|.
1. Let |key| be |pair|’s key.
1. Let |value| be |pair|’s value.
1. Let |key| be |pair|’s [=value pair/key=].
1. Let |value| be |pair|’s [=value pair/value=].
1. [=Invoke=] |callback| with |thisArg|
(or <emu-val>undefined</emu-val>, if the argument was not supplied)
as the [=callback this value=] and |value|, |key| and <b>this</b> as its arguments.
Expand Down Expand Up @@ -11784,22 +11791,22 @@ The \[[Prototype]] [=internal slot=] of an [=iterator prototype object=]
must be {{%IteratorPrototype%}}.

<div algorithm>
The <dfn>iterator result</dfn> for a pair of IDL values |pair| and a kind |kind| is given by the
The <dfn>iterator result</dfn> for a [=value pair=] |pair| and a kind |kind| is given by the
following steps:

1. Let |result| be a value determined by the value of |kind|:
<dl class="switch">
: "<code>key</code>"
:: 1. Let |idlKey| be |pair|’s key.
:: 1. Let |idlKey| be |pair|’s [=value pair/key=].
1. Let |key| be the result of [=converted to an ECMAScript value|converting=] |idlKey| to an ECMAScript value.
1. |result| is |key|.
: "<code>value</code>"
:: 1. Let |idlValue| be |pair|’s value.
:: 1. Let |idlValue| be |pair|’s [=value pair/value=].
1. Let |value| be the result of [=converted to an ECMAScript value|converting=] |idlValue| to an ECMAScript value.
1. |result| is |value|.
: "<code>key+value</code>"
:: 1. Let |idlKey| be |pair|’s key.
1. Let |idlValue| be |pair|’s value.
:: 1. Let |idlKey| be |pair|’s [=value pair/key=].
1. Let |idlValue| be |pair|’s [=value pair/value=].
1. Let |key| be the result of [=converted to an ECMAScript value|converting=] |idlKey| to an ECMAScript value.
1. Let |value| be the result of [=converted to an ECMAScript value|converting=] |idlValue| to an ECMAScript value.
1. Let |array| be the result of performing [$ArrayCreate$](2).
Expand Down

0 comments on commit b7ac492

Please sign in to comment.