nl_tokens: Initializes the given object so it s a valid NumberFormat instance . Useful for subclassing .
pl_tokens: function initializeNumberFormat ( numberFormat , locales , options ) { if ( % IsInitializedIntlObject ( numberFormat ) ) { throw MakeTypeError ( kReinitializeIntl , "NumberFormat" ) ; } if ( IS_UNDEFINED ( options ) ) { options = { } ; } var getOption = getGetOption ( options , 'numberformat' ) ; var locale = resolveLocale ( 'numberformat' , locales , options ) ; var internalOptions = { } ; defineWEProperty ( internalOptions , 'style' , getOption ( 'style' , 'string' , [ 'decimal' , 'percent' , 'currency' ] , 'decimal' ) ) ; var currency = getOption ( 'currency' , 'string' ) ; if ( ! IS_UNDEFINED ( currency ) && ! isWellFormedCurrencyCode ( currency ) ) { throw MakeRangeError ( kInvalidCurrencyCode , currency ) ; } if ( internalOptions . style === 'currency' && IS_UNDEFINED ( <mask> ) ) { throw MakeTypeError ( kCurrencyCode ) ; } var currencyDisplay = getOption ( 'currencyDisplay' , 'string' , [ 'code' , 'symbol' , 'name' ] , 'symbol' ) ; if ( internalOptions . style === 'currency' ) { defineWEProperty ( internalOptions , 'currency' , % StringToUpperCase ( currency ) ) ; defineWEProperty ( internalOptions , 'currencyDisplay' , currencyDisplay ) ; } // Digit ranges. var mnid = getNumberOption ( options , 'minimumIntegerDigits' , 1 , 21 , 1 ) ; defineWEProperty ( internalOptions , 'minimumIntegerDigits' , mnid ) ; var mnfd = options [ 'minimumFractionDigits' ] ; var mxfd = options [ 'maximumFractionDigits' ] ; if ( ! IS_UNDEFINED ( mnfd ) || internalOptions . style !== 'currency' ) { mnfd = getNumberOption ( options , 'minimumFractionDigits' , 0 , 20 , 0 ) ; defineWEProperty ( internalOptions , 'minimumFractionDigits' , mnfd ) ; } if ( ! IS_UNDEFINED ( mxfd ) || internalOptions . style !== 'currency' ) { var min_mxfd = internalOptions . style === 'percent' ? 0 : 3 ; mnfd = IS_UNDEFINED ( mnfd ) ? 0 : mnfd ; var fallback_limit = ( mnfd > min_mxfd ) ? mnfd : min_mxfd ; mxfd = getNumberOption ( options , 'maximumFractionDigits' , mnfd , 20 , fallback_limit ) ; defineWEProperty ( internalOptions , 'maximumFractionDigits' , mxfd ) ; } var mnsd = options [ 'minimumSignificantDigits' ] ; var mxsd = options [ 'maximumSignificantDigits' ] ; if ( ! IS_UNDEFINED ( mnsd ) || ! IS_UNDEFINED ( mxsd ) ) { mnsd = getNumberOption ( options , 'minimumSignificantDigits' , 1 , 21 , 0 ) ; defineWEProperty ( internalOptions , 'minimumSignificantDigits' , mnsd ) ; mxsd = getNumberOption ( options , 'maximumSignificantDigits' , mnsd , 21 , 21 ) ; defineWEProperty ( internalOptions , 'maximumSignificantDigits' , mxsd ) ; } // Grouping. defineWEProperty ( internalOptions , 'useGrouping' , getOption ( 'useGrouping' , 'boolean' , UNDEFINED , true ) ) ; // ICU prefers options to be passed using -u- extension key/values for // number format, so we need to build that. var extensionMap = parseExtension ( locale . extension ) ; /**
     * Map of Unicode extensions to option properties, and their values and types,
     * for a number format.
     */ var NUMBER_FORMAT_KEY_MAP = { 'nu' : { 'property' : UNDEFINED , 'type' : 'string' } } ; var extension = setOptions ( options , extensionMap , NUMBER_FORMAT_KEY_MAP , getOption , internalOptions ) ; var requestedLocale = locale . locale + extension ; var resolved = % object_define_properties ( { } , { currency : { writable : true } , currencyDisplay : { writable : true } , locale : { writable : true } , maximumFractionDigits : { writable : true } , minimumFractionDigits : { writable : true } , minimumIntegerDigits : { writable : true } , numberingSystem : { writable : true } , requestedLocale : { value : requestedLocale , writable : true } , style : { value : internalOptions . style , writable : true } , useGrouping : { writable : true } } ) ; if ( HAS_OWN_PROPERTY ( internalOptions , 'minimumSignificantDigits' ) ) { defineWEProperty ( resolved , 'minimumSignificantDigits' , UNDEFINED ) ; } if ( HAS_OWN_PROPERTY ( internalOptions , 'maximumSignificantDigits' ) ) { defineWEProperty ( resolved , 'maximumSignificantDigits' , UNDEFINED ) ; } var formatter = % CreateNumberFormat ( requestedLocale , internalOptions , resolved ) ; if ( internalOptions . style === 'currency' ) { % object_define_property ( resolved , 'currencyDisplay' , { value : currencyDisplay , writable : true } ) ; } % MarkAsInitializedIntlObjectOfType ( numberFormat , 'numberformat' , formatter ) ; numberFormat [ resolvedSymbol ] = resolved ; if ( FLAG_intl_extra ) { % object_define_property ( resolved , 'pattern' , patternAccessor ) ; % object_define_property ( numberFormat , 'resolved' , resolvedAccessor ) ; } return numberFormat ; }