@formatjs/ecma402-abstract 1.11.9 → 1.11.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/262.d.ts +92 -0
  2. package/262.d.ts.map +1 -0
  3. package/262.js +362 -0
  4. package/CanonicalizeLocaleList.d.ts +6 -0
  5. package/CanonicalizeLocaleList.d.ts.map +1 -0
  6. package/CanonicalizeLocaleList.js +12 -0
  7. package/CanonicalizeTimeZoneName.d.ts +9 -0
  8. package/CanonicalizeTimeZoneName.d.ts.map +1 -0
  9. package/CanonicalizeTimeZoneName.js +21 -0
  10. package/CoerceOptionsToObject.d.ts +7 -0
  11. package/CoerceOptionsToObject.d.ts.map +1 -0
  12. package/CoerceOptionsToObject.js +16 -0
  13. package/DefaultNumberOption.d.ts +9 -0
  14. package/DefaultNumberOption.d.ts.map +1 -0
  15. package/DefaultNumberOption.js +14 -0
  16. package/GetNumberOption.d.ts +10 -0
  17. package/GetNumberOption.d.ts.map +1 -0
  18. package/GetNumberOption.js +18 -0
  19. package/GetOption.d.ts +10 -0
  20. package/GetOption.d.ts.map +1 -0
  21. package/GetOption.js +35 -0
  22. package/GetOptionsObject.d.ts +7 -0
  23. package/GetOptionsObject.d.ts.map +1 -0
  24. package/GetOptionsObject.js +18 -0
  25. package/IsSanctionedSimpleUnitIdentifier.d.ts +14 -0
  26. package/IsSanctionedSimpleUnitIdentifier.d.ts.map +1 -0
  27. package/IsSanctionedSimpleUnitIdentifier.js +68 -0
  28. package/IsValidTimeZoneName.d.ts +10 -0
  29. package/IsValidTimeZoneName.d.ts.map +1 -0
  30. package/IsValidTimeZoneName.js +23 -0
  31. package/IsWellFormedCurrencyCode.d.ts +5 -0
  32. package/IsWellFormedCurrencyCode.d.ts.map +1 -0
  33. package/IsWellFormedCurrencyCode.js +25 -0
  34. package/IsWellFormedUnitIdentifier.d.ts +6 -0
  35. package/IsWellFormedUnitIdentifier.d.ts.map +1 -0
  36. package/IsWellFormedUnitIdentifier.js +32 -0
  37. package/NumberFormat/ComputeExponent.d.ts +12 -0
  38. package/NumberFormat/ComputeExponent.d.ts.map +1 -0
  39. package/NumberFormat/ComputeExponent.js +43 -0
  40. package/NumberFormat/ComputeExponentForMagnitude.d.ts +10 -0
  41. package/NumberFormat/ComputeExponentForMagnitude.d.ts.map +1 -0
  42. package/NumberFormat/ComputeExponentForMagnitude.js +64 -0
  43. package/NumberFormat/CurrencyDigits.d.ts +7 -0
  44. package/NumberFormat/CurrencyDigits.d.ts.map +1 -0
  45. package/NumberFormat/CurrencyDigits.js +14 -0
  46. package/NumberFormat/FormatNumericToParts.d.ts +5 -0
  47. package/NumberFormat/FormatNumericToParts.d.ts.map +1 -0
  48. package/NumberFormat/FormatNumericToParts.js +18 -0
  49. package/NumberFormat/FormatNumericToString.d.ts +9 -0
  50. package/NumberFormat/FormatNumericToString.d.ts.map +1 -0
  51. package/NumberFormat/FormatNumericToString.js +45 -0
  52. package/NumberFormat/InitializeNumberFormat.d.ts +13 -0
  53. package/NumberFormat/InitializeNumberFormat.d.ts.map +1 -0
  54. package/NumberFormat/InitializeNumberFormat.js +68 -0
  55. package/NumberFormat/PartitionNumberPattern.d.ts +8 -0
  56. package/NumberFormat/PartitionNumberPattern.d.ts.map +1 -0
  57. package/NumberFormat/PartitionNumberPattern.js +80 -0
  58. package/NumberFormat/SetNumberFormatDigitOptions.d.ts +6 -0
  59. package/NumberFormat/SetNumberFormatDigitOptions.d.ts.map +1 -0
  60. package/NumberFormat/SetNumberFormatDigitOptions.js +40 -0
  61. package/NumberFormat/SetNumberFormatUnitOptions.d.ts +8 -0
  62. package/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +1 -0
  63. package/NumberFormat/SetNumberFormatUnitOptions.js +43 -0
  64. package/NumberFormat/ToRawFixed.d.ts +10 -0
  65. package/NumberFormat/ToRawFixed.d.ts.map +1 -0
  66. package/NumberFormat/ToRawFixed.js +55 -0
  67. package/NumberFormat/ToRawPrecision.d.ts +3 -0
  68. package/NumberFormat/ToRawPrecision.d.ts.map +1 -0
  69. package/NumberFormat/ToRawPrecision.js +78 -0
  70. package/NumberFormat/digit-mapping.generated.d.ts +2 -0
  71. package/NumberFormat/digit-mapping.generated.d.ts.map +1 -0
  72. package/NumberFormat/digit-mapping.generated.js +4 -0
  73. package/NumberFormat/format_to_parts.d.ts +22 -0
  74. package/NumberFormat/format_to_parts.d.ts.map +1 -0
  75. package/NumberFormat/format_to_parts.js +424 -0
  76. package/PartitionPattern.d.ts +9 -0
  77. package/PartitionPattern.d.ts.map +1 -0
  78. package/PartitionPattern.js +39 -0
  79. package/SupportedLocales.d.ts +10 -0
  80. package/SupportedLocales.d.ts.map +1 -0
  81. package/SupportedLocales.js +24 -0
  82. package/data.d.ts +6 -0
  83. package/data.d.ts.map +1 -0
  84. package/data.js +17 -0
  85. package/index.d.ts +37 -0
  86. package/index.d.ts.map +1 -0
  87. package/index.js +48 -0
  88. package/lib/262.d.ts +92 -0
  89. package/lib/262.d.ts.map +1 -0
  90. package/lib/262.js +336 -0
  91. package/lib/CanonicalizeLocaleList.d.ts +6 -0
  92. package/lib/CanonicalizeLocaleList.d.ts.map +1 -0
  93. package/lib/CanonicalizeLocaleList.js +8 -0
  94. package/lib/CanonicalizeTimeZoneName.d.ts +9 -0
  95. package/lib/CanonicalizeTimeZoneName.d.ts.map +1 -0
  96. package/lib/CanonicalizeTimeZoneName.js +17 -0
  97. package/lib/CoerceOptionsToObject.d.ts +7 -0
  98. package/lib/CoerceOptionsToObject.d.ts.map +1 -0
  99. package/lib/CoerceOptionsToObject.js +12 -0
  100. package/lib/DefaultNumberOption.d.ts +9 -0
  101. package/lib/DefaultNumberOption.d.ts.map +1 -0
  102. package/lib/DefaultNumberOption.js +10 -0
  103. package/lib/GetNumberOption.d.ts +10 -0
  104. package/lib/GetNumberOption.d.ts.map +1 -0
  105. package/lib/GetNumberOption.js +14 -0
  106. package/lib/GetOption.d.ts +10 -0
  107. package/lib/GetOption.d.ts.map +1 -0
  108. package/lib/GetOption.js +31 -0
  109. package/lib/GetOptionsObject.d.ts +7 -0
  110. package/lib/GetOptionsObject.d.ts.map +1 -0
  111. package/lib/GetOptionsObject.js +14 -0
  112. package/lib/IsSanctionedSimpleUnitIdentifier.d.ts +14 -0
  113. package/lib/IsSanctionedSimpleUnitIdentifier.d.ts.map +1 -0
  114. package/lib/IsSanctionedSimpleUnitIdentifier.js +63 -0
  115. package/lib/IsValidTimeZoneName.d.ts +10 -0
  116. package/lib/IsValidTimeZoneName.d.ts.map +1 -0
  117. package/lib/IsValidTimeZoneName.js +19 -0
  118. package/lib/IsWellFormedCurrencyCode.d.ts +5 -0
  119. package/lib/IsWellFormedCurrencyCode.d.ts.map +1 -0
  120. package/lib/IsWellFormedCurrencyCode.js +21 -0
  121. package/lib/IsWellFormedUnitIdentifier.d.ts +6 -0
  122. package/lib/IsWellFormedUnitIdentifier.d.ts.map +1 -0
  123. package/lib/IsWellFormedUnitIdentifier.js +28 -0
  124. package/lib/NumberFormat/ComputeExponent.d.ts +12 -0
  125. package/lib/NumberFormat/ComputeExponent.d.ts.map +1 -0
  126. package/lib/NumberFormat/ComputeExponent.js +39 -0
  127. package/lib/NumberFormat/ComputeExponentForMagnitude.d.ts +10 -0
  128. package/lib/NumberFormat/ComputeExponentForMagnitude.d.ts.map +1 -0
  129. package/lib/NumberFormat/ComputeExponentForMagnitude.js +60 -0
  130. package/lib/NumberFormat/CurrencyDigits.d.ts +7 -0
  131. package/lib/NumberFormat/CurrencyDigits.d.ts.map +1 -0
  132. package/lib/NumberFormat/CurrencyDigits.js +10 -0
  133. package/lib/NumberFormat/FormatNumericToParts.d.ts +5 -0
  134. package/lib/NumberFormat/FormatNumericToParts.d.ts.map +1 -0
  135. package/lib/NumberFormat/FormatNumericToParts.js +14 -0
  136. package/lib/NumberFormat/FormatNumericToString.d.ts +9 -0
  137. package/lib/NumberFormat/FormatNumericToString.d.ts.map +1 -0
  138. package/lib/NumberFormat/FormatNumericToString.js +41 -0
  139. package/lib/NumberFormat/InitializeNumberFormat.d.ts +13 -0
  140. package/lib/NumberFormat/InitializeNumberFormat.d.ts.map +1 -0
  141. package/lib/NumberFormat/InitializeNumberFormat.js +64 -0
  142. package/lib/NumberFormat/PartitionNumberPattern.d.ts +8 -0
  143. package/lib/NumberFormat/PartitionNumberPattern.d.ts.map +1 -0
  144. package/lib/NumberFormat/PartitionNumberPattern.js +75 -0
  145. package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts +6 -0
  146. package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts.map +1 -0
  147. package/lib/NumberFormat/SetNumberFormatDigitOptions.js +36 -0
  148. package/lib/NumberFormat/SetNumberFormatUnitOptions.d.ts +8 -0
  149. package/lib/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +1 -0
  150. package/lib/NumberFormat/SetNumberFormatUnitOptions.js +39 -0
  151. package/lib/NumberFormat/ToRawFixed.d.ts +10 -0
  152. package/lib/NumberFormat/ToRawFixed.d.ts.map +1 -0
  153. package/lib/NumberFormat/ToRawFixed.js +51 -0
  154. package/lib/NumberFormat/ToRawPrecision.d.ts +3 -0
  155. package/lib/NumberFormat/ToRawPrecision.d.ts.map +1 -0
  156. package/lib/NumberFormat/ToRawPrecision.js +74 -0
  157. package/lib/NumberFormat/digit-mapping.generated.d.ts +2 -0
  158. package/lib/NumberFormat/digit-mapping.generated.d.ts.map +1 -0
  159. package/lib/NumberFormat/digit-mapping.generated.js +1 -0
  160. package/lib/NumberFormat/format_to_parts.d.ts +22 -0
  161. package/lib/NumberFormat/format_to_parts.d.ts.map +1 -0
  162. package/lib/NumberFormat/format_to_parts.js +421 -0
  163. package/lib/PartitionPattern.d.ts +9 -0
  164. package/lib/PartitionPattern.d.ts.map +1 -0
  165. package/lib/PartitionPattern.js +35 -0
  166. package/lib/SupportedLocales.d.ts +10 -0
  167. package/lib/SupportedLocales.d.ts.map +1 -0
  168. package/lib/SupportedLocales.js +20 -0
  169. package/lib/data.d.ts +6 -0
  170. package/lib/data.d.ts.map +1 -0
  171. package/lib/data.js +13 -0
  172. package/lib/index.d.ts +37 -0
  173. package/lib/index.d.ts.map +1 -0
  174. package/lib/index.js +34 -0
  175. package/lib/regex.generated.d.ts +2 -0
  176. package/lib/regex.generated.d.ts.map +1 -0
  177. package/lib/regex.generated.js +2 -0
  178. package/lib/types/core.d.ts +11 -0
  179. package/lib/types/core.d.ts.map +1 -0
  180. package/lib/types/core.js +1 -0
  181. package/lib/types/date-time.d.ts +135 -0
  182. package/lib/types/date-time.d.ts.map +1 -0
  183. package/lib/types/date-time.js +6 -0
  184. package/lib/types/displaynames.d.ts +47 -0
  185. package/lib/types/displaynames.d.ts.map +1 -0
  186. package/lib/types/displaynames.js +1 -0
  187. package/lib/types/list.d.ts +19 -0
  188. package/lib/types/list.d.ts.map +1 -0
  189. package/lib/types/list.js +1 -0
  190. package/lib/types/number.d.ts +147 -0
  191. package/lib/types/number.d.ts.map +1 -0
  192. package/lib/types/number.js +1 -0
  193. package/lib/types/plural-rules.d.ts +17 -0
  194. package/lib/types/plural-rules.d.ts.map +1 -0
  195. package/lib/types/plural-rules.js +1 -0
  196. package/lib/types/relative-time.d.ts +41 -0
  197. package/lib/types/relative-time.d.ts.map +1 -0
  198. package/lib/types/relative-time.js +1 -0
  199. package/lib/utils.d.ts +24 -0
  200. package/lib/utils.d.ts.map +1 -0
  201. package/lib/utils.js +78 -0
  202. package/package.json +2 -2
  203. package/regex.generated.d.ts +2 -0
  204. package/regex.generated.d.ts.map +1 -0
  205. package/regex.generated.js +5 -0
  206. package/types/core.d.ts +11 -0
  207. package/types/core.d.ts.map +1 -0
  208. package/types/core.js +2 -0
  209. package/types/date-time.d.ts +135 -0
  210. package/types/date-time.d.ts.map +1 -0
  211. package/types/date-time.js +9 -0
  212. package/types/displaynames.d.ts +47 -0
  213. package/types/displaynames.d.ts.map +1 -0
  214. package/types/displaynames.js +2 -0
  215. package/types/list.d.ts +19 -0
  216. package/types/list.d.ts.map +1 -0
  217. package/types/list.js +2 -0
  218. package/types/number.d.ts +147 -0
  219. package/types/number.d.ts.map +1 -0
  220. package/types/number.js +2 -0
  221. package/types/plural-rules.d.ts +17 -0
  222. package/types/plural-rules.d.ts.map +1 -0
  223. package/types/plural-rules.js +2 -0
  224. package/types/relative-time.d.ts +41 -0
  225. package/types/relative-time.d.ts.map +1 -0
  226. package/types/relative-time.js +2 -0
  227. package/utils.d.ts +24 -0
  228. package/utils.d.ts.map +1 -0
  229. package/utils.js +90 -0
  230. package/262.ts +0 -372
  231. package/BUILD +0 -97
  232. package/CHANGELOG.md +0 -709
  233. package/CanonicalizeLocaleList.ts +0 -8
  234. package/CanonicalizeTimeZoneName.ts +0 -29
  235. package/CoerceOptionsToObject.ts +0 -13
  236. package/DefaultNumberOption.ts +0 -28
  237. package/GetNumberOption.ts +0 -29
  238. package/GetOption.ts +0 -38
  239. package/GetOptionsObject.ts +0 -14
  240. package/IsSanctionedSimpleUnitIdentifier.ts +0 -66
  241. package/IsValidTimeZoneName.ts +0 -27
  242. package/IsWellFormedCurrencyCode.ts +0 -23
  243. package/IsWellFormedUnitIdentifier.ts +0 -32
  244. package/NumberFormat/ComputeExponent.ts +0 -49
  245. package/NumberFormat/ComputeExponentForMagnitude.ts +0 -71
  246. package/NumberFormat/CurrencyDigits.ts +0 -13
  247. package/NumberFormat/FormatNumericToParts.ts +0 -22
  248. package/NumberFormat/FormatNumericToString.ts +0 -71
  249. package/NumberFormat/InitializeNumberFormat.ts +0 -147
  250. package/NumberFormat/PartitionNumberPattern.ts +0 -86
  251. package/NumberFormat/SetNumberFormatDigitOptions.ts +0 -45
  252. package/NumberFormat/SetNumberFormatUnitOptions.ts +0 -77
  253. package/NumberFormat/ToRawFixed.ts +0 -56
  254. package/NumberFormat/ToRawPrecision.ts +0 -86
  255. package/NumberFormat/digit-mapping.generated.ts +0 -1
  256. package/NumberFormat/format_to_parts.ts +0 -571
  257. package/PartitionPattern.ts +0 -38
  258. package/SupportedLocales.ts +0 -31
  259. package/data.ts +0 -9
  260. package/index.ts +0 -45
  261. package/regex.generated.ts +0 -2
  262. package/scripts/digit-mapping.ts +0 -109
  263. package/scripts/regex-gen.ts +0 -19
  264. package/tests/PartitionPattern.test.ts +0 -38
  265. package/tests/ToRawFixed.test.tsx +0 -41
  266. package/tests/ToRawPrecision.test.tsx +0 -65
  267. package/tsconfig.json +0 -5
  268. package/types/core.ts +0 -11
  269. package/types/date-time.ts +0 -199
  270. package/types/displaynames.ts +0 -48
  271. package/types/list.ts +0 -22
  272. package/types/number.ts +0 -240
  273. package/types/plural-rules.ts +0 -18
  274. package/types/relative-time.ts +0 -74
  275. package/utils.ts +0 -128
package/types/number.ts DELETED
@@ -1,240 +0,0 @@
1
- import {LDMLPluralRule} from './plural-rules'
2
- import {LocaleData} from './core'
3
-
4
- export type NumberFormatNotation =
5
- | 'standard'
6
- | 'scientific'
7
- | 'engineering'
8
- | 'compact'
9
-
10
- export type NumberFormatRoundingType =
11
- | 'significantDigits'
12
- | 'fractionDigits'
13
- | 'compactRounding'
14
-
15
- export interface NumberFormatDigitOptions {
16
- minimumIntegerDigits?: number
17
- minimumSignificantDigits?: number
18
- maximumSignificantDigits?: number
19
- minimumFractionDigits?: number
20
- maximumFractionDigits?: number
21
- }
22
-
23
- export interface NumberFormatDigitInternalSlots {
24
- minimumIntegerDigits: number
25
- minimumSignificantDigits?: number
26
- maximumSignificantDigits?: number
27
- roundingType: NumberFormatRoundingType
28
- // These two properties are only used when `roundingType` is "fractionDigits".
29
- minimumFractionDigits?: number
30
- maximumFractionDigits?: number
31
- notation?: NumberFormatNotation
32
- }
33
-
34
- // All fields are optional due to de-duping
35
- export type RawNumberLocaleData = LocaleData<NumberFormatLocaleInternalData>
36
-
37
- export interface NumberFormatLocaleInternalData {
38
- units: UnitDataTable
39
- currencies: Record<string, CurrencyData>
40
- numbers: RawNumberData
41
- // Bc of relevantExtensionKeys in the spec
42
- nu: string[]
43
- }
44
-
45
- export interface UnitDataTable {
46
- simple: Record<string, UnitData>
47
- compound: Record<string, CompoundUnitData>
48
- }
49
-
50
- export interface UnitData {
51
- // A pattern where {0} is number placeholder. Example: "摂氏 {0} 度".
52
- long: LDMLPluralRuleMap<string>
53
- short: LDMLPluralRuleMap<string>
54
- narrow: LDMLPluralRuleMap<string>
55
- // perUnitPattern. See http://unicode.org/reports/tr35/tr35-general.html#perUnitPatterns
56
- perUnit: Record<'narrow' | 'short' | 'long', string | undefined>
57
- }
58
-
59
- // The values are patterns on how to compose simple units.
60
- // For example, "{0} per {1}".
61
- export interface CompoundUnitData {
62
- long: string
63
- short: string
64
- narrow: string
65
- }
66
-
67
- export interface CurrencyData {
68
- displayName: LDMLPluralRuleMap<string>
69
- symbol: string
70
- narrow: string
71
- }
72
-
73
- export type DecimalFormatNum =
74
- | '1000'
75
- | '10000'
76
- | '100000'
77
- | '1000000'
78
- | '10000000'
79
- | '100000000'
80
- | '1000000000'
81
- | '10000000000'
82
- | '100000000000'
83
- | '1000000000000'
84
- | '10000000000000'
85
- | '100000000000000'
86
- export type NumberingSystem = string
87
-
88
- /**
89
- * We only care about insertBetween bc we assume
90
- * `currencyMatch` & `surroundingMatch` are all the same
91
- *
92
- * @export
93
- * @interface CurrencySpacingData
94
- */
95
- export interface CurrencySpacingData {
96
- beforeInsertBetween: string
97
- afterInsertBetween: string
98
- }
99
-
100
- export interface RawCurrencyData {
101
- currencySpacing: CurrencySpacingData
102
- standard: string
103
- accounting: string
104
- short?: Record<DecimalFormatNum, LDMLPluralRuleMap<string>>
105
- // IMPORTANT: We're making the assumption here that currency unitPattern
106
- // are the same for all LDMLPluralRule
107
- unitPattern: string
108
- }
109
-
110
- export interface SymbolsData {
111
- decimal: string
112
- group: string
113
- list: string
114
- percentSign: string
115
- plusSign: string
116
- minusSign: string
117
- exponential: string
118
- superscriptingExponent: string
119
- perMille: string
120
- infinity: string
121
- nan: string
122
- timeSeparator: string
123
- }
124
-
125
- export interface RawNumberData {
126
- nu: string[]
127
- // numberingSystem -> pattern
128
- symbols: Record<NumberingSystem, SymbolsData>
129
- // numberingSystem -> pattern
130
- decimal: Record<
131
- NumberingSystem,
132
- {
133
- // The standard number pattern of the decimal.
134
- standard: string
135
- // These two are compact notation mappings.
136
- long: Record<DecimalFormatNum, LDMLPluralRuleMap<string>>
137
- short: Record<DecimalFormatNum, LDMLPluralRuleMap<string>>
138
- }
139
- >
140
- percent: Record<NumberingSystem, string>
141
- currency: Record<NumberingSystem, RawCurrencyData>
142
- }
143
-
144
- export type LDMLPluralRuleMap<T> = Omit<
145
- Partial<Record<LDMLPluralRule, T>>,
146
- 'other'
147
- > & {
148
- other: T
149
- }
150
-
151
- export interface RawNumberFormatResult {
152
- formattedString: string
153
- roundedNumber: number
154
- integerDigitsCount: number
155
- }
156
-
157
- export type NumberFormatOptionsLocaleMatcher = 'lookup' | 'best fit'
158
- export type NumberFormatOptionsStyle =
159
- | 'decimal'
160
- | 'percent'
161
- | 'currency'
162
- | 'unit'
163
- export type NumberFormatOptionsCompactDisplay = 'short' | 'long'
164
- export type NumberFormatOptionsCurrencyDisplay =
165
- | 'symbol'
166
- | 'code'
167
- | 'name'
168
- | 'narrowSymbol'
169
- export type NumberFormatOptionsCurrencySign = 'standard' | 'accounting'
170
- export type NumberFormatOptionsNotation = NumberFormatNotation
171
- export type NumberFormatOptionsSignDisplay =
172
- | 'auto'
173
- | 'always'
174
- | 'never'
175
- | 'exceptZero'
176
- export type NumberFormatOptionsUnitDisplay = 'long' | 'short' | 'narrow'
177
-
178
- export interface NumberFormatInternal extends NumberFormatDigitInternalSlots {
179
- locale: string
180
- dataLocale: string
181
- style: NumberFormatOptionsStyle
182
- currency?: string
183
- currencyDisplay: NumberFormatOptionsCurrencyDisplay
184
- unit?: string
185
- unitDisplay: NumberFormatOptionsUnitDisplay
186
- currencySign: NumberFormatOptionsCurrencySign
187
- notation: NumberFormatOptionsNotation
188
- compactDisplay: NumberFormatOptionsCompactDisplay
189
- signDisplay: NumberFormatOptionsSignDisplay
190
- useGrouping: boolean
191
- pl: Intl.PluralRules
192
- boundFormat?: Intl.NumberFormat['format']
193
- numberingSystem: string
194
- // Locale-dependent formatter data
195
- dataLocaleData: NumberFormatLocaleInternalData
196
- }
197
-
198
- export type NumberFormatOptions = Omit<
199
- Intl.NumberFormatOptions,
200
- 'signDisplay'
201
- > &
202
- NumberFormatDigitOptions & {
203
- localeMatcher?: NumberFormatOptionsLocaleMatcher
204
- style?: NumberFormatOptionsStyle
205
- compactDisplay?: NumberFormatOptionsCompactDisplay
206
- currencyDisplay?: NumberFormatOptionsCurrencyDisplay
207
- currencySign?: NumberFormatOptionsCurrencySign
208
- notation?: NumberFormatOptionsNotation
209
- signDisplay?: NumberFormatOptionsSignDisplay
210
- unit?: string
211
- unitDisplay?: NumberFormatOptionsUnitDisplay
212
- numberingSystem?: string
213
- trailingZeroDisplay?: 'auto' | 'stripIfInteger'
214
- roundingPriority?: 'auto' | 'morePrecision' | 'lessPrecision'
215
- }
216
-
217
- export type ResolvedNumberFormatOptions = Intl.ResolvedNumberFormatOptions &
218
- Pick<
219
- NumberFormatInternal,
220
- | 'currencySign'
221
- | 'unit'
222
- | 'unitDisplay'
223
- | 'notation'
224
- | 'compactDisplay'
225
- | 'signDisplay'
226
- >
227
-
228
- export type NumberFormatPartTypes =
229
- | Intl.NumberFormatPartTypes
230
- | 'exponentSeparator'
231
- | 'exponentMinusSign'
232
- | 'exponentInteger'
233
- | 'compact'
234
- | 'unit'
235
- | 'literal'
236
-
237
- export interface NumberFormatPart {
238
- type: NumberFormatPartTypes
239
- value: string
240
- }
@@ -1,18 +0,0 @@
1
- import {LocaleData} from './core'
2
- import {NumberFormatDigitInternalSlots} from './number'
3
- export type LDMLPluralRule = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other'
4
- export interface PluralRulesData {
5
- categories: {
6
- cardinal: string[]
7
- ordinal: string[]
8
- }
9
- fn: (val: number | string, ord?: boolean) => LDMLPluralRule
10
- }
11
-
12
- export type PluralRulesLocaleData = LocaleData<PluralRulesData>
13
-
14
- export interface PluralRulesInternal extends NumberFormatDigitInternalSlots {
15
- initializedPluralRules: boolean
16
- locale: string
17
- type: 'cardinal' | 'ordinal'
18
- }
@@ -1,74 +0,0 @@
1
- import {LocaleData} from './core'
2
- import {LDMLPluralRule} from './plural-rules'
3
-
4
- export interface FieldData {
5
- '0'?: string
6
- '1'?: string
7
- '-1'?: string
8
- '2'?: string
9
- '-2'?: string
10
- '3'?: string
11
- '-3'?: string
12
- future: RelativeTimeData
13
- past: RelativeTimeData
14
- }
15
-
16
- type RelativeTimeData = {[u in LDMLPluralRule]?: string}
17
-
18
- export type UnpackedLocaleFieldsData = {
19
- [f in RelativeTimeField]?: FieldData
20
- } & {nu: Array<string | null>}
21
-
22
- export type LocaleFieldsData = {
23
- [f in RelativeTimeField]?: FieldData
24
- } & {nu?: Array<string | null>}
25
-
26
- export type RelativeTimeField =
27
- | 'second'
28
- | 'second-short'
29
- | 'second-narrow'
30
- | 'minute'
31
- | 'minute-short'
32
- | 'minute-narrow'
33
- | 'hour'
34
- | 'hour-short'
35
- | 'hour-narrow'
36
- | 'day'
37
- | 'day-short'
38
- | 'day-narrow'
39
- | 'week'
40
- | 'week-short'
41
- | 'week-narrow'
42
- | 'month'
43
- | 'month-short'
44
- | 'month-narrow'
45
- | 'quarter'
46
- | 'quarter-short'
47
- | 'quarter-narrow'
48
- | 'year'
49
- | 'year-short'
50
- | 'year-narrow'
51
-
52
- export type RelativeTimeFormatSingularUnit = Exclude<
53
- Intl.RelativeTimeFormatUnit,
54
- | 'seconds'
55
- | 'minutes'
56
- | 'hours'
57
- | 'days'
58
- | 'weeks'
59
- | 'months'
60
- | 'quarters'
61
- | 'years'
62
- >
63
-
64
- export type RelativeTimeLocaleData = LocaleData<LocaleFieldsData>
65
- export interface RelativeTimeFormatInternal {
66
- numberFormat: Intl.NumberFormat
67
- pluralRules: Intl.PluralRules
68
- locale: string
69
- fields: LocaleFieldsData
70
- style: Intl.ResolvedRelativeTimeFormatOptions['style']
71
- numeric: Intl.ResolvedRelativeTimeFormatOptions['numeric']
72
- numberingSystem: string
73
- initializedRelativeTimeFormat: boolean
74
- }
package/utils.ts DELETED
@@ -1,128 +0,0 @@
1
- /**
2
- * Cannot do Math.log(x) / Math.log(10) bc if IEEE floating point issue
3
- * @param x number
4
- */
5
- export function getMagnitude(x: number): number {
6
- // Cannot count string length via Number.toString because it may use scientific notation
7
- // for very small or very large numbers.
8
- return Math.floor(Math.log(x) * Math.LOG10E)
9
- }
10
-
11
- export function repeat(s: string, times: number): string {
12
- if (typeof s.repeat === 'function') {
13
- return s.repeat(times)
14
- }
15
- const arr = new Array(times)
16
- for (let i = 0; i < arr.length; i++) {
17
- arr[i] = s
18
- }
19
- return arr.join('')
20
- }
21
-
22
- export function setInternalSlot<
23
- Instance extends object,
24
- Internal extends object,
25
- Field extends keyof Internal
26
- >(
27
- map: WeakMap<Instance, Internal>,
28
- pl: Instance,
29
- field: Field,
30
- value: NonNullable<Internal>[Field]
31
- ) {
32
- if (!map.get(pl)) {
33
- map.set(pl, Object.create(null))
34
- }
35
- const slots = map.get(pl)!
36
- slots[field] = value
37
- }
38
-
39
- export function setMultiInternalSlots<
40
- Instance extends object,
41
- Internal extends object,
42
- K extends keyof Internal
43
- >(
44
- map: WeakMap<Instance, Internal>,
45
- pl: Instance,
46
- props: Pick<NonNullable<Internal>, K>
47
- ) {
48
- for (const k of Object.keys(props) as K[]) {
49
- setInternalSlot(map, pl, k, props[k])
50
- }
51
- }
52
-
53
- export function getInternalSlot<
54
- Instance extends object,
55
- Internal extends object,
56
- Field extends keyof Internal
57
- >(
58
- map: WeakMap<Instance, Internal>,
59
- pl: Instance,
60
- field: Field
61
- ): Internal[Field] {
62
- return getMultiInternalSlots(map, pl, field)[field]
63
- }
64
-
65
- export function getMultiInternalSlots<
66
- Instance extends object,
67
- Internal extends object,
68
- Field extends keyof Internal
69
- >(
70
- map: WeakMap<Instance, Internal>,
71
- pl: Instance,
72
- ...fields: Field[]
73
- ): Pick<Internal, Field> {
74
- const slots = map.get(pl)
75
- if (!slots) {
76
- throw new TypeError(`${pl} InternalSlot has not been initialized`)
77
- }
78
- return fields.reduce((all, f) => {
79
- all[f] = slots[f]
80
- return all
81
- }, Object.create(null) as Pick<Internal, Field>)
82
- }
83
-
84
- export interface LiteralPart {
85
- type: 'literal'
86
- value: string
87
- }
88
-
89
- export function isLiteralPart(
90
- patternPart: LiteralPart | {type: string; value?: string}
91
- ): patternPart is LiteralPart {
92
- return patternPart.type === 'literal'
93
- }
94
-
95
- /*
96
- 17 ECMAScript Standard Built-in Objects:
97
- Every built-in Function object, including constructors, that is not
98
- identified as an anonymous function has a name property whose value
99
- is a String.
100
-
101
- Unless otherwise specified, the name property of a built-in Function
102
- object, if it exists, has the attributes { [[Writable]]: false,
103
- [[Enumerable]]: false, [[Configurable]]: true }.
104
- */
105
- export function defineProperty<T extends object>(
106
- target: T,
107
- name: string | symbol,
108
- {value}: {value: any} & ThisType<any>
109
- ) {
110
- Object.defineProperty(target, name, {
111
- configurable: true,
112
- enumerable: false,
113
- writable: true,
114
- value,
115
- })
116
- }
117
-
118
- export const UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi
119
-
120
- export function invariant(
121
- condition: boolean,
122
- message: string,
123
- Err: any = Error
124
- ): asserts condition {
125
- if (!condition) {
126
- throw new Err(message)
127
- }
128
- }