npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@formatjs/intl-supportedvaluesof

v2.2.0

Published

Intl.supportedValuesOf polyfill

Readme

@formatjs/intl-supportedvaluesof

Polyfill for Intl.supportedValuesOf()

npm Version

ECMA-402 Spec Compliance

This package implements the ECMA-402 Intl.supportedValuesOf() specification:

  • Spec Section: 8.3.2 Intl.supportedValuesOf(key)
  • Returns: Supported values for internationalization keys
  • Fully spec-compliant: No optional parameters, matches native browser behavior

Installation

npm install @formatjs/intl-supportedvaluesof

Usage

As Polyfill

Import the polyfill to make Intl.supportedValuesOf available globally:

import '@formatjs/intl-supportedvaluesof/polyfill'

// Now available on the global Intl object
const calendars = Intl.supportedValuesOf('calendar')
// ['buddhist', 'chinese', 'coptic', 'dangi', 'ethioaa', 'ethiopic', 'gregory', ...]

const currencies = Intl.supportedValuesOf('currency')
// ['AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', ...]

const timeZones = Intl.supportedValuesOf('timeZone')
// ['Africa/Abidjan', 'Africa/Accra', ..., 'Pacific/Wallis']

Direct Import

Import the function directly without modifying the global namespace:

import {supportedValuesOf} from '@formatjs/intl-supportedvaluesof'

const numberingSystems = supportedValuesOf('numberingSystem')
// ['adlm', 'ahom', 'arab', 'arabext', 'bali', 'beng', 'bhks', ...]

const units = supportedValuesOf('unit')
// ['acre', 'bit', 'byte', 'celsius', 'centimeter', 'day', 'degree', ...]

Supported Keys

The function accepts one of six string keys and returns an array of supported values:

| Key | Returns | Example Values | | ------------------- | --------------------------------- | ------------------------------------------------------- | | 'calendar' | Supported calendar systems | 'gregory', 'islamic', 'buddhist', 'chinese' | | 'collation' | Supported collation algorithms | 'emoji', 'eor', 'phonebk', 'search' | | 'currency' | Supported ISO 4217 currency codes | 'USD', 'EUR', 'JPY', 'GBP' | | 'numberingSystem' | Supported numbering systems | 'arab', 'latn', 'hanidec', 'thai' | | 'timeZone' | Supported IANA time zones | 'America/New_York', 'Europe/London', 'Asia/Tokyo' | | 'unit' | Supported measurement units | 'meter', 'celsius', 'liter', 'acre' |

API

supportedValuesOf(key: string): string[]

Returns an array of supported values for the given key.

Parameters:

  • key - One of: 'calendar', 'collation', 'currency', 'numberingSystem', 'timeZone', 'unit'

Returns:

  • A sorted array of unique string values

Throws:

  • RangeError - If the key is not one of the supported values

Example:

import {supportedValuesOf} from '@formatjs/intl-supportedvaluesof'

// Valid usage
const calendars = supportedValuesOf('calendar')
console.log(calendars) // ['buddhist', 'chinese', 'coptic', ...]

// Invalid key throws RangeError
try {
  supportedValuesOf('invalid')
} catch (e) {
  console.error(e) // RangeError: Invalid key: invalid
}

Implementation Details

This polyfill dynamically validates candidate values against the actual Intl implementation rather than maintaining static lists. This approach ensures:

  • Accuracy: Results match what your JavaScript runtime actually supports
  • Runtime-specific: Different engines (V8, JavaScriptCore, SpiderMonkey) may support different values
  • Up-to-date: No need to manually update lists when new values are added to engines

How It Works

For each category, the implementation:

  1. Loads candidate values from CLDR (Unicode Common Locale Data Repository)
  2. Tests each value by attempting to create an appropriate Intl formatter with that value
  3. Validates acceptance by checking if the formatter actually uses the requested value
  4. Returns filtered list of only the values that passed validation

Example: Calendar Validation

// Implementation tests if a calendar is supported:
function isSupportedCalendar(calendar) {
  try {
    // Attempt to create DateTimeFormat with this calendar
    const formatter = new Intl.DateTimeFormat(`en-u-ca-${calendar}`)
    // Verify the calendar was actually accepted
    const resolvedOptions = formatter.resolvedOptions()
    return resolvedOptions.calendar === calendar
  } catch {
    return false
  }
}

This ensures that only calendars actually supported by your runtime are returned, not just a static list.

TypeScript Support

This package includes TypeScript type definitions. When using as a polyfill, the global Intl namespace is automatically augmented:

import '@formatjs/intl-supportedvaluesof/polyfill'

// TypeScript knows about Intl.supportedValuesOf
const calendars: string[] = Intl.supportedValuesOf('calendar')

// TypeScript will error on invalid keys
Intl.supportedValuesOf('invalid') // Error: Argument of type '"invalid"' is not assignable...

Browser Support

This polyfill is only needed for older browsers that don't have native support for Intl.supportedValuesOf(). Native support is available in:

  • Chrome 99+
  • Edge 99+
  • Firefox 93+
  • Safari 15.4+

The polyfill requires the following Intl APIs to be available:

  • Intl.DateTimeFormat (for calendar, timeZone, numberingSystem)
  • Intl.NumberFormat (for currency, unit, numberingSystem)
  • Intl.Collator (for collation)

Breaking Changes in v3.0

Removed: Non-standard locale parameter

v2.x and earlier had a non-standard optional locale parameter that filtered results by locale. This has been removed to match the ECMA-402 specification.

// ❌ v2.x (non-standard, no longer works)
const calendars = supportedValuesOf('calendar', 'en-US')

// ✅ v3.0 (spec-compliant)
const calendars = supportedValuesOf('calendar')

The function now always returns ALL supported values, matching native browser behavior.

Migration Guide

If you need locale-specific filtering in v3.0+, implement it yourself:

import {supportedValuesOf} from '@formatjs/intl-supportedvaluesof'

// Get all supported calendars
const allCalendars = supportedValuesOf('calendar')

// Filter by what a specific locale actually uses/accepts
const enUSCalendars = allCalendars.filter(calendar => {
  try {
    const formatter = new Intl.DateTimeFormat('en-US', {calendar})
    return formatter.resolvedOptions().calendar === calendar
  } catch {
    return false
  }
})

However, note that most use cases don't need locale-specific filtering, as the spec's design returns all values that any locale could use.

Examples

Check if a calendar is supported

import {supportedValuesOf} from '@formatjs/intl-supportedvaluesof'

const calendars = supportedValuesOf('calendar')

if (calendars.includes('islamic')) {
  console.log('Islamic calendar is supported')
  const formatter = new Intl.DateTimeFormat('en-US', {calendar: 'islamic'})
  console.log(formatter.format(new Date()))
}

Display all supported currencies

import {supportedValuesOf} from '@formatjs/intl-supportedvaluesof'

const currencies = supportedValuesOf('currency')

console.log(`This runtime supports ${currencies.length} currencies:`)
currencies.forEach(currency => {
  const formatter = new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency,
  })
  console.log(`${currency}: ${formatter.format(100)}`)
})

Validate user input

import {supportedValuesOf} from '@formatjs/intl-supportedvaluesof'

function isValidTimeZone(timeZone) {
  const supportedTimeZones = supportedValuesOf('timeZone')
  return supportedTimeZones.includes(timeZone)
}

console.log(isValidTimeZone('America/New_York')) // true
console.log(isValidTimeZone('Invalid/TimeZone')) // false

License

MIT

Related Packages

Resources