Skip to content

Commit 4e79b69

Browse files
gibson042ptomato
authored andcommitted
Editorial: Update to the latest ECMA-402 GetOption and move it into ECMA-262
1 parent 4c2476b commit 4e79b69

File tree

2 files changed

+54
-17
lines changed

2 files changed

+54
-17
lines changed

spec/abstractops.html

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,25 @@ <h1>GetOptionsObject ( _options_ )</h1>
4545
</emu-alg>
4646
</emu-clause>
4747

48-
<emu-clause id="sec-getoption" aoid="GetOption">
49-
<h1>GetOption ( _options_, _property_, _type_, _values_, _fallback_ )</h1>
50-
51-
<emu-note type="editor">
52-
<p>
53-
This operation extends ECMA-402 <a href="https://tc39.es/ecma402/#sec-getoption">GetOption</a> to support a *"number"* type.
54-
Once it is added to ECMA-262, the ECMA-402 version can be removed.
55-
</p>
56-
</emu-note>
57-
58-
<p>
59-
The abstract operation GetOption extracts the value of the property named _property_ from the provided _options_ object, converts it to the required _type_, checks whether it is one of a List of allowed _values_, and fills in a _fallback_ value if necessary. If _values_ is *undefined*, there is no fixed set of values and any is permitted.
60-
</p>
61-
48+
<emu-clause id="sec-getoption" type="abstract operation">
49+
<h1>
50+
GetOption (
51+
_options_: an Object,
52+
_property_: a property key,
53+
_type_: *"boolean"*, *"number"*, or *"string"*,
54+
_values_: *undefined* or a List of ECMAScript language values,
55+
_default_: ~required~ or an ECMAScript language value,
56+
)
57+
</h1>
58+
<dl class="header">
59+
<dt>description</dt>
60+
<dd>It extracts the value of the specified property of _options_, converts it to the required _type_, checks whether it is allowed by _values_ if _values_ is not *undefined*, and substitutes _default_ if the value is *undefined*.</dd>
61+
</dl>
6262
<emu-alg>
63-
1. Assert: Type(_options_) is Object.
6463
1. Let _value_ be ? Get(_options_, _property_).
65-
1. If _value_ is *undefined*, return _fallback_.
66-
1. Assert: _type_ is *"boolean"* or *"string"* or *"number"*.
64+
1. If _value_ is *undefined*, then
65+
1. If _default_ is ~required~, throw a *RangeError* exception.
66+
1. Return _default_.
6767
1. If _type_ is *"boolean"*, then
6868
1. Set _value_ to ToBoolean(_value_).
6969
1. Else if _type_ is *"number"*, then

spec/intl.html

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,43 @@ <h1><a href="https://tc39.es/ecma402/#sec-getoptionsobject">GetOptionsObject</a>
136136
</emu-alg>
137137
</emu-clause>
138138
</del>
139+
140+
<del class="block">
141+
<!-- https://tc39.es/ecma402/#sec-getoption -->
142+
<emu-clause id="sec-getoption-deleted" type="abstract operation">
143+
<h1>
144+
GetOption (
145+
_options_: an Object,
146+
_property_: a property key,
147+
_type_: *"boolean"*, *"number"*, or *"string"*,
148+
_values_: *undefined* or a List of ECMAScript language values,
149+
_default_: ~required~ or an ECMAScript language value,
150+
)
151+
</h1>
152+
<dl class="header">
153+
<dt>description</dt>
154+
<dd>It extracts the value of the specified property of _options_, converts it to the required _type_, checks whether it is allowed by _values_ if _values_ is not *undefined*, and substitutes _default_ if the value is *undefined*.</dd>
155+
<dt>redefinition</dt>
156+
<dd>true</dd>
157+
</dl>
158+
<emu-alg>
159+
1. Let _value_ be ? Get(_options_, _property_).
160+
1. If _value_ is *undefined*, then
161+
1. If _default_ is ~required~, throw a *RangeError* exception.
162+
1. Return _default_.
163+
1. If _type_ is *"boolean"*, then
164+
1. Set _value_ to ToBoolean(_value_).
165+
1. Else if _type_ is *"number"*, then
166+
1. Set _value_ to ? ToNumber(_value_).
167+
1. If _value_ is *NaN*, throw a *RangeError* exception.
168+
1. Else,
169+
1. Assert: _type_ is *"string"*.
170+
1. Set _value_ to ? ToString(_value_).
171+
1. If _values_ is not *undefined* and _values_ does not contain an element equal to _value_, throw a *RangeError* exception.
172+
1. Return _value_.
173+
</emu-alg>
174+
</emu-clause>
175+
</del>
139176
</emu-clause>
140177

141178
<emu-clause id="sec-datetimeformat-abstracts">

0 commit comments

Comments
 (0)