You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This operation extends ECMA-402 <ahref="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.
_values_: *undefined* or a List of ECMAScript language values,
55
+
_default_: ~required~ or an ECMAScript language value,
56
+
)
57
+
</h1>
58
+
<dlclass="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>
62
62
<emu-alg>
63
-
1.Assert: Type(_options_) is Object.
64
63
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.
_values_: *undefined* or a List of ECMAScript language values,
149
+
_default_: ~required~ or an ECMAScript language value,
150
+
)
151
+
</h1>
152
+
<dlclass="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.
0 commit comments