src/third_party/mozjs/extract/js/src/builtin/intl/RelativeTimeFormat.js
/**
 * Initializes an object as a RelativeTimeFormat.
 *
 * This method is complicated a moderate bit by its implementing initialization
 * as a *lazy* concept.  Everything that must happen now, does -- but we defer
 * all the work we can until the object is actually used as a RelativeTimeFormat.
 * This later work occurs in |resolveRelativeTimeFormatInternals|; steps not noted
 * here occur there.
 *
 * Spec: ECMAScript 402 API, RelativeTimeFormat, 1.1.1.
 */
Initializes an object as a RelativeTimeFormat.
This method is complicated a moderate bit by its implementing initialization
as a *lazy* concept.  Everything that must happen now, does -- but we defer
all the work we can until the object is actually used as a RelativeTimeFormat.
This later work occurs in |resolveRelativeTimeFormatInternals|; steps not noted
here occur there.


Initializes an object as a RelativeTimeFormat . This method is complicated a moderate bit by its implementing initialization as a * lazy * concept . Everything that must happen now does -- but we defer all the work we can until the object is actually used as a RelativeTimeFormat . This later work occurs in |resolveRelativeTimeFormatInternals| ; steps not noted here occur there .
function InitializeRelativeTimeFormat(relativeTimeFormat, locales, options) {
    assert(IsObject(relativeTimeFormat),
           "InitializeRelativeimeFormat called with non-object");
    assert(intl_GuardToRelativeTimeFormat(relativeTimeFormat) !== null,
           "InitializeRelativeTimeFormat called with non-RelativeTimeFormat");
       {
         requestedLocales: List of locales,
         style: "long" / "short" / "narrow",
         numeric: "always" / "auto",
         opt:  opt object computed in InitializeRelativeTimeFormat
           {
             localeMatcher: "lookup" / "best fit",
           }
       }
     Note that lazy data is only installed as a final step of initialization,
     so every RelativeTimeFormat lazy data object has *all* these properties, never a
     subset of them.
    const lazyRelativeTimeFormatData = std_Object_create(null);
     Step 1.
    let requestedLocales = CanonicalizeLocaleList(locales);
    lazyRelativeTimeFormatData.requestedLocales = requestedLocales;
     Steps 2-3.
    if (options === undefined)
        options = std_Object_create(null);
    else
        options = ToObject(options);
     Step 4.
    let opt = new_Record();
     Steps 5-6.
    let matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
    opt.localeMatcher = matcher;
     Steps 7-9.
    let numberingSystem = GetOption(options, "numberingSystem", "string", undefined, undefined);
    if (numberingSystem !== undefined) {
        numberingSystem = intl_ValidateAndCanonicalizeUnicodeExtensionType(numberingSystem,
                                                                           "numberingSystem",
                                                                           "nu");
    }
    opt.nu = numberingSystem;
    lazyRelativeTimeFormatData.opt = opt;
     Steps 16-17.
    const style = GetOption(options, "style", "string", ["long", "short", "narrow"], "long");
    lazyRelativeTimeFormatData.style = style;
     Steps 18-19.
    const numeric = GetOption(options, "numeric", "string", ["always", "auto"], "always");
    lazyRelativeTimeFormatData.numeric = numeric;
    initializeIntlObject(relativeTimeFormat, "RelativeTimeFormat", lazyRelativeTimeFormatData);
}
function InitializeRelativeTimeFormat ( relativeTimeFormat , locales , options ) { assert ( IsObject ( relativeTimeFormat ) , "InitializeRelativeimeFormat called with non-object" ) ; assert ( intl_GuardToRelativeTimeFormat ( relativeTimeFormat ) !== null , "InitializeRelativeTimeFormat called with non-RelativeTimeFormat" ) ; const lazyRelativeTimeFormatData = std_Object_create ( null ) ; let requestedLocales = CanonicalizeLocaleList ( locales ) ; lazyRelativeTimeFormatData . requestedLocales = requestedLocales ; if ( options === undefined ) options = std_Object_create ( null ) ; else options = ToObject ( options ) ; let opt = new_Record ( ) ; let matcher = GetOption ( options , "localeMatcher" , "string" , [ "lookup" , "best fit" ] , "best fit" ) ; opt . localeMatcher = matcher ; let numberingSystem = GetOption ( options , "numberingSystem" , "string" , undefined , undefined ) ; if ( numberingSystem !== undefined ) { numberingSystem = intl_ValidateAndCanonicalizeUnicodeExtensionType ( numberingSystem , "numberingSystem" , "nu" ) ; } opt . nu = numberingSystem ; lazyRelativeTimeFormatData . opt = opt ; const style = GetOption ( options , "style" , "string" , [ "long" , "short" , "narrow" ] , "long" ) ; lazyRelativeTimeFormatData . style = style ; const numeric = GetOption ( options , "numeric" , "string" , [ "always" , "auto" ] , "always" ) ; lazyRelativeTimeFormatData . numeric = numeric ; initializeIntlObject ( relativeTimeFormat , "RelativeTimeFormat" , lazyRelativeTimeFormatData ) ; }
Initializes an object as a RelativeTimeFormat.
Initializes an object as a RelativeTimeFormat .
// Lazy RelativeTimeFormat data has the following structure: // //   { //     requestedLocales: List of locales, //     style: "long" / "short" / "narrow", //     numeric: "always" / "auto", // //     opt: // opt object computed in InitializeRelativeTimeFormat //       { //         localeMatcher: "lookup" / "best fit", //       } //   } // // Note that lazy data is only installed as a final step of initialization, // so every RelativeTimeFormat lazy data object has *all* these properties, never a // subset of them. // Step 1. // Steps 2-3. // Step 4. // Steps 5-6. // Steps 7-9. // Steps 16-17. // Steps 18-19.