MCPcopy
hub / github.com/formatjs/formatjs / isLocaleObject

Function isLocaleObject

packages/intl-getcanonicallocales/index.ts:15–23  ·  view source on GitHub ↗

* Check if value is an Intl.Locale object by checking for [[InitializedLocale]] internal slot * We detect this by checking if it's an Intl.Locale instance * * Per ECMA-402 #sec-canonicalizelocalelist step 7.c: * "If Type(kValue) is Object and kValue has an [[InitializedLocale]] internal slot, th

(value: any)

Source from the content-addressed store, hash-verified

13 * https://tc39.es/ecma402/#sec-canonicalizelocalelist
14 */
15function isLocaleObject(value: any): value is Intl.Locale {
16 return (
17 typeof value === 'object' &&
18 value !== null &&
19 typeof value.toString === 'function' &&
20 typeof value.baseName === 'string' &&
21 typeof value.language === 'string'
22 )
23}
24
25/**
26 * https://tc39.es/ecma402/#sec-canonicalizelocalelist

Callers 1

CanonicalizeLocaleListFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected