Skip to content

Commit

Permalink
capitalized several fields from numberformat.html ([[Pattern]], [[Pos…
Browse files Browse the repository at this point in the history
…itivePattern]], [[ZeroPattern]], [[NegativePattern]], [[Unit]], [[Currency]], [[Decimal]], [[UnitDisplay]], [[Code]], [[Symbol]], [[Percent]], [[Narrow]], [[Short]], [[Long]]
  • Loading branch information
ben-allen committed Mar 31, 2023
1 parent 2c6a892 commit 2a7d3cb
Showing 1 changed file with 17 additions and 119 deletions.
136 changes: 17 additions & 119 deletions spec/numberformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -239,118 +239,16 @@ <h1>Internal slots</h1>

<ul>
<li>The list that is the value of the *"nu"* field of any locale field of [[LocaleData]] must not include the values *"native"*, *"traditio"*, or *"finance"*.</li>
<li>[[LocaleData]].[[&lt;_locale_&gt;]] must have a [[patterns]] field for all locale values _locale_. The value of this field must be a Record, which must have fields with the names of the four number format styles: *"decimal"*, *"percent"*, *"currency"*, and *"unit"*.</li>
<li>[[LocaleData]].[[&lt;_locale_&gt;]] must have a [[Patterns]] field for all locale values _locale_. The value of this field must be a Record, which must have the following fields: [[Decimal]], [[Percent]], [[Currency]], and [[Unit]]. These fields correspond with the names of the four number format styles: *"decimal"*, *"percent"*, *"currency"*, and *"unit"*.</li>
<li>
The two fields *"currency"* and *"unit"* noted above must be Records with at least one field, *"fallback"*.
The *"currency"* may have additional fields with keys corresponding to currency codes according to <emu-xref href="#sec-currency-codes"></emu-xref>.
Each field of *"currency"* must be a Record with fields corresponding to the possible currencyDisplay values: *"code"*, *"symbol"*, *"narrowSymbol"*, and *"name"*.
Each of those fields must contain a Record with fields corresponding to the possible currencySign values: *"standard"* or *"accounting"*. The *"unit"* field (of [[LocaleData]].[[&lt;_locale_&gt;]]) may have additional fields beyond the required field *"fallback"* with keys corresponding to core measurement unit identifiers corresponding to <emu-xref href="#sec-measurement-unit-identifiers"></emu-xref>.
Each field of *"unit"* must be a Record with fields corresponding to the possible unitDisplay values: *"narrow"*, *"short"*, and *"long"*.
The two fields [[Currency]] and [[Unit]] noted above must be Records with at least one field, [[Fallback]]. [[Currency]] may have additional fields with keys corresponding to currency codes according to <emu-xref href="#sec-currency-codes"></emu-xref>.
Each field of [[Currency]] must be a Record with the following fields: [[Code]], [[Symbol]], [[NarrowSymbol]], and [[Name]], corresponding to the possible currencyDisplay values: *"code"*, *"symbol"*, *"narrowSymbol"*, and *"name"*.
Each of those fields must contain a Record with the fields [[Standard]] and [[Accounting]], corresponding to the possible currencySign values: *"standard"* or *"accounting"*. The [[Unit]] field (of [[LocaleData]].[[&lt;_locale_&gt;]]) may have additional fields beyond the required field [[Fallback]] with keys corresponding to core measurement unit identifiers corresponding to <emu-xref href="#sec-measurement-unit-identifiers"></emu-xref>.
Each field of [[Unit]] must be a Record with the fields [[Narrow]], [[Short]], and [[Long]] corresponding to the possible unitDisplay values: *"narrow"*, *"short"*, and *"long"*.
</li>
<li>All of the leaf fields so far described for the patterns tree (*"decimal"*, *"percent"*, great-grandchildren of *"currency"*, and grandchildren of *"unit"*) must be Records with the keys *"positivePattern"*, *"zeroPattern"*, and *"negativePattern"*.</li>
<li>All of the leaf fields so far described for the patterns tree ([[Decimal]], [[Percent]], great-grandchildren of [[Currency]], and grandchildren of [[Unit]]) must be Records with the keys *"PositivePattern"*, *"ZeroPattern"*, and *"NegativePattern"*.</li>
<li>
The value of the aforementioned fields (the sign-dependent pattern fields) must be string values that must contain the substring *"{number}"*.
*"positivePattern"* must contain the substring *"{plusSign}"* but not *"{minusSign}"*; *"negativePattern"* must contain the substring *"{minusSign}"* but not *"{plusSign}"*; and *"zeroPattern"* must not contain either *"{plusSign}"* or *"{minusSign}"*.
Additionally, the values within the *"percent"* field must also contain the substring *"{percentSign}"*; the values within the *"currency"* field must also contain one or more of the following substrings: *"{currencyCode}"*, *"{currencyPrefix}"*, or *"{currencySuffix}"*; and the values within the *"unit"* field must also contain one or more of the following substrings: *"{unitPrefix}"* or *"{unitSuffix}"*.
The pattern strings, when interpreted as a sequence of UTF-16 encoded code points as described in es2023, <emu-xref href="#sec-ecmascript-language-types-string-type"></emu-xref>, must not contain any code points in the General Category "Number, decimal digit" as specified by the Unicode Standard.
</li>
<li>[[LocaleData]].[[&lt;_locale_&gt;]] must also have a [[notationSubPatterns]] field for all locale values _locale_. The value of this field must be a Record, which must have two fields: [[scientific]] and [[compact]]. The [[scientific]] field must be a string value containing the substrings *"{number}"*, *"{scientificSeparator}"*, and *"{scientificExponent}"*. The [[compact]] field must be a Record with two fields: *"short"* and *"long"*. Each of these fields must be a Record with integer keys corresponding to all discrete magnitudes the implementation supports for compact notation. Each of these fields must be a string value which may contain the substring *"{number}"*. Strings descended from *"short"* must contain the substring *"{compactSymbol}"*, and strings descended from *"long"* must contain the substring *"{compactName}"*.</li>
</ul>

<emu-note>
It is recommended that implementations use the locale data provided by the Common Locale Data Repository (available at <a href="https://cldr.unicode.org/">https://cldr.unicode.org/</a>).
</emu-note>
</emu-clause>
</emu-clause>

<emu-clause id="sec-properties-of-intl-numberformat-prototype-object">
<h1>Properties of the Intl.NumberFormat Prototype Object</h1>

<p>
The Intl.NumberFormat prototype object is itself an ordinary object. <dfn>%NumberFormat.prototype%</dfn> is not an Intl.NumberFormat instance and does not have an [[InitializedNumberFormat]] internal slot or any of the other internal slots of Intl.NumberFormat instance objects.
</p>

<emu-clause id="sec-intl.numberformat.prototype.constructor">
<h1>Intl.NumberFormat.prototype.constructor</h1>

<p>
The initial value of `Intl.NumberFormat.prototype.constructor` is %NumberFormat%.
</p>
</emu-clause>

<emu-clause id="sec-intl.numberformat.prototype-@@tostringtag">
<h1>Intl.NumberFormat.prototype [ @@toStringTag ]</h1>

<p>
The initial value of the @@toStringTag property is the String value *"Intl.NumberFormat"*.
</p>
<p>
This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.
</p>
</emu-clause>

<emu-clause id="sec-intl.numberformat.prototype.format">
<h1>get Intl.NumberFormat.prototype.format</h1>

<p>
Intl.NumberFormat.prototype.format is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:
</p>

<emu-alg>
1. Let _nf_ be the *this* value.
1. If the implementation supports the normative optional constructor mode of <emu-xref href="#legacy-constructor"></emu-xref>, then
1. Set _nf_ to ? UnwrapNumberFormat(_nf_).
1. Perform ? RequireInternalSlot(_nf_, [[InitializedNumberFormat]]).
1. If _nf_.[[BoundFormat]] is *undefined*, then
1. Let _F_ be a new built-in function object as defined in Number Format Functions (<emu-xref href="#sec-number-format-functions"></emu-xref>).
1. Set _F_.[[NumberFormat]] to _nf_.
1. Set _nf_.[[BoundFormat]] to _F_.
1. Return _nf_.[[BoundFormat]].
</emu-alg>

<emu-note>
The returned function is bound to _nf_ so that it can be passed directly to `Array.prototype.map` or other functions.
This is considered a historical artefact, as part of a convention which is no longer followed for new features, but is preserved to maintain compatibility with existing programs.
</emu-note>
</emu-clause>

<emu-clause id="sec-intl.numberformat.prototype.formattoparts">
<h1>Intl.NumberFormat.prototype.formatToParts ( _value_ )</h1>

<p>
When the `formatToParts` method is called with an optional argument _value_, the following steps are taken:
</p>

<emu-alg>
1. Let _nf_ be the *this* value.
1. Perform ? RequireInternalSlot(_nf_, [[InitializedNumberFormat]]).
1. Let _x_ be ? ToNumeric(_value_).
1. Return ? FormatNumericToParts(_nf_, _x_).
</emu-alg>
</emu-clause>

<emu-clause id="sec-intl.numberformat.prototype.resolvedoptions">
<h1>Intl.NumberFormat.prototype.resolvedOptions ( )</h1>

<p>
This function provides access to the locale and options computed during initialization of the object.
</p>

<emu-alg>
1. Let _nf_ be the *this* value.
1. If the implementation supports the normative optional constructor mode of <emu-xref href="#legacy-constructor"></emu-xref>, then
1. Set _nf_ to ? UnwrapNumberFormat(_nf_).
1. Perform ? RequireInternalSlot(_nf_, [[InitializedNumberFormat]]).
1. Let _options_ be OrdinaryObjectCreate(%Object.prototype%).
1. For each row of <emu-xref href="#table-numberformat-resolvedoptions-properties"></emu-xref>, except the header row, in table order, do
1. Let _p_ be the Property value of the current row.
1. Let _v_ be the value of _nf_'s internal slot whose name is the Internal Slot value of the current row.
1. If _v_ is not *undefined*, then
1. Perform ! CreateDataPropertyOrThrow(_options_, _p_, _v_).
1. Return _options_.
</emu-alg>

<emu-table id="table-numberformat-resolvedoptions-properties">
<emu-caption>Resolved Options of NumberFormat Instances</emu-caption>
<table class="real-table">
<thead>
Expand Down Expand Up @@ -1132,15 +1030,15 @@ <h1>GetNumberFormatPattern ( _numberFormat_, _x_ )</h1>
1. Let _localeData_ be %NumberFormat%.[[LocaleData]].
1. Let _dataLocale_ be _numberFormat_.[[DataLocale]].
1. Let _dataLocaleData_ be _localeData_.[[&lt;_dataLocale_&gt;]].
1. Let _patterns_ be _dataLocaleData_.[[patterns]].
1. Let _patterns_ be _dataLocaleData_.[[Patterns]].
1. Assert: _patterns_ is a Record (see <emu-xref href="#sec-intl.numberformat-internal-slots"></emu-xref>).
1. Let _style_ be _numberFormat_.[[Style]].
1. If _style_ is *"percent"*, then
1. Let _patterns_ be _patterns_.[[percent]].
1. Else if _style_ is *"unit"*, then
1. Let _unit_ be _numberFormat_.[[Unit]].
1. Let _unitDisplay_ be _numberFormat_.[[UnitDisplay]].
1. Let _patterns_ be _patterns_.[[unit]].
1. Let _patterns_ be _patterns_.[[Unit]].
1. If _patterns_ doesn't have a field [[&lt;_unit_&gt;]], then
1. Let _unit_ be *"fallback"*.
1. Let _patterns_ be _patterns_.[[&lt;_unit_&gt;]].
Expand All @@ -1149,7 +1047,7 @@ <h1>GetNumberFormatPattern ( _numberFormat_, _x_ )</h1>
1. Let _currency_ be _numberFormat_.[[Currency]].
1. Let _currencyDisplay_ be _numberFormat_.[[CurrencyDisplay]].
1. Let _currencySign_ be _numberFormat_.[[CurrencySign]].
1. Let _patterns_ be _patterns_.[[currency]].
1. Let _patterns_ be _patterns_.[[Currency]].
1. If _patterns_ doesn't have a field [[&lt;_currency_&gt;]], then
1. Let _currency_ be *"fallback"*.
1. Let _patterns_ be _patterns_.[[&lt;_currency_&gt;]].
Expand All @@ -1160,25 +1058,25 @@ <h1>GetNumberFormatPattern ( _numberFormat_, _x_ )</h1>
1. Let _patterns_ be _patterns_.[[decimal]].
1. Let _signDisplay_ be _numberFormat_.[[SignDisplay]].
1. If _signDisplay_ is *"never"*, then
1. Let _pattern_ be _patterns_.[[zeroPattern]].
1. Let _pattern_ be _patterns_.[[ZeroPattern]].
1. Else if _signDisplay_ is *"auto"*, then
1. If _x_ is 0 or _x_ &gt; 0 or _x_ is *NaN*, then
1. Let _pattern_ be _patterns_.[[zeroPattern]].
1. Let _pattern_ be _patterns_.[[ZeroPattern]].
1. Else,
1. Let _pattern_ be _patterns_.[[negativePattern]].
1. Let _pattern_ be _patterns_.[[NegativePattern]].
1. Else if _signDisplay_ is *"always"*, then
1. If _x_ is 0 or _x_ &gt; 0 or _x_ is *NaN*, then
1. Let _pattern_ be _patterns_.[[positivePattern]].
1. Let _pattern_ be _patterns_.[[PositivePattern]].
1. Else,
1. Let _pattern_ be _patterns_.[[negativePattern]].
1. Let _pattern_ be _patterns_.[[NegativePattern]].
1. Else,
1. Assert: _signDisplay_ is *"exceptZero"*.
1. If _x_ is *NaN*, or if _x_ is finite and ℝ(_x_) is 0, then
1. Let _pattern_ be _patterns_.[[zeroPattern]].
1. Let _pattern_ be _patterns_.[[ZeroPattern]].
1. Else if ℝ(_x_) &gt; 0, then
1. Let _pattern_ be _patterns_.[[positivePattern]].
1. Let _pattern_ be _patterns_.[[PositivePattern]].
1. Else,
1. Let _pattern_ be _patterns_.[[negativePattern]].
1. Let _pattern_ be _patterns_.[[NegativePattern]].
1. Return _pattern_.
</emu-alg>
</emu-clause>
Expand Down

0 comments on commit 2a7d3cb

Please sign in to comment.