@formatjs/ecma402-abstract 1.0.3 → 1.2.2

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 (242) hide show
  1. package/262.d.ts +79 -0
  2. package/262.d.ts.map +1 -0
  3. package/262.js +336 -0
  4. package/_validate_dist-base_options.optionsvalid.d.ts +2 -1
  5. package/_validate_dist-esm_options.optionsvalid.d.ts +2 -1
  6. package/index.d.ts +33 -0
  7. package/index.d.ts.map +1 -1
  8. package/index.js +52 -11
  9. package/lib/262.d.ts +79 -0
  10. package/lib/262.d.ts.map +1 -0
  11. package/lib/262.js +312 -0
  12. package/lib/index.d.ts +33 -0
  13. package/lib/index.d.ts.map +1 -1
  14. package/lib/index.js +33 -0
  15. package/lib/src/CanonicalizeLocaleList.d.ts +6 -0
  16. package/lib/src/CanonicalizeLocaleList.d.ts.map +1 -0
  17. package/lib/src/CanonicalizeLocaleList.js +8 -0
  18. package/lib/src/CanonicalizeTimeZoneName.d.ts +9 -0
  19. package/lib/src/CanonicalizeTimeZoneName.d.ts.map +1 -0
  20. package/lib/src/CanonicalizeTimeZoneName.js +17 -0
  21. package/lib/src/DateTimeFormat/BasicFormatMatcher.d.ts +8 -0
  22. package/lib/src/DateTimeFormat/BasicFormatMatcher.d.ts.map +1 -0
  23. package/lib/src/DateTimeFormat/BasicFormatMatcher.js +61 -0
  24. package/lib/src/DateTimeFormat/BestFitFormatMatcher.d.ts +17 -0
  25. package/lib/src/DateTimeFormat/BestFitFormatMatcher.d.ts.map +1 -0
  26. package/lib/src/DateTimeFormat/BestFitFormatMatcher.js +119 -0
  27. package/lib/src/DateTimeFormat/DateTimeStyleFormat.d.ts +3 -0
  28. package/lib/src/DateTimeFormat/DateTimeStyleFormat.d.ts.map +1 -0
  29. package/lib/src/DateTimeFormat/DateTimeStyleFormat.js +50 -0
  30. package/lib/src/DateTimeFormat/FormatDateTime.d.ts +8 -0
  31. package/lib/src/DateTimeFormat/FormatDateTime.d.ts.map +1 -0
  32. package/lib/src/DateTimeFormat/FormatDateTime.js +15 -0
  33. package/lib/src/DateTimeFormat/FormatDateTimeToParts.d.ts +10 -0
  34. package/lib/src/DateTimeFormat/FormatDateTimeToParts.d.ts.map +1 -0
  35. package/lib/src/DateTimeFormat/FormatDateTimeToParts.js +21 -0
  36. package/lib/src/DateTimeFormat/InitializeDateTimeFormat.d.ts +18 -0
  37. package/lib/src/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +1 -0
  38. package/lib/src/DateTimeFormat/InitializeDateTimeFormat.js +163 -0
  39. package/lib/src/DateTimeFormat/PartitionDateTimePattern.d.ts +13 -0
  40. package/lib/src/DateTimeFormat/PartitionDateTimePattern.d.ts.map +1 -0
  41. package/lib/src/DateTimeFormat/PartitionDateTimePattern.js +176 -0
  42. package/lib/src/DateTimeFormat/ToDateTimeOptions.d.ts +9 -0
  43. package/lib/src/DateTimeFormat/ToDateTimeOptions.d.ts.map +1 -0
  44. package/lib/src/DateTimeFormat/ToDateTimeOptions.js +57 -0
  45. package/lib/src/DateTimeFormat/ToLocalTime.d.ts +24 -0
  46. package/lib/src/DateTimeFormat/ToLocalTime.d.ts.map +1 -0
  47. package/lib/src/DateTimeFormat/ToLocalTime.js +49 -0
  48. package/lib/src/DateTimeFormat/skeleton.d.ts +9 -0
  49. package/lib/src/DateTimeFormat/skeleton.d.ts.map +1 -0
  50. package/lib/src/DateTimeFormat/skeleton.js +163 -0
  51. package/lib/src/DateTimeFormat/utils.d.ts +10 -0
  52. package/lib/src/DateTimeFormat/utils.d.ts.map +1 -0
  53. package/lib/src/DateTimeFormat/utils.js +18 -0
  54. package/lib/src/DisplayNames/CanonicalCodeForDisplayNames.d.ts +2 -0
  55. package/lib/src/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +1 -0
  56. package/lib/src/DisplayNames/CanonicalCodeForDisplayNames.js +33 -0
  57. package/lib/src/GetOption.js +1 -1
  58. package/lib/src/IsValidTimeZoneName.d.ts +10 -0
  59. package/lib/src/IsValidTimeZoneName.d.ts.map +1 -0
  60. package/lib/src/IsValidTimeZoneName.js +11 -0
  61. package/lib/src/NumberFormat/ComputeExponent.d.ts +12 -0
  62. package/lib/src/NumberFormat/ComputeExponent.d.ts.map +1 -0
  63. package/lib/src/NumberFormat/ComputeExponent.js +39 -0
  64. package/lib/src/NumberFormat/ComputeExponentForMagnitude.d.ts +10 -0
  65. package/lib/src/NumberFormat/ComputeExponentForMagnitude.d.ts.map +1 -0
  66. package/lib/src/NumberFormat/ComputeExponentForMagnitude.js +60 -0
  67. package/lib/src/NumberFormat/CurrencyDigits.d.ts +7 -0
  68. package/lib/src/NumberFormat/CurrencyDigits.d.ts.map +1 -0
  69. package/lib/src/NumberFormat/CurrencyDigits.js +10 -0
  70. package/lib/src/NumberFormat/FormatNumericToParts.d.ts +5 -0
  71. package/lib/src/NumberFormat/FormatNumericToParts.d.ts.map +1 -0
  72. package/lib/src/NumberFormat/FormatNumericToParts.js +14 -0
  73. package/lib/src/NumberFormat/FormatNumericToString.js +1 -1
  74. package/lib/src/NumberFormat/InitializeNumberFormat.d.ts +13 -0
  75. package/lib/src/NumberFormat/InitializeNumberFormat.d.ts.map +1 -0
  76. package/lib/src/NumberFormat/InitializeNumberFormat.js +71 -0
  77. package/lib/src/NumberFormat/PartitionNumberPattern.d.ts +8 -0
  78. package/lib/src/NumberFormat/PartitionNumberPattern.d.ts.map +1 -0
  79. package/lib/src/NumberFormat/PartitionNumberPattern.js +74 -0
  80. package/lib/src/NumberFormat/SetNumberFormatUnitOptions.d.ts +8 -0
  81. package/lib/src/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +1 -0
  82. package/lib/src/NumberFormat/SetNumberFormatUnitOptions.js +39 -0
  83. package/lib/src/NumberFormat/digit-mapping.json +1 -0
  84. package/lib/src/NumberFormat/format_to_parts.d.ts +22 -0
  85. package/lib/src/NumberFormat/format_to_parts.d.ts.map +1 -0
  86. package/lib/src/NumberFormat/format_to_parts.js +421 -0
  87. package/lib/src/PluralRules/GetOperands.d.ts +32 -0
  88. package/lib/src/PluralRules/GetOperands.d.ts.map +1 -0
  89. package/lib/src/PluralRules/GetOperands.js +47 -0
  90. package/lib/src/PluralRules/InitializePluralRules.d.ts +9 -0
  91. package/lib/src/PluralRules/InitializePluralRules.d.ts.map +1 -0
  92. package/lib/src/PluralRules/InitializePluralRules.js +20 -0
  93. package/lib/src/PluralRules/ResolvePlural.d.ts +13 -0
  94. package/lib/src/PluralRules/ResolvePlural.d.ts.map +1 -0
  95. package/lib/src/PluralRules/ResolvePlural.js +25 -0
  96. package/lib/src/RelativeTimeFormat/FormatRelativeTime.d.ts +5 -0
  97. package/lib/src/RelativeTimeFormat/FormatRelativeTime.d.ts.map +1 -0
  98. package/lib/src/RelativeTimeFormat/FormatRelativeTime.js +10 -0
  99. package/lib/src/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +5 -0
  100. package/lib/src/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +1 -0
  101. package/lib/src/RelativeTimeFormat/FormatRelativeTimeToParts.js +18 -0
  102. package/lib/src/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +9 -0
  103. package/lib/src/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +1 -0
  104. package/lib/src/RelativeTimeFormat/InitializeRelativeTimeFormat.js +32 -0
  105. package/lib/src/RelativeTimeFormat/MakePartsList.d.ts +3 -0
  106. package/lib/src/RelativeTimeFormat/MakePartsList.d.ts.map +1 -0
  107. package/lib/src/RelativeTimeFormat/MakePartsList.js +27 -0
  108. package/lib/src/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +5 -0
  109. package/lib/src/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +1 -0
  110. package/lib/src/RelativeTimeFormat/PartitionRelativeTimePattern.js +54 -0
  111. package/lib/src/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +7 -0
  112. package/lib/src/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +1 -0
  113. package/lib/src/RelativeTimeFormat/SingularRelativeTimeUnit.js +36 -0
  114. package/lib/src/SupportedLocales.js +1 -1
  115. package/lib/src/data.js +1 -1
  116. package/lib/types/core.js +1 -0
  117. package/lib/types/date-time.d.ts +112 -0
  118. package/lib/types/date-time.d.ts.map +1 -0
  119. package/lib/types/date-time.js +1 -0
  120. package/lib/types/displaynames.js +1 -0
  121. package/lib/types/list.js +1 -0
  122. package/lib/types/number.d.ts +44 -0
  123. package/lib/types/number.d.ts.map +1 -1
  124. package/lib/types/number.js +1 -0
  125. package/lib/types/plural-rules.d.ts +6 -0
  126. package/lib/types/plural-rules.d.ts.map +1 -1
  127. package/lib/types/plural-rules.js +1 -0
  128. package/lib/types/relative-time.d.ts +63 -0
  129. package/lib/types/relative-time.d.ts.map +1 -1
  130. package/lib/types/relative-time.js +1 -0
  131. package/package.json +2 -6
  132. package/src/CanonicalizeLocaleList.d.ts +6 -0
  133. package/src/CanonicalizeLocaleList.d.ts.map +1 -0
  134. package/src/CanonicalizeLocaleList.js +12 -0
  135. package/src/CanonicalizeTimeZoneName.d.ts +9 -0
  136. package/src/CanonicalizeTimeZoneName.d.ts.map +1 -0
  137. package/src/CanonicalizeTimeZoneName.js +21 -0
  138. package/src/DateTimeFormat/BasicFormatMatcher.d.ts +8 -0
  139. package/src/DateTimeFormat/BasicFormatMatcher.d.ts.map +1 -0
  140. package/src/DateTimeFormat/BasicFormatMatcher.js +65 -0
  141. package/src/DateTimeFormat/BestFitFormatMatcher.d.ts +17 -0
  142. package/src/DateTimeFormat/BestFitFormatMatcher.d.ts.map +1 -0
  143. package/src/DateTimeFormat/BestFitFormatMatcher.js +124 -0
  144. package/src/DateTimeFormat/DateTimeStyleFormat.d.ts +3 -0
  145. package/src/DateTimeFormat/DateTimeStyleFormat.d.ts.map +1 -0
  146. package/src/DateTimeFormat/DateTimeStyleFormat.js +54 -0
  147. package/src/DateTimeFormat/FormatDateTime.d.ts +8 -0
  148. package/src/DateTimeFormat/FormatDateTime.d.ts.map +1 -0
  149. package/src/DateTimeFormat/FormatDateTime.js +19 -0
  150. package/src/DateTimeFormat/FormatDateTimeToParts.d.ts +10 -0
  151. package/src/DateTimeFormat/FormatDateTimeToParts.d.ts.map +1 -0
  152. package/src/DateTimeFormat/FormatDateTimeToParts.js +25 -0
  153. package/src/DateTimeFormat/InitializeDateTimeFormat.d.ts +18 -0
  154. package/src/DateTimeFormat/InitializeDateTimeFormat.d.ts.map +1 -0
  155. package/src/DateTimeFormat/InitializeDateTimeFormat.js +167 -0
  156. package/src/DateTimeFormat/PartitionDateTimePattern.d.ts +13 -0
  157. package/src/DateTimeFormat/PartitionDateTimePattern.d.ts.map +1 -0
  158. package/src/DateTimeFormat/PartitionDateTimePattern.js +180 -0
  159. package/src/DateTimeFormat/ToDateTimeOptions.d.ts +9 -0
  160. package/src/DateTimeFormat/ToDateTimeOptions.d.ts.map +1 -0
  161. package/src/DateTimeFormat/ToDateTimeOptions.js +61 -0
  162. package/src/DateTimeFormat/ToLocalTime.d.ts +24 -0
  163. package/src/DateTimeFormat/ToLocalTime.d.ts.map +1 -0
  164. package/src/DateTimeFormat/ToLocalTime.js +53 -0
  165. package/src/DateTimeFormat/skeleton.d.ts +9 -0
  166. package/src/DateTimeFormat/skeleton.d.ts.map +1 -0
  167. package/src/DateTimeFormat/skeleton.js +167 -0
  168. package/src/DateTimeFormat/utils.d.ts +10 -0
  169. package/src/DateTimeFormat/utils.d.ts.map +1 -0
  170. package/src/DateTimeFormat/utils.js +21 -0
  171. package/src/DisplayNames/CanonicalCodeForDisplayNames.d.ts +2 -0
  172. package/src/DisplayNames/CanonicalCodeForDisplayNames.d.ts.map +1 -0
  173. package/src/DisplayNames/CanonicalCodeForDisplayNames.js +37 -0
  174. package/src/GetOption.js +2 -5
  175. package/src/IsValidTimeZoneName.d.ts +10 -0
  176. package/src/IsValidTimeZoneName.d.ts.map +1 -0
  177. package/src/IsValidTimeZoneName.js +15 -0
  178. package/src/NumberFormat/ComputeExponent.d.ts +12 -0
  179. package/src/NumberFormat/ComputeExponent.d.ts.map +1 -0
  180. package/src/NumberFormat/ComputeExponent.js +43 -0
  181. package/src/NumberFormat/ComputeExponentForMagnitude.d.ts +10 -0
  182. package/src/NumberFormat/ComputeExponentForMagnitude.d.ts.map +1 -0
  183. package/src/NumberFormat/ComputeExponentForMagnitude.js +64 -0
  184. package/src/NumberFormat/CurrencyDigits.d.ts +7 -0
  185. package/src/NumberFormat/CurrencyDigits.d.ts.map +1 -0
  186. package/src/NumberFormat/CurrencyDigits.js +14 -0
  187. package/src/NumberFormat/FormatNumericToParts.d.ts +5 -0
  188. package/src/NumberFormat/FormatNumericToParts.d.ts.map +1 -0
  189. package/src/NumberFormat/FormatNumericToParts.js +18 -0
  190. package/src/NumberFormat/FormatNumericToString.js +2 -5
  191. package/src/NumberFormat/InitializeNumberFormat.d.ts +13 -0
  192. package/src/NumberFormat/InitializeNumberFormat.d.ts.map +1 -0
  193. package/src/NumberFormat/InitializeNumberFormat.js +75 -0
  194. package/src/NumberFormat/PartitionNumberPattern.d.ts +8 -0
  195. package/src/NumberFormat/PartitionNumberPattern.d.ts.map +1 -0
  196. package/src/NumberFormat/PartitionNumberPattern.js +81 -0
  197. package/src/NumberFormat/SetNumberFormatUnitOptions.d.ts +8 -0
  198. package/src/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +1 -0
  199. package/src/NumberFormat/SetNumberFormatUnitOptions.js +43 -0
  200. package/src/NumberFormat/digit-mapping.json +1 -0
  201. package/src/NumberFormat/format_to_parts.d.ts +22 -0
  202. package/src/NumberFormat/format_to_parts.d.ts.map +1 -0
  203. package/src/NumberFormat/format_to_parts.js +443 -0
  204. package/src/PluralRules/GetOperands.d.ts +32 -0
  205. package/src/PluralRules/GetOperands.d.ts.map +1 -0
  206. package/src/PluralRules/GetOperands.js +51 -0
  207. package/src/PluralRules/InitializePluralRules.d.ts +9 -0
  208. package/src/PluralRules/InitializePluralRules.d.ts.map +1 -0
  209. package/src/PluralRules/InitializePluralRules.js +24 -0
  210. package/src/PluralRules/ResolvePlural.d.ts +13 -0
  211. package/src/PluralRules/ResolvePlural.d.ts.map +1 -0
  212. package/src/PluralRules/ResolvePlural.js +29 -0
  213. package/src/RelativeTimeFormat/FormatRelativeTime.d.ts +5 -0
  214. package/src/RelativeTimeFormat/FormatRelativeTime.d.ts.map +1 -0
  215. package/src/RelativeTimeFormat/FormatRelativeTime.js +14 -0
  216. package/src/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts +5 -0
  217. package/src/RelativeTimeFormat/FormatRelativeTimeToParts.d.ts.map +1 -0
  218. package/src/RelativeTimeFormat/FormatRelativeTimeToParts.js +22 -0
  219. package/src/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts +9 -0
  220. package/src/RelativeTimeFormat/InitializeRelativeTimeFormat.d.ts.map +1 -0
  221. package/src/RelativeTimeFormat/InitializeRelativeTimeFormat.js +36 -0
  222. package/src/RelativeTimeFormat/MakePartsList.d.ts +3 -0
  223. package/src/RelativeTimeFormat/MakePartsList.d.ts.map +1 -0
  224. package/src/RelativeTimeFormat/MakePartsList.js +31 -0
  225. package/src/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts +5 -0
  226. package/src/RelativeTimeFormat/PartitionRelativeTimePattern.d.ts.map +1 -0
  227. package/src/RelativeTimeFormat/PartitionRelativeTimePattern.js +58 -0
  228. package/src/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts +7 -0
  229. package/src/RelativeTimeFormat/SingularRelativeTimeUnit.d.ts.map +1 -0
  230. package/src/RelativeTimeFormat/SingularRelativeTimeUnit.js +40 -0
  231. package/src/SupportedLocales.js +2 -5
  232. package/src/data.js +1 -1
  233. package/types/date-time.d.ts +112 -0
  234. package/types/date-time.d.ts.map +1 -0
  235. package/types/date-time.js +2 -0
  236. package/types/number.d.ts +44 -0
  237. package/types/number.d.ts.map +1 -1
  238. package/types/plural-rules.d.ts +6 -0
  239. package/types/plural-rules.d.ts.map +1 -1
  240. package/types/relative-time.d.ts +63 -0
  241. package/types/relative-time.d.ts.map +1 -1
  242. package/types.js +1 -1
package/lib/262.d.ts ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * https://tc39.es/ecma262/#sec-tostring
3
+ */
4
+ export declare function ToString(o: unknown): string;
5
+ /**
6
+ * https://tc39.es/ecma262/#sec-tonumber
7
+ * @param val
8
+ */
9
+ export declare function ToNumber(val: any): number;
10
+ /**
11
+ * https://tc39.es/ecma262/#sec-timeclip
12
+ * @param time
13
+ */
14
+ export declare function TimeClip(time: number): number;
15
+ /**
16
+ * https://tc39.es/ecma262/#sec-toobject
17
+ * @param arg
18
+ */
19
+ export declare function ToObject<T>(arg: T): T extends null ? never : T extends undefined ? never : T;
20
+ /**
21
+ * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-samevalue
22
+ * @param x
23
+ * @param y
24
+ */
25
+ export declare function SameValue(x: any, y: any): boolean;
26
+ /**
27
+ * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-arraycreate
28
+ * @param len
29
+ */
30
+ export declare function ArrayCreate(len: number): any[];
31
+ /**
32
+ * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-hasownproperty
33
+ * @param o
34
+ * @param prop
35
+ */
36
+ export declare function HasOwnProperty(o: object, prop: string): boolean;
37
+ /**
38
+ * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-type
39
+ * @param x
40
+ */
41
+ export declare function Type(x: any): "Null" | "Undefined" | "Object" | "Number" | "Boolean" | "String" | "Symbol" | "BigInt" | undefined;
42
+ /**
43
+ * https://tc39.es/ecma262/#eqn-Day
44
+ * @param t
45
+ */
46
+ export declare function Day(t: number): number;
47
+ /**
48
+ * https://tc39.es/ecma262/#sec-week-day
49
+ * @param t
50
+ */
51
+ export declare function WeekDay(t: number): number;
52
+ /**
53
+ * https://tc39.es/ecma262/#sec-year-number
54
+ * @param y
55
+ */
56
+ export declare function DayFromYear(y: number): number;
57
+ /**
58
+ * https://tc39.es/ecma262/#sec-year-number
59
+ * @param y
60
+ */
61
+ export declare function TimeFromYear(y: number): number;
62
+ /**
63
+ * https://tc39.es/ecma262/#sec-year-number
64
+ * @param t
65
+ */
66
+ export declare function YearFromTime(t: number): number;
67
+ export declare function DaysInYear(y: number): 365 | 366;
68
+ export declare function DayWithinYear(t: number): number;
69
+ export declare function InLeapYear(t: number): 0 | 1;
70
+ /**
71
+ * https://tc39.es/ecma262/#sec-month-number
72
+ * @param t
73
+ */
74
+ export declare function MonthFromTime(t: number): 1 | 0 | 4 | 7 | 2 | 3 | 5 | 6 | 8 | 9 | 10 | 11;
75
+ export declare function DateFromTime(t: number): number;
76
+ export declare function HourFromTime(t: number): number;
77
+ export declare function MinFromTime(t: number): number;
78
+ export declare function SecFromTime(t: number): number;
79
+ //# sourceMappingURL=262.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"262.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/262.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAM3C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAiBzC;AAwBD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,UAQpC;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,GAAG,EAAE,CAAC,GACL,CAAC,SAAS,IAAI,GAAG,KAAK,GAAG,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAK1D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,WAYvC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,SAEtC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAErD;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,GAAG,uGAyB1B;AAcD;;;GAGG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,UAE5B;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,UAEhC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,UAOpC;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,UAErC;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,UAOrC;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,aAWnC;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,UAEtC;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,CAAC,CAE3C;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,mDAwCtC;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,UAyCrC;AASD,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,UAErC;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,UAEpC;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,UAEpC"}
package/lib/262.js ADDED
@@ -0,0 +1,312 @@
1
+ /**
2
+ * https://tc39.es/ecma262/#sec-tostring
3
+ */
4
+ export function ToString(o) {
5
+ // Only symbol is irregular...
6
+ if (typeof o === 'symbol') {
7
+ throw TypeError('Cannot convert a Symbol value to a string');
8
+ }
9
+ return String(o);
10
+ }
11
+ /**
12
+ * https://tc39.es/ecma262/#sec-tonumber
13
+ * @param val
14
+ */
15
+ export function ToNumber(val) {
16
+ if (val === undefined) {
17
+ return NaN;
18
+ }
19
+ if (val === null) {
20
+ return +0;
21
+ }
22
+ if (typeof val === 'boolean') {
23
+ return val ? 1 : +0;
24
+ }
25
+ if (typeof val === 'number') {
26
+ return val;
27
+ }
28
+ if (typeof val === 'symbol' || typeof val === 'bigint') {
29
+ throw new TypeError('Cannot convert symbol/bigint to number');
30
+ }
31
+ return Number(val);
32
+ }
33
+ /**
34
+ * https://tc39.es/ecma262/#sec-tointeger
35
+ * @param n
36
+ */
37
+ function ToInteger(n) {
38
+ var number = ToNumber(n);
39
+ if (isNaN(number) || SameValue(number, -0)) {
40
+ return 0;
41
+ }
42
+ if (isFinite(number)) {
43
+ return number;
44
+ }
45
+ var integer = Math.floor(Math.abs(number));
46
+ if (number < 0) {
47
+ integer = -integer;
48
+ }
49
+ if (SameValue(integer, -0)) {
50
+ return 0;
51
+ }
52
+ return integer;
53
+ }
54
+ /**
55
+ * https://tc39.es/ecma262/#sec-timeclip
56
+ * @param time
57
+ */
58
+ export function TimeClip(time) {
59
+ if (!isFinite(time)) {
60
+ return NaN;
61
+ }
62
+ if (Math.abs(time) > 8.64 * 1e16) {
63
+ return NaN;
64
+ }
65
+ return ToInteger(time);
66
+ }
67
+ /**
68
+ * https://tc39.es/ecma262/#sec-toobject
69
+ * @param arg
70
+ */
71
+ export function ToObject(arg) {
72
+ if (arg == null) {
73
+ throw new TypeError('undefined/null cannot be converted to object');
74
+ }
75
+ return Object(arg);
76
+ }
77
+ /**
78
+ * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-samevalue
79
+ * @param x
80
+ * @param y
81
+ */
82
+ export function SameValue(x, y) {
83
+ if (Object.is) {
84
+ return Object.is(x, y);
85
+ }
86
+ // SameValue algorithm
87
+ if (x === y) {
88
+ // Steps 1-5, 7-10
89
+ // Steps 6.b-6.e: +0 != -0
90
+ return x !== 0 || 1 / x === 1 / y;
91
+ }
92
+ // Step 6.a: NaN == NaN
93
+ return x !== x && y !== y;
94
+ }
95
+ /**
96
+ * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-arraycreate
97
+ * @param len
98
+ */
99
+ export function ArrayCreate(len) {
100
+ return new Array(len);
101
+ }
102
+ /**
103
+ * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-hasownproperty
104
+ * @param o
105
+ * @param prop
106
+ */
107
+ export function HasOwnProperty(o, prop) {
108
+ return Object.prototype.hasOwnProperty.call(o, prop);
109
+ }
110
+ /**
111
+ * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-type
112
+ * @param x
113
+ */
114
+ export function Type(x) {
115
+ if (x === null) {
116
+ return 'Null';
117
+ }
118
+ if (typeof x === 'undefined') {
119
+ return 'Undefined';
120
+ }
121
+ if (typeof x === 'function' || typeof x === 'object') {
122
+ return 'Object';
123
+ }
124
+ if (typeof x === 'number') {
125
+ return 'Number';
126
+ }
127
+ if (typeof x === 'boolean') {
128
+ return 'Boolean';
129
+ }
130
+ if (typeof x === 'string') {
131
+ return 'String';
132
+ }
133
+ if (typeof x === 'symbol') {
134
+ return 'Symbol';
135
+ }
136
+ if (typeof x === 'bigint') {
137
+ return 'BigInt';
138
+ }
139
+ }
140
+ var MS_PER_DAY = 86400000;
141
+ /**
142
+ * https://www.ecma-international.org/ecma-262/11.0/index.html#eqn-modulo
143
+ * @param x
144
+ * @param y
145
+ * @return k of the same sign as y
146
+ */
147
+ function mod(x, y) {
148
+ return x - Math.floor(x / y) * y;
149
+ }
150
+ /**
151
+ * https://tc39.es/ecma262/#eqn-Day
152
+ * @param t
153
+ */
154
+ export function Day(t) {
155
+ return Math.floor(t / MS_PER_DAY);
156
+ }
157
+ /**
158
+ * https://tc39.es/ecma262/#sec-week-day
159
+ * @param t
160
+ */
161
+ export function WeekDay(t) {
162
+ return mod(Day(t) + 4, 7);
163
+ }
164
+ /**
165
+ * https://tc39.es/ecma262/#sec-year-number
166
+ * @param y
167
+ */
168
+ export function DayFromYear(y) {
169
+ return (365 * (y - 1970) +
170
+ Math.floor((y - 1969) / 4) -
171
+ Math.floor((y - 1901) / 100) +
172
+ Math.floor((y - 1601) / 400));
173
+ }
174
+ /**
175
+ * https://tc39.es/ecma262/#sec-year-number
176
+ * @param y
177
+ */
178
+ export function TimeFromYear(y) {
179
+ return MS_PER_DAY * DayFromYear(y);
180
+ }
181
+ /**
182
+ * https://tc39.es/ecma262/#sec-year-number
183
+ * @param t
184
+ */
185
+ export function YearFromTime(t) {
186
+ var min = Math.ceil(t / MS_PER_DAY / 366);
187
+ var y = min;
188
+ while (TimeFromYear(y) <= t) {
189
+ y++;
190
+ }
191
+ return y - 1;
192
+ }
193
+ export function DaysInYear(y) {
194
+ if (y % 4 !== 0) {
195
+ return 365;
196
+ }
197
+ if (y % 100 !== 0) {
198
+ return 366;
199
+ }
200
+ if (y % 400 !== 0) {
201
+ return 365;
202
+ }
203
+ return 366;
204
+ }
205
+ export function DayWithinYear(t) {
206
+ return Day(t) - DayFromYear(YearFromTime(t));
207
+ }
208
+ export function InLeapYear(t) {
209
+ return DaysInYear(YearFromTime(t)) === 365 ? 0 : 1;
210
+ }
211
+ /**
212
+ * https://tc39.es/ecma262/#sec-month-number
213
+ * @param t
214
+ */
215
+ export function MonthFromTime(t) {
216
+ var dwy = DayWithinYear(t);
217
+ var leap = InLeapYear(t);
218
+ if (dwy >= 0 && dwy < 31) {
219
+ return 0;
220
+ }
221
+ if (dwy < 59 + leap) {
222
+ return 1;
223
+ }
224
+ if (dwy < 90 + leap) {
225
+ return 2;
226
+ }
227
+ if (dwy < 120 + leap) {
228
+ return 3;
229
+ }
230
+ if (dwy < 151 + leap) {
231
+ return 4;
232
+ }
233
+ if (dwy < 181 + leap) {
234
+ return 5;
235
+ }
236
+ if (dwy < 212 + leap) {
237
+ return 6;
238
+ }
239
+ if (dwy < 243 + leap) {
240
+ return 7;
241
+ }
242
+ if (dwy < 273 + leap) {
243
+ return 8;
244
+ }
245
+ if (dwy < 304 + leap) {
246
+ return 9;
247
+ }
248
+ if (dwy < 334 + leap) {
249
+ return 10;
250
+ }
251
+ if (dwy < 365 + leap) {
252
+ return 11;
253
+ }
254
+ throw new Error('Invalid time');
255
+ }
256
+ export function DateFromTime(t) {
257
+ var dwy = DayWithinYear(t);
258
+ var mft = MonthFromTime(t);
259
+ var leap = InLeapYear(t);
260
+ if (mft === 0) {
261
+ return dwy + 1;
262
+ }
263
+ if (mft === 1) {
264
+ return dwy - 30;
265
+ }
266
+ if (mft === 2) {
267
+ return dwy - 58 - leap;
268
+ }
269
+ if (mft === 3) {
270
+ return dwy - 89 - leap;
271
+ }
272
+ if (mft === 4) {
273
+ return dwy - 119 - leap;
274
+ }
275
+ if (mft === 5) {
276
+ return dwy - 150 - leap;
277
+ }
278
+ if (mft === 6) {
279
+ return dwy - 180 - leap;
280
+ }
281
+ if (mft === 7) {
282
+ return dwy - 211 - leap;
283
+ }
284
+ if (mft === 8) {
285
+ return dwy - 242 - leap;
286
+ }
287
+ if (mft === 9) {
288
+ return dwy - 272 - leap;
289
+ }
290
+ if (mft === 10) {
291
+ return dwy - 303 - leap;
292
+ }
293
+ if (mft === 11) {
294
+ return dwy - 333 - leap;
295
+ }
296
+ throw new Error('Invalid time');
297
+ }
298
+ var HOURS_PER_DAY = 24;
299
+ var MINUTES_PER_HOUR = 60;
300
+ var SECONDS_PER_MINUTE = 60;
301
+ var MS_PER_SECOND = 1e3;
302
+ var MS_PER_MINUTE = MS_PER_SECOND * SECONDS_PER_MINUTE;
303
+ var MS_PER_HOUR = MS_PER_MINUTE * MINUTES_PER_HOUR;
304
+ export function HourFromTime(t) {
305
+ return mod(Math.floor(t / MS_PER_HOUR), HOURS_PER_DAY);
306
+ }
307
+ export function MinFromTime(t) {
308
+ return mod(Math.floor(t / MS_PER_MINUTE), MINUTES_PER_HOUR);
309
+ }
310
+ export function SecFromTime(t) {
311
+ return mod(Math.floor(t / MS_PER_SECOND), SECONDS_PER_MINUTE);
312
+ }
package/lib/index.d.ts CHANGED
@@ -1,22 +1,55 @@
1
+ export { BestFitFormatMatcher } from './src/DateTimeFormat/BestFitFormatMatcher';
2
+ export * from './src/CanonicalizeLocaleList';
3
+ export * from './src/CanonicalizeTimeZoneName';
4
+ export * from './src/DateTimeFormat/BasicFormatMatcher';
5
+ export * from './src/DateTimeFormat/DateTimeStyleFormat';
6
+ export * from './src/DateTimeFormat/FormatDateTime';
7
+ export * from './src/DateTimeFormat/FormatDateTimeToParts';
8
+ export * from './src/DateTimeFormat/InitializeDateTimeFormat';
9
+ export * from './src/DateTimeFormat/PartitionDateTimePattern';
10
+ export * from './src/DateTimeFormat/ToDateTimeOptions';
11
+ export * from './src/DisplayNames/CanonicalCodeForDisplayNames';
1
12
  export * from './src/GetNumberOption';
2
13
  export * from './src/GetOption';
3
14
  export * from './src/IsSanctionedSimpleUnitIdentifier';
15
+ export * from './src/IsValidTimeZoneName';
4
16
  export * from './src/IsWellFormedCurrencyCode';
5
17
  export * from './src/IsWellFormedUnitIdentifier';
18
+ export * from './src/NumberFormat/ComputeExponent';
19
+ export * from './src/NumberFormat/ComputeExponentForMagnitude';
20
+ export * from './src/NumberFormat/CurrencyDigits';
21
+ export * from './src/NumberFormat/FormatNumericToParts';
6
22
  export * from './src/NumberFormat/FormatNumericToString';
23
+ export * from './src/NumberFormat/InitializeNumberFormat';
24
+ export * from './src/NumberFormat/PartitionNumberPattern';
7
25
  export * from './src/NumberFormat/SetNumberFormatDigitOptions';
26
+ export * from './src/NumberFormat/SetNumberFormatUnitOptions';
8
27
  export * from './src/NumberFormat/ToRawFixed';
9
28
  export * from './src/NumberFormat/ToRawPrecision';
10
29
  export * from './src/PartitionPattern';
30
+ export * from './src/PluralRules/GetOperands';
31
+ export * from './src/PluralRules/InitializePluralRules';
32
+ export * from './src/PluralRules/ResolvePlural';
33
+ export * from './src/RelativeTimeFormat/FormatRelativeTime';
34
+ export * from './src/RelativeTimeFormat/FormatRelativeTimeToParts';
35
+ export * from './src/RelativeTimeFormat/InitializeRelativeTimeFormat';
36
+ export * from './src/RelativeTimeFormat/MakePartsList';
37
+ export * from './src/RelativeTimeFormat/PartitionRelativeTimePattern';
38
+ export * from './src/RelativeTimeFormat/SingularRelativeTimeUnit';
11
39
  export * from './src/ResolveLocale';
12
40
  export * from './src/SupportedLocales';
41
+ export { default as _formatToParts } from './src/NumberFormat/format_to_parts';
42
+ export { DATE_TIME_PROPS } from './src/DateTimeFormat/utils';
43
+ export { parseDateTimeSkeleton } from './src/DateTimeFormat/skeleton';
13
44
  export { getInternalSlot, getMultiInternalSlots, isLiteralPart, LiteralPart, setInternalSlot, setMultiInternalSlots, getMagnitude, defineProperty, } from './src/utils';
14
45
  export { getLocaleHierarchy, unpackData, isMissingLocaleDataError, } from './src/data';
15
46
  export * from './types/relative-time';
47
+ export * from './types/date-time';
16
48
  export * from './types/list';
17
49
  export * from './types/plural-rules';
18
50
  export * from './types/number';
19
51
  export * from './types/displaynames';
20
52
  export { invariant } from './src/utils';
21
53
  export { LocaleData } from './types/core';
54
+ export * from './262';
22
55
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wCAAwC,CAAC;AACvD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,0CAA0C,CAAC;AACzD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,2CAA2C,CAAC;AAC/E,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AACzD,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,wCAAwC,CAAC;AACvD,cAAc,iDAAiD,CAAC;AAChE,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wCAAwC,CAAC;AACvD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC;AACnD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,mCAAmC,CAAC;AAClD,cAAc,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AACzD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yCAAyC,CAAC;AACxD,cAAc,iCAAiC,CAAC;AAChD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,oDAAoD,CAAC;AACnE,cAAc,uDAAuD,CAAC;AACtE,cAAc,wCAAwC,CAAC;AACvD,cAAc,uDAAuD,CAAC;AACtE,cAAc,mDAAmD,CAAC;AAClE,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAC,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AACpE,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,cAAc,OAAO,CAAC"}
package/lib/index.js CHANGED
@@ -1,20 +1,53 @@
1
+ export { BestFitFormatMatcher } from './src/DateTimeFormat/BestFitFormatMatcher';
2
+ export * from './src/CanonicalizeLocaleList';
3
+ export * from './src/CanonicalizeTimeZoneName';
4
+ export * from './src/DateTimeFormat/BasicFormatMatcher';
5
+ export * from './src/DateTimeFormat/DateTimeStyleFormat';
6
+ export * from './src/DateTimeFormat/FormatDateTime';
7
+ export * from './src/DateTimeFormat/FormatDateTimeToParts';
8
+ export * from './src/DateTimeFormat/InitializeDateTimeFormat';
9
+ export * from './src/DateTimeFormat/PartitionDateTimePattern';
10
+ export * from './src/DateTimeFormat/ToDateTimeOptions';
11
+ export * from './src/DisplayNames/CanonicalCodeForDisplayNames';
1
12
  export * from './src/GetNumberOption';
2
13
  export * from './src/GetOption';
3
14
  export * from './src/IsSanctionedSimpleUnitIdentifier';
15
+ export * from './src/IsValidTimeZoneName';
4
16
  export * from './src/IsWellFormedCurrencyCode';
5
17
  export * from './src/IsWellFormedUnitIdentifier';
18
+ export * from './src/NumberFormat/ComputeExponent';
19
+ export * from './src/NumberFormat/ComputeExponentForMagnitude';
20
+ export * from './src/NumberFormat/CurrencyDigits';
21
+ export * from './src/NumberFormat/FormatNumericToParts';
6
22
  export * from './src/NumberFormat/FormatNumericToString';
23
+ export * from './src/NumberFormat/InitializeNumberFormat';
24
+ export * from './src/NumberFormat/PartitionNumberPattern';
7
25
  export * from './src/NumberFormat/SetNumberFormatDigitOptions';
26
+ export * from './src/NumberFormat/SetNumberFormatUnitOptions';
8
27
  export * from './src/NumberFormat/ToRawFixed';
9
28
  export * from './src/NumberFormat/ToRawPrecision';
10
29
  export * from './src/PartitionPattern';
30
+ export * from './src/PluralRules/GetOperands';
31
+ export * from './src/PluralRules/InitializePluralRules';
32
+ export * from './src/PluralRules/ResolvePlural';
33
+ export * from './src/RelativeTimeFormat/FormatRelativeTime';
34
+ export * from './src/RelativeTimeFormat/FormatRelativeTimeToParts';
35
+ export * from './src/RelativeTimeFormat/InitializeRelativeTimeFormat';
36
+ export * from './src/RelativeTimeFormat/MakePartsList';
37
+ export * from './src/RelativeTimeFormat/PartitionRelativeTimePattern';
38
+ export * from './src/RelativeTimeFormat/SingularRelativeTimeUnit';
11
39
  export * from './src/ResolveLocale';
12
40
  export * from './src/SupportedLocales';
41
+ export { default as _formatToParts } from './src/NumberFormat/format_to_parts';
42
+ export { DATE_TIME_PROPS } from './src/DateTimeFormat/utils';
43
+ export { parseDateTimeSkeleton } from './src/DateTimeFormat/skeleton';
13
44
  export { getInternalSlot, getMultiInternalSlots, isLiteralPart, setInternalSlot, setMultiInternalSlots, getMagnitude, defineProperty, } from './src/utils';
14
45
  export { getLocaleHierarchy, unpackData, isMissingLocaleDataError, } from './src/data';
15
46
  export * from './types/relative-time';
47
+ export * from './types/date-time';
16
48
  export * from './types/list';
17
49
  export * from './types/plural-rules';
18
50
  export * from './types/number';
19
51
  export * from './types/displaynames';
20
52
  export { invariant } from './src/utils';
53
+ export * from './262';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
3
+ * @param locales
4
+ */
5
+ export declare function CanonicalizeLocaleList(locales?: string | string[]): any;
6
+ //# sourceMappingURL=CanonicalizeLocaleList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CanonicalizeLocaleList.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/src/CanonicalizeLocaleList.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,OAGjE"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
3
+ * @param locales
4
+ */
5
+ export function CanonicalizeLocaleList(locales) {
6
+ // TODO
7
+ return Intl.getCanonicalLocales(locales);
8
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * https://tc39.es/ecma402/#sec-canonicalizetimezonename
3
+ * @param tz
4
+ */
5
+ export declare function CanonicalizeTimeZoneName(tz: string, { tzData, uppercaseLinks, }: {
6
+ tzData: Record<string, unknown>;
7
+ uppercaseLinks: Record<string, string>;
8
+ }): string;
9
+ //# sourceMappingURL=CanonicalizeTimeZoneName.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CanonicalizeTimeZoneName.d.ts","sourceRoot":"","sources":["../../../../../../../packages/ecma402-abstract/src/CanonicalizeTimeZoneName.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,MAAM,EACV,EACE,MAAM,EACN,cAAc,GACf,EAAE;IACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,UAgBF"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * https://tc39.es/ecma402/#sec-canonicalizetimezonename
3
+ * @param tz
4
+ */
5
+ export function CanonicalizeTimeZoneName(tz, _a) {
6
+ var tzData = _a.tzData, uppercaseLinks = _a.uppercaseLinks;
7
+ var uppercasedTz = tz.toUpperCase();
8
+ var uppercasedZones = Object.keys(tzData).reduce(function (all, z) {
9
+ all[z.toUpperCase()] = z;
10
+ return all;
11
+ }, {});
12
+ var ianaTimeZone = uppercaseLinks[uppercasedTz] || uppercasedZones[uppercasedTz];
13
+ if (ianaTimeZone === 'Etc/UTC' || ianaTimeZone === 'Etc/GMT') {
14
+ return 'UTC';
15
+ }
16
+ return ianaTimeZone;
17
+ }
@@ -0,0 +1,8 @@
1
+ import { DateTimeFormatOptions, Formats } from '../../types/date-time';
2
+ /**
3
+ * https://tc39.es/ecma402/#sec-basicformatmatcher
4
+ * @param options
5
+ * @param formats
6
+ */
7
+ export declare function BasicFormatMatcher(options: DateTimeFormatOptions, formats: Formats[]): Formats;
8
+ //# sourceMappingURL=BasicFormatMatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BasicFormatMatcher.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/ecma402-abstract/src/DateTimeFormat/BasicFormatMatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAE,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAYrE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,OAAO,EAAE,GACjB,OAAO,CAsCT"}
@@ -0,0 +1,61 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { invariant } from '../utils';
13
+ import { DATE_TIME_PROPS, additionPenalty, removalPenalty, longMorePenalty, shortMorePenalty, shortLessPenalty, longLessPenalty, } from './utils';
14
+ /**
15
+ * https://tc39.es/ecma402/#sec-basicformatmatcher
16
+ * @param options
17
+ * @param formats
18
+ */
19
+ export function BasicFormatMatcher(options, formats) {
20
+ var bestScore = -Infinity;
21
+ var bestFormat = formats[0];
22
+ invariant(Array.isArray(formats), 'formats should be a list of things');
23
+ for (var _i = 0, formats_1 = formats; _i < formats_1.length; _i++) {
24
+ var format = formats_1[_i];
25
+ var score = 0;
26
+ for (var _a = 0, DATE_TIME_PROPS_1 = DATE_TIME_PROPS; _a < DATE_TIME_PROPS_1.length; _a++) {
27
+ var prop = DATE_TIME_PROPS_1[_a];
28
+ var optionsProp = options[prop];
29
+ var formatProp = format[prop];
30
+ if (optionsProp === undefined && formatProp !== undefined) {
31
+ score -= additionPenalty;
32
+ }
33
+ else if (optionsProp !== undefined && formatProp === undefined) {
34
+ score -= removalPenalty;
35
+ }
36
+ else if (optionsProp !== formatProp) {
37
+ var values = ['2-digit', 'numeric', 'narrow', 'short', 'long'];
38
+ var optionsPropIndex = values.indexOf(optionsProp);
39
+ var formatPropIndex = values.indexOf(formatProp);
40
+ var delta = Math.max(-2, Math.min(formatPropIndex - optionsPropIndex, 2));
41
+ if (delta === 2) {
42
+ score -= longMorePenalty;
43
+ }
44
+ else if (delta === 1) {
45
+ score -= shortMorePenalty;
46
+ }
47
+ else if (delta === -1) {
48
+ score -= shortLessPenalty;
49
+ }
50
+ else if (delta === -2) {
51
+ score -= longLessPenalty;
52
+ }
53
+ }
54
+ }
55
+ if (score > bestScore) {
56
+ bestScore = score;
57
+ bestFormat = format;
58
+ }
59
+ }
60
+ return __assign({}, bestFormat);
61
+ }
@@ -0,0 +1,17 @@
1
+ import { DateTimeFormatOptions, Formats } from '../../types/date-time';
2
+ /**
3
+ * Credit: https://github.com/andyearnshaw/Intl.js/blob/0958dc1ad8153f1056653ea22b8208f0df289a4e/src/12.datetimeformat.js#L611
4
+ * with some modifications
5
+ * @param options
6
+ * @param format
7
+ */
8
+ export declare function bestFitFormatMatcherScore(options: DateTimeFormatOptions, format: Formats): number;
9
+ /**
10
+ * https://tc39.es/ecma402/#sec-bestfitformatmatcher
11
+ * Just alias to basic for now
12
+ * @param options
13
+ * @param formats
14
+ * @param implDetails Implementation details
15
+ */
16
+ export declare function BestFitFormatMatcher(options: DateTimeFormatOptions, formats: Formats[]): Formats;
17
+ //# sourceMappingURL=BestFitFormatMatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BestFitFormatMatcher.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/ecma402-abstract/src/DateTimeFormat/BestFitFormatMatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAE,OAAO,EAAU,MAAM,uBAAuB,CAAC;AAoB9E;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE,OAAO,GACd,MAAM,CA0CR;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,OAAO,EAAE,WA+CnB"}