src/third_party/mozjs/extract/js/src/builtin/intl/CommonFunctions.js
/**
 * Canonicalizes a locale list.
 *
 * Spec: ECMAScript Internationalization API Specification, 9.2.1.
 */
Canonicalizes a locale list.
Spec: ECMAScript Internationalization API Specification, 9.2.1.
Canonicalizes a locale list . Spec : ECMAScript Internationalization API Specification 9 . 2 . 1 .
function CanonicalizeLocaleList(locales) {
    if (locales === undefined)
        return [];
    var tag = intl_ValidateAndCanonicalizeLanguageTag(locales, false);
    if (tag !== null) {
        assert(typeof tag === "string",
               "intl_ValidateAndCanonicalizeLanguageTag returns a string value");
        return [tag];
    }
    var seen = [];
    var O = ToObject(locales);
    var len = ToLength(O.length);
    var k = 0;
    while (k < len) {
        if (k in O) {
            c.i.
            var kValue = O[k];
            c.ii.
            if (!(typeof kValue === "string" || IsObject(kValue)))
                ThrowTypeError(JSMSG_INVALID_LOCALES_ELEMENT);
            var tag = intl_ValidateAndCanonicalizeLanguageTag(kValue, true);
            assert(typeof tag === "string",
                   "ValidateAndCanonicalizeLanguageTag returns a string value");
            c.v.
            if (callFunction(ArrayIndexOf, seen, tag) === -1)
                DefineDataProperty(seen, seen.length, tag);
        }
        d.
        k++;
    }
    return seen;
}
function CanonicalizeLocaleList ( locales ) { if ( locales === undefined ) return [ ] ; var tag = intl_ValidateAndCanonicalizeLanguageTag ( locales , false ) ; if ( tag !== null ) { assert ( typeof tag === "string" , "intl_ValidateAndCanonicalizeLanguageTag returns a string value" ) ; return [ tag ] ; } var seen = [ ] ; var O = ToObject ( locales ) ; var len = ToLength ( O . length ) ; var k = 0 ; while ( k < len ) { if ( k in O ) { var kValue = O [ k ] ; if ( ! ( typeof kValue === "string" || IsObject ( kValue ) ) ) ThrowTypeError ( JSMSG_INVALID_LOCALES_ELEMENT ) ; var tag = intl_ValidateAndCanonicalizeLanguageTag ( kValue , true ) ; assert ( typeof tag === "string" , "ValidateAndCanonicalizeLanguageTag returns a string value" ) ; if ( callFunction ( ArrayIndexOf , seen , tag ) === - 1 ) DefineDataProperty ( seen , seen . length , tag ) ; } k ++ ; } return seen ; }
Canonicalizes a locale list.
Canonicalizes a locale list .
// Step 1. // Step 3 (and the remaining steps). // Step 2. // Step 4. // Step 5. // Step 6. // Step 7. // Steps 7.a-c. // Step 7.c.i. // Step 7.c.ii. // Steps 7.c.iii-iv. // Step 7.c.v. // Step 7.d. // Step 8.