@formatjs/intl-supportedvaluesof 2.1.2 → 2.2.0

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 (65) hide show
  1. package/index.d.ts +8 -0
  2. package/index.js +2 -0
  3. package/package.json +5 -5
  4. package/polyfill-force.d.ts +1 -0
  5. package/polyfill-force.js +7 -0
  6. package/polyfill.d.ts +1 -0
  7. package/polyfill.iife.js +6105 -0
  8. package/polyfill.js +10 -0
  9. package/should-polyfill.d.ts +1 -0
  10. package/should-polyfill.js +3 -0
  11. package/src/calendars.generated.d.ts +2 -0
  12. package/src/calendars.generated.js +23 -0
  13. package/src/collations.generated.d.ts +2 -0
  14. package/src/collations.generated.js +23 -0
  15. package/src/currencies.generated.d.ts +2 -0
  16. package/src/currencies.generated.js +311 -0
  17. package/src/get-supported-calendars.d.ts +8 -0
  18. package/src/get-supported-calendars.js +27 -0
  19. package/src/get-supported-collations.d.ts +8 -0
  20. package/src/get-supported-collations.js +23 -0
  21. package/src/get-supported-currencies.d.ts +8 -0
  22. package/src/get-supported-currencies.js +50 -0
  23. package/src/get-supported-numbering-systems.d.ts +7 -0
  24. package/src/get-supported-numbering-systems.js +28 -0
  25. package/src/get-supported-timezones.d.ts +8 -0
  26. package/src/get-supported-timezones.js +25 -0
  27. package/src/get-supported-units.d.ts +7 -0
  28. package/src/get-supported-units.js +28 -0
  29. package/src/index.d.ts +33 -0
  30. package/src/index.js +34 -0
  31. package/src/memoize.d.ts +9 -0
  32. package/src/memoize.js +10 -0
  33. package/src/numbering-systems.generated.d.ts +1 -0
  34. package/src/numbering-systems.generated.js +99 -0
  35. package/src/timezones.generated.d.ts +2 -0
  36. package/src/timezones.generated.js +431 -0
  37. package/src/units.generated.d.ts +2 -0
  38. package/src/units.generated.js +47 -0
  39. package/BUILD.bazel +0 -135
  40. package/CHANGELOG.md +0 -249
  41. package/index.ts +0 -9
  42. package/polyfill-force.ts +0 -8
  43. package/polyfill.ts +0 -11
  44. package/scripts/calendars.ts +0 -21
  45. package/scripts/collations.ts +0 -21
  46. package/scripts/currencies.ts +0 -21
  47. package/scripts/timezones.ts +0 -22
  48. package/scripts/units.ts +0 -23
  49. package/should-polyfill.ts +0 -3
  50. package/src/calendars.generated.ts +0 -4
  51. package/src/collations.generated.ts +0 -4
  52. package/src/currencies.generated.ts +0 -4
  53. package/src/get-supported-calendars.ts +0 -32
  54. package/src/get-supported-collations.ts +0 -30
  55. package/src/get-supported-currencies.ts +0 -62
  56. package/src/get-supported-numbering-systems.ts +0 -35
  57. package/src/get-supported-timezones.ts +0 -29
  58. package/src/get-supported-units.ts +0 -73
  59. package/src/index.ts +0 -75
  60. package/src/memoize.ts +0 -19
  61. package/src/numbering-systems.generated.ts +0 -99
  62. package/src/timezones.generated.ts +0 -4
  63. package/src/units.generated.ts +0 -4
  64. package/tests/index.test.ts +0 -155
  65. package/tsconfig.json +0 -5
@@ -1,62 +0,0 @@
1
- import {createMemoizedNumberFormat} from '@formatjs/ecma402-abstract'
2
- import type {Currency} from './currencies.generated.js'
3
- import {currencies} from './currencies.generated.js'
4
-
5
- /**
6
- * Implementation: Tests if a currency is supported by attempting to create
7
- * a NumberFormat with that currency and verifying it was accepted.
8
- *
9
- * CLDR Data: Candidate values come from CLDR currency codes (ISO 4217)
10
- */
11
- function isSupportedCurrency(currency: Currency): boolean {
12
- try {
13
- // Always use 'en' for testing
14
- const numberFormat = createMemoizedNumberFormat('en', {
15
- style: 'currency',
16
- currencyDisplay: 'name',
17
- currency,
18
- })
19
-
20
- const format = numberFormat.format(123)
21
-
22
- if (
23
- format.substring(0, 3) !== currency &&
24
- format.substring(format.length - 3) !== currency
25
- ) {
26
- return true
27
- }
28
- } catch {}
29
-
30
- return false
31
- }
32
-
33
- /**
34
- * ECMA-402 Spec: Returns supported currency identifiers
35
- * ECMA-402 Spec: Results must be sorted lexicographically
36
- *
37
- * Implementation: Filters CLDR list against actual runtime support
38
- */
39
- export function getSupportedCurrencies(): Currency[] {
40
- const ATOZ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
41
- const supportedCurrencies: Currency[] = []
42
-
43
- for (const currency of currencies) {
44
- if (currency.length === 3) {
45
- if (isSupportedCurrency(currency)) {
46
- supportedCurrencies.push(currency)
47
- }
48
- } else if (currency.length === 5 && currency[3] === '~') {
49
- const start = ATOZ.indexOf(currency[2])
50
- const end = ATOZ.indexOf(currency[4])
51
-
52
- for (let i = start; i <= end; i++) {
53
- const currentCurrency = (currency.substring(0, 2) + ATOZ[i]) as Currency
54
- if (isSupportedCurrency(currentCurrency)) {
55
- supportedCurrencies.push(currentCurrency)
56
- }
57
- }
58
- }
59
- }
60
-
61
- return supportedCurrencies.sort()
62
- }
@@ -1,35 +0,0 @@
1
- import {createMemoizedNumberFormat} from '@formatjs/ecma402-abstract'
2
- import {numberingSystemNames} from './numbering-systems.generated.js'
3
-
4
- /**
5
- * Implementation: Tests if a numbering system is supported by attempting to create
6
- * a NumberFormat with that numbering system and verifying it was accepted.
7
- *
8
- * CLDR Data: Candidate values come from CLDR numbering system types
9
- */
10
- function isSupportedNumberingSystem(system: string): boolean {
11
- try {
12
- // Always use 'en' for testing
13
- const numberFormat = createMemoizedNumberFormat(`en-u-nu-${system}`)
14
- const options = numberFormat.resolvedOptions().numberingSystem
15
-
16
- if (
17
- (options === system && system === 'latn') ||
18
- numberFormat.format(123) !== '123'
19
- ) {
20
- return true
21
- }
22
- } catch {}
23
-
24
- return false
25
- }
26
-
27
- /**
28
- * ECMA-402 Spec: Returns supported numbering system identifiers
29
- * ECMA-402 Spec: Results must be sorted lexicographically
30
- *
31
- * Implementation: Filters CLDR list against actual runtime support
32
- */
33
- export function getSupportedNumberingSystems(): string[] {
34
- return numberingSystemNames.filter(isSupportedNumberingSystem).sort()
35
- }
@@ -1,29 +0,0 @@
1
- import {createMemoizedDateTimeFormat} from './memoize.js'
2
- import type {Timezone} from './timezones.generated.js'
3
- import {timezones} from './timezones.generated.js'
4
-
5
- /**
6
- * Implementation: Tests if a timezone is supported by attempting to create
7
- * a DateTimeFormat with that timezone and verifying it was accepted.
8
- *
9
- * CLDR Data: Candidate values come from IANA Time Zone Database
10
- */
11
- function isSupportedTimeZone(timeZone: Timezone): boolean {
12
- try {
13
- // Always use 'en' for testing
14
- const formatter = createMemoizedDateTimeFormat('en', {timeZone})
15
- return formatter.resolvedOptions().timeZone === timeZone
16
- } catch {}
17
-
18
- return false
19
- }
20
-
21
- /**
22
- * ECMA-402 Spec: Returns supported timezone identifiers
23
- * ECMA-402 Spec: Results must be sorted lexicographically
24
- *
25
- * Implementation: Filters CLDR list against actual runtime support
26
- */
27
- export function getSupportedTimeZones(): Timezone[] {
28
- return timezones.filter(isSupportedTimeZone).sort()
29
- }
@@ -1,73 +0,0 @@
1
- import {createMemoizedNumberFormat} from '@formatjs/ecma402-abstract'
2
- import type {Unit} from './units.generated.js'
3
- import {units} from './units.generated.js'
4
-
5
- /**
6
- * Implementation: Tests if a unit is supported by attempting to create
7
- * a NumberFormat with that unit and verifying it was accepted.
8
- *
9
- * CLDR Data: Candidate values come from CLDR unit types
10
- */
11
- function isSupportedUnit(unit: Unit): boolean {
12
- try {
13
- // Always use 'en' for testing
14
- const formatter = createMemoizedNumberFormat('en', {style: 'unit', unit})
15
- return formatter.resolvedOptions().unit === unit
16
- } catch {}
17
-
18
- return false
19
- }
20
-
21
- /**
22
- * ECMA-402 Spec: Returns supported unit identifiers
23
- * ECMA-402 Spec: Results must be sorted lexicographically
24
- *
25
- * Implementation: Filters CLDR list against actual runtime support
26
- */
27
- export function getSupportedUnits(): (
28
- | 'degree'
29
- | 'acre'
30
- | 'hectare'
31
- | 'percent'
32
- | 'bit'
33
- | 'byte'
34
- | 'gigabit'
35
- | 'gigabyte'
36
- | 'kilobit'
37
- | 'kilobyte'
38
- | 'megabit'
39
- | 'megabyte'
40
- | 'petabyte'
41
- | 'terabit'
42
- | 'terabyte'
43
- | 'day'
44
- | 'hour'
45
- | 'millisecond'
46
- | 'minute'
47
- | 'month'
48
- | 'second'
49
- | 'week'
50
- | 'year'
51
- | 'centimeter'
52
- | 'foot'
53
- | 'inch'
54
- | 'kilometer'
55
- | 'meter'
56
- | 'mile-scandinavian'
57
- | 'mile'
58
- | 'millimeter'
59
- | 'yard'
60
- | 'gram'
61
- | 'kilogram'
62
- | 'ounce'
63
- | 'pound'
64
- | 'stone'
65
- | 'celsius'
66
- | 'fahrenheit'
67
- | 'fluid-ounce'
68
- | 'gallon'
69
- | 'liter'
70
- | 'milliliter'
71
- )[] {
72
- return units.filter(isSupportedUnit).sort()
73
- }
package/src/index.ts DELETED
@@ -1,75 +0,0 @@
1
- import {getSupportedCalendars} from './get-supported-calendars.js'
2
- import {getSupportedCollations} from './get-supported-collations.js'
3
- import {getSupportedCurrencies} from './get-supported-currencies.js'
4
- import {getSupportedNumberingSystems} from './get-supported-numbering-systems.js'
5
- import {getSupportedTimeZones} from './get-supported-timezones.js'
6
- import {getSupportedUnits} from './get-supported-units.js'
7
-
8
- /**
9
- * ECMA-402 Spec: Intl.supportedValuesOf
10
- * https://tc39.es/ecma402/#sec-intl.supportedvaluesof
11
- */
12
- declare global {
13
- namespace Intl {
14
- /**
15
- * Returns an array containing the supported values for the given key.
16
- * @param key - The category of values to return
17
- * @returns A sorted array of strings
18
- */
19
- function supportedValuesOf(
20
- key:
21
- | 'calendar'
22
- | 'collation'
23
- | 'currency'
24
- | 'numberingSystem'
25
- | 'timeZone'
26
- | 'unit'
27
- ): string[]
28
- }
29
- }
30
-
31
- /**
32
- * ECMA-402 Spec: Supported value categories
33
- */
34
- export type SupportedValuesOf =
35
- | 'calendar'
36
- | 'collation'
37
- | 'currency'
38
- | 'numberingSystem'
39
- | 'timeZone'
40
- | 'unit'
41
-
42
- /**
43
- * ECMA-402 Spec: Intl.supportedValuesOf(key)
44
- * https://tc39.es/ecma402/#sec-intl.supportedvaluesof
45
- *
46
- * Returns an array containing the supported calendar, collation, currency,
47
- * numbering systems, time zone, or unit values supported by the implementation.
48
- *
49
- * Implementation: We validate candidate values from CLDR against the actual
50
- * Intl formatters to determine runtime support rather than using static lists.
51
- * This ensures accuracy across different JavaScript engines and runtimes.
52
- *
53
- * @param key - The category of values to return
54
- * @returns A sorted array of unique string values
55
- */
56
- export function supportedValuesOf(key: SupportedValuesOf): string[] {
57
- // ECMA-402 Spec: Dispatch to appropriate getter based on key
58
- switch (key) {
59
- case 'calendar':
60
- return getSupportedCalendars()
61
- case 'collation':
62
- return getSupportedCollations()
63
- case 'currency':
64
- return getSupportedCurrencies()
65
- case 'numberingSystem':
66
- return getSupportedNumberingSystems()
67
- case 'timeZone':
68
- return getSupportedTimeZones()
69
- case 'unit':
70
- return getSupportedUnits()
71
- default:
72
- // ECMA-402 Spec: Throw RangeError for invalid keys
73
- throw RangeError('Invalid key: ' + key)
74
- }
75
- }
package/src/memoize.ts DELETED
@@ -1,19 +0,0 @@
1
- import {memoize, strategies} from '@formatjs/fast-memoize'
2
-
3
- /**
4
- * Implementation: Memoized factory for Intl.DateTimeFormat instances
5
- *
6
- * Creates and caches DateTimeFormat instances to avoid repeated instantiation overhead.
7
- * This is critical for performance since we test many candidate values against formatters.
8
- *
9
- * Uses variadic memoization strategy to handle varying numbers of constructor arguments.
10
- */
11
- export const createMemoizedDateTimeFormat: (
12
- ...args: ConstructorParameters<typeof Intl.DateTimeFormat>
13
- ) => Intl.DateTimeFormat = memoize(
14
- (...args: ConstructorParameters<typeof Intl.DateTimeFormat>) =>
15
- new Intl.DateTimeFormat(...args),
16
- {
17
- strategy: strategies.variadic,
18
- }
19
- )
@@ -1,99 +0,0 @@
1
- export const numberingSystemNames: ReadonlyArray<string> = [
2
- 'adlm',
3
- 'ahom',
4
- 'arab',
5
- 'arabext',
6
- 'armn',
7
- 'armnlow',
8
- 'bali',
9
- 'beng',
10
- 'bhks',
11
- 'brah',
12
- 'cakm',
13
- 'cham',
14
- 'cyrl',
15
- 'deva',
16
- 'diak',
17
- 'ethi',
18
- 'fullwide',
19
- 'gara',
20
- 'geor',
21
- 'gong',
22
- 'gonm',
23
- 'grek',
24
- 'greklow',
25
- 'gujr',
26
- 'gukh',
27
- 'guru',
28
- 'hanidays',
29
- 'hanidec',
30
- 'hans',
31
- 'hansfin',
32
- 'hant',
33
- 'hantfin',
34
- 'hebr',
35
- 'hmng',
36
- 'hmnp',
37
- 'java',
38
- 'jpan',
39
- 'jpanfin',
40
- 'jpanyear',
41
- 'kali',
42
- 'kawi',
43
- 'khmr',
44
- 'knda',
45
- 'krai',
46
- 'lana',
47
- 'lanatham',
48
- 'laoo',
49
- 'latn',
50
- 'lepc',
51
- 'limb',
52
- 'mathbold',
53
- 'mathdbl',
54
- 'mathmono',
55
- 'mathsanb',
56
- 'mathsans',
57
- 'mlym',
58
- 'modi',
59
- 'mong',
60
- 'mroo',
61
- 'mtei',
62
- 'mymr',
63
- 'mymrepka',
64
- 'mymrpao',
65
- 'mymrshan',
66
- 'mymrtlng',
67
- 'nagm',
68
- 'newa',
69
- 'nkoo',
70
- 'olck',
71
- 'onao',
72
- 'orya',
73
- 'osma',
74
- 'outlined',
75
- 'rohg',
76
- 'roman',
77
- 'romanlow',
78
- 'saur',
79
- 'segment',
80
- 'shrd',
81
- 'sind',
82
- 'sinh',
83
- 'sora',
84
- 'sund',
85
- 'sunu',
86
- 'takr',
87
- 'talu',
88
- 'taml',
89
- 'tamldec',
90
- 'telu',
91
- 'thai',
92
- 'tibt',
93
- 'tirh',
94
- 'tnsa',
95
- 'tols',
96
- 'vaii',
97
- 'wara',
98
- 'wcho',
99
- ]
@@ -1,4 +0,0 @@
1
- /* @generated */
2
- // prettier-ignore
3
- export const timezones = ["Africa/Abidjan","Africa/Accra","Africa/Addis_Ababa","Africa/Algiers","Africa/Asmara","Africa/Bamako","Africa/Bangui","Africa/Banjul","Africa/Bissau","Africa/Blantyre","Africa/Brazzaville","Africa/Bujumbura","Africa/Cairo","Africa/Casablanca","Africa/Ceuta","Africa/Conakry","Africa/Dakar","Africa/Dar_es_Salaam","Africa/Djibouti","Africa/Douala","Africa/El_Aaiun","Africa/Freetown","Africa/Gaborone","Africa/Harare","Africa/Johannesburg","Africa/Juba","Africa/Kampala","Africa/Khartoum","Africa/Kigali","Africa/Kinshasa","Africa/Lagos","Africa/Libreville","Africa/Lome","Africa/Luanda","Africa/Lubumbashi","Africa/Lusaka","Africa/Malabo","Africa/Maputo","Africa/Maseru","Africa/Mbabane","Africa/Mogadishu","Africa/Monrovia","Africa/Nairobi","Africa/Ndjamena","Africa/Niamey","Africa/Nouakchott","Africa/Ouagadougou","Africa/Porto-Novo","Africa/Sao_Tome","Africa/Tripoli","Africa/Tunis","Africa/Windhoek","America/Adak","America/Anchorage","America/Anguilla","America/Antigua","America/Araguaina","America/Argentina/Buenos_Aires","America/Argentina/Catamarca","America/Argentina/Cordoba","America/Argentina/Jujuy","America/Argentina/La_Rioja","America/Argentina/Mendoza","America/Argentina/Rio_Gallegos","America/Argentina/Salta","America/Argentina/San_Juan","America/Argentina/San_Luis","America/Argentina/Tucuman","America/Argentina/Ushuaia","America/Aruba","America/Asuncion","America/Atikokan","America/Bahia_Banderas","America/Bahia","America/Barbados","America/Belem","America/Belize","America/Blanc-Sablon","America/Boa_Vista","America/Bogota","America/Boise","America/Cambridge_Bay","America/Campo_Grande","America/Cancun","America/Caracas","America/Cayenne","America/Cayman","America/Chicago","America/Chihuahua","America/Ciudad_Juarez","America/Costa_Rica","America/Coyhaique","America/Creston","America/Cuiaba","America/Curacao","America/Danmarkshavn","America/Dawson_Creek","America/Dawson","America/Denver","America/Detroit","America/Dominica","America/Edmonton","America/Eirunepe","America/El_Salvador","America/Fort_Nelson","America/Fortaleza","America/Glace_Bay","America/Goose_Bay","America/Grand_Turk","America/Grenada","America/Guadeloupe","America/Guatemala","America/Guayaquil","America/Guyana","America/Halifax","America/Havana","America/Hermosillo","America/Indiana/Indianapolis","America/Indiana/Knox","America/Indiana/Marengo","America/Indiana/Petersburg","America/Indiana/Tell_City","America/Indiana/Vevay","America/Indiana/Vincennes","America/Indiana/Winamac","America/Inuvik","America/Iqaluit","America/Jamaica","America/Juneau","America/Kentucky/Louisville","America/Kentucky/Monticello","America/Kralendijk","America/La_Paz","America/Lima","America/Los_Angeles","America/Lower_Princes","America/Maceio","America/Managua","America/Manaus","America/Marigot","America/Martinique","America/Matamoros","America/Mazatlan","America/Menominee","America/Merida","America/Metlakatla","America/Mexico_City","America/Miquelon","America/Moncton","America/Monterrey","America/Montevideo","America/Montserrat","America/Nassau","America/New_York","America/Nipigon","America/Nome","America/Noronha","America/North_Dakota/Beulah","America/North_Dakota/Center","America/North_Dakota/New_Salem","America/Nuuk","America/Ojinaga","America/Panama","America/Pangnirtung","America/Paramaribo","America/Phoenix","America/Port_of_Spain","America/Port-au-Prince","America/Porto_Velho","America/Puerto_Rico","America/Punta_Arenas","America/Rainy_River","America/Rankin_Inlet","America/Recife","America/Regina","America/Resolute","America/Rio_Branco","America/Santarem","America/Santiago","America/Santo_Domingo","America/Sao_Paulo","America/Scoresbysund","America/Sitka","America/St_Barthelemy","America/St_Johns","America/St_Kitts","America/St_Lucia","America/St_Thomas","America/St_Vincent","America/Swift_Current","America/Tegucigalpa","America/Thule","America/Thunder_Bay","America/Tijuana","America/Toronto","America/Tortola","America/Vancouver","America/Whitehorse","America/Winnipeg","America/Yakutat","America/Yellowknife","Antarctica/Casey","Antarctica/Davis","Antarctica/DumontDUrville","Antarctica/Macquarie","Antarctica/Mawson","Antarctica/McMurdo","Antarctica/Palmer","Antarctica/Rothera","Antarctica/Syowa","Antarctica/Troll","Antarctica/Vostok","Arctic/Longyearbyen","Asia/Aden","Asia/Almaty","Asia/Amman","Asia/Anadyr","Asia/Aqtau","Asia/Aqtobe","Asia/Ashgabat","Asia/Atyrau","Asia/Baghdad","Asia/Bahrain","Asia/Baku","Asia/Bangkok","Asia/Barnaul","Asia/Beirut","Asia/Bishkek","Asia/Brunei","Asia/Chita","Asia/Choibalsan","Asia/Colombo","Asia/Damascus","Asia/Dhaka","Asia/Dili","Asia/Dubai","Asia/Dushanbe","Asia/Famagusta","Asia/Gaza","Asia/Hebron","Asia/Ho_Chi_Minh","Asia/Hong_Kong","Asia/Hovd","Asia/Irkutsk","Asia/Jakarta","Asia/Jayapura","Asia/Jerusalem","Asia/Kabul","Asia/Kamchatka","Asia/Karachi","Asia/Kathmandu","Asia/Khandyga","Asia/Kolkata","Asia/Krasnoyarsk","Asia/Kuala_Lumpur","Asia/Kuching","Asia/Kuwait","Asia/Macau","Asia/Magadan","Asia/Makassar","Asia/Manila","Asia/Muscat","Asia/Nicosia","Asia/Novokuznetsk","Asia/Novosibirsk","Asia/Omsk","Asia/Oral","Asia/Phnom_Penh","Asia/Pontianak","Asia/Pyongyang","Asia/Qatar","Asia/Qostanay","Asia/Qyzylorda","Asia/Riyadh","Asia/Sakhalin","Asia/Samarkand","Asia/Seoul","Asia/Shanghai","Asia/Singapore","Asia/Srednekolymsk","Asia/Taipei","Asia/Tashkent","Asia/Tbilisi","Asia/Tehran","Asia/Thimphu","Asia/Tokyo","Asia/Tomsk","Asia/Ulaanbaatar","Asia/Urumqi","Asia/Ust-Nera","Asia/Vientiane","Asia/Vladivostok","Asia/Yakutsk","Asia/Yangon","Asia/Yekaterinburg","Asia/Yerevan","Atlantic/Azores","Atlantic/Bermuda","Atlantic/Canary","Atlantic/Cape_Verde","Atlantic/Faroe","Atlantic/Madeira","Atlantic/Reykjavik","Atlantic/South_Georgia","Atlantic/St_Helena","Atlantic/Stanley","Australia/Adelaide","Australia/Brisbane","Australia/Broken_Hill","Australia/Currie","Australia/Darwin","Australia/Eucla","Australia/Hobart","Australia/Lindeman","Australia/Lord_Howe","Australia/Melbourne","Australia/Perth","Australia/Sydney","Europe/Amsterdam","Europe/Andorra","Europe/Astrakhan","Europe/Athens","Europe/Belgrade","Europe/Berlin","Europe/Bratislava","Europe/Brussels","Europe/Bucharest","Europe/Budapest","Europe/Busingen","Europe/Chisinau","Europe/Copenhagen","Europe/Dublin","Europe/Gibraltar","Europe/Guernsey","Europe/Helsinki","Europe/Isle_of_Man","Europe/Istanbul","Europe/Jersey","Europe/Kaliningrad","Europe/Kyiv","Europe/Kirov","Europe/Lisbon","Europe/Ljubljana","Europe/London","Europe/Luxembourg","Europe/Madrid","Europe/Malta","Europe/Mariehamn","Europe/Minsk","Europe/Monaco","Europe/Moscow","Europe/Oslo","Europe/Paris","Europe/Podgorica","Europe/Prague","Europe/Riga","Europe/Rome","Europe/Samara","Europe/San_Marino","Europe/Sarajevo","Europe/Saratov","Europe/Simferopol","Europe/Skopje","Europe/Sofia","Europe/Stockholm","Europe/Tallinn","Europe/Tirane","Europe/Ulyanovsk","Europe/Uzhgorod","Europe/Vaduz","Europe/Vatican","Europe/Vienna","Europe/Vilnius","Europe/Volgograd","Europe/Warsaw","Europe/Zagreb","Europe/Zaporozhye","Europe/Zurich","Indian/Antananarivo","Indian/Chagos","Indian/Christmas","Indian/Cocos","Indian/Comoro","Indian/Kerguelen","Indian/Mahe","Indian/Maldives","Indian/Mauritius","Indian/Mayotte","Indian/Reunion","Pacific/Apia","Pacific/Auckland","Pacific/Bougainville","Pacific/Chatham","Pacific/Chuuk","Pacific/Easter","Pacific/Efate","Pacific/Kanton","Pacific/Fakaofo","Pacific/Fiji","Pacific/Funafuti","Pacific/Galapagos","Pacific/Gambier","Pacific/Guadalcanal","Pacific/Guam","Pacific/Honolulu","Pacific/Kiritimati","Pacific/Kosrae","Pacific/Kwajalein","Pacific/Majuro","Pacific/Marquesas","Pacific/Midway","Pacific/Nauru","Pacific/Niue","Pacific/Norfolk","Pacific/Noumea","Pacific/Pago_Pago","Pacific/Palau","Pacific/Pitcairn","Pacific/Pohnpei","Pacific/Port_Moresby","Pacific/Rarotonga","Pacific/Saipan","Pacific/Tahiti","Pacific/Tarawa","Pacific/Tongatapu","Pacific/Wake","Pacific/Wallis"] as const
4
- export type Timezone = (typeof timezones)[number]
@@ -1,4 +0,0 @@
1
- /* @generated */
2
- // prettier-ignore
3
- export const units = ["degree","acre","hectare","percent","bit","byte","gigabit","gigabyte","kilobit","kilobyte","megabit","megabyte","petabyte","terabit","terabyte","day","hour","millisecond","minute","month","second","week","year","centimeter","foot","inch","kilometer","meter","mile-scandinavian","mile","millimeter","yard","gram","kilogram","ounce","pound","stone","celsius","fahrenheit","fluid-ounce","gallon","liter","milliliter"] as const
4
- export type Unit = (typeof units)[number]
@@ -1,155 +0,0 @@
1
- import {supportedValuesOf} from '../src/index.js'
2
- import {describe, expect, it} from 'vitest'
3
-
4
- describe('Intl.supportedValuesOf', () => {
5
- describe('ECMA-402 spec compliance', () => {
6
- it('should return an array for valid keys', () => {
7
- // ECMA-402 Spec: Must return an array
8
- const result = supportedValuesOf('calendar')
9
- expect(Array.isArray(result)).toBe(true)
10
- })
11
-
12
- it('should throw RangeError for invalid key', () => {
13
- // ECMA-402 Spec: Throw RangeError for invalid keys
14
- // @ts-expect-error
15
- expect(() => supportedValuesOf('invalid')).toThrow(RangeError)
16
- // @ts-expect-error
17
- expect(() => supportedValuesOf('calendars')).toThrowError(
18
- 'Invalid key: calendars'
19
- )
20
- // @ts-expect-error
21
- expect(() => supportedValuesOf('calendarz')).toThrowError(RangeError)
22
- })
23
-
24
- it('should return sorted arrays', () => {
25
- // ECMA-402 Spec: Results must be sorted lexicographically
26
- const keys = [
27
- 'calendar',
28
- 'collation',
29
- 'currency',
30
- 'numberingSystem',
31
- 'timeZone',
32
- 'unit',
33
- ] as const
34
-
35
- for (const key of keys) {
36
- const result = supportedValuesOf(key)
37
- const sorted = [...result].sort()
38
- expect(result).toEqual(sorted)
39
- }
40
- })
41
-
42
- it('should return non-empty arrays for all keys', () => {
43
- // Implementation: All keys must return at least some supported values
44
- const keys = [
45
- 'calendar',
46
- 'collation',
47
- 'currency',
48
- 'numberingSystem',
49
- 'timeZone',
50
- 'unit',
51
- ] as const
52
-
53
- for (const key of keys) {
54
- const result = supportedValuesOf(key)
55
- expect(result.length).toBeGreaterThan(0)
56
- }
57
- })
58
-
59
- it('should return unique values', () => {
60
- // ECMA-402 Spec: Array must contain unique values
61
- const keys = [
62
- 'calendar',
63
- 'collation',
64
- 'currency',
65
- 'numberingSystem',
66
- 'timeZone',
67
- 'unit',
68
- ] as const
69
-
70
- for (const key of keys) {
71
- const result = supportedValuesOf(key)
72
- const unique = [...new Set(result)]
73
- expect(result).toEqual(unique)
74
- }
75
- })
76
- })
77
-
78
- describe('calendar', () => {
79
- it('should return an array of supported calendars', () => {
80
- const result = supportedValuesOf('calendar')
81
- expect(result).toEqual(expect.any(Array))
82
- expect(result.length).toBeGreaterThan(0)
83
- })
84
-
85
- it('should include gregorian calendar', () => {
86
- // Implementation: Gregorian calendar should always be supported
87
- const result = supportedValuesOf('calendar')
88
- expect(result).toContain('gregory')
89
- })
90
- })
91
-
92
- describe('collation', () => {
93
- it('should return an array of supported collations', () => {
94
- const result = supportedValuesOf('collation')
95
- expect(result).toEqual(expect.any(Array))
96
- expect(result.length).toBeGreaterThan(0)
97
- })
98
- })
99
-
100
- describe('currency', () => {
101
- it('should return an array of supported currencies', () => {
102
- const result = supportedValuesOf('currency')
103
- expect(result).toEqual(expect.any(Array))
104
- expect(result.length).toBeGreaterThan(0)
105
- })
106
-
107
- it('should include common currencies', () => {
108
- // Implementation: Common currencies should be supported
109
- const result = supportedValuesOf('currency')
110
- expect(result).toContain('USD')
111
- expect(result).toContain('EUR')
112
- })
113
- })
114
-
115
- describe('numberingSystem', () => {
116
- it('should return an array of supported numbering systems', () => {
117
- const result = supportedValuesOf('numberingSystem')
118
- expect(result).toEqual(expect.any(Array))
119
- expect(result.length).toBeGreaterThan(0)
120
- })
121
-
122
- it('should include latin numbering system', () => {
123
- // Implementation: Latin numbering system should always be supported
124
- const result = supportedValuesOf('numberingSystem')
125
- expect(result).toContain('latn')
126
- })
127
- })
128
-
129
- describe('timeZone', () => {
130
- it('should return an array of supported time zones', () => {
131
- const result = supportedValuesOf('timeZone')
132
- expect(result).toEqual(expect.any(Array))
133
- expect(result.length).toBeGreaterThan(0)
134
- })
135
-
136
- it('should include common IANA timezones', () => {
137
- // Implementation: Common IANA timezones should be supported
138
- const result = supportedValuesOf('timeZone')
139
- // Test for a commonly available timezone
140
- const hasCommonTimezone =
141
- result.includes('America/New_York') ||
142
- result.includes('Europe/London') ||
143
- result.includes('Asia/Tokyo')
144
- expect(hasCommonTimezone).toBe(true)
145
- })
146
- })
147
-
148
- describe('unit', () => {
149
- it('should return an array of supported units', () => {
150
- const result = supportedValuesOf('unit')
151
- expect(result).toEqual(expect.any(Array))
152
- expect(result.length).toBeGreaterThan(0)
153
- })
154
- })
155
- })
package/tsconfig.json DELETED
@@ -1,5 +0,0 @@
1
- // @generated
2
- {
3
- // This is purely for IDE, not for compilation
4
- "extends": "../../tsconfig.json"
5
- }