@phensley/cldr-core
Advanced tools
Comparing version 0.2.10 to 0.2.11
@@ -18,3 +18,3 @@ import { NumberFormatOptions, RoundingModeType } from './options'; | ||
currencyDigits: number; | ||
constructor(options: NumberFormatOptions, currencyDigits?: number); | ||
constructor(options: NumberFormatOptions, compact: boolean, currencyDigits?: number); | ||
/** | ||
@@ -21,0 +21,0 @@ * Set a pattern. |
@@ -8,3 +8,3 @@ "use strict"; | ||
var NumberContext = /** @class */ (function () { | ||
function NumberContext(options, currencyDigits) { | ||
function NumberContext(options, compact, currencyDigits) { | ||
if (currencyDigits === void 0) { currencyDigits = -1; } | ||
@@ -14,7 +14,10 @@ this.maxSig = -1; | ||
this.currencyDigits = -1; | ||
this.options = options; | ||
var o = options; | ||
this.options = o; | ||
this.roundingMode = options.round || 'half-even'; | ||
this.currencyDigits = currencyDigits; | ||
this.useSignificant = options.minimumSignificantDigits !== undefined || | ||
options.maximumSignificantDigits !== undefined; | ||
// Determine if we should use default or significant digit modes. | ||
this.useSignificant = | ||
(compact && o.maximumFractionDigits === undefined && o.minimumFractionDigits === undefined) || | ||
(!compact && o.minimumSignificantDigits === undefined && o.maximumSignificantDigits === undefined); | ||
} | ||
@@ -33,2 +36,5 @@ /** | ||
var maxSigDigits = Math.max(pattern.minInt, integerDigits); | ||
if (integerDigits === 1) { | ||
maxSigDigits++; | ||
} | ||
this._setPattern(pattern, maxSigDigits, 1, maxFracDigits); | ||
@@ -40,3 +46,3 @@ }; | ||
NumberContext.prototype.adjust = function (n) { | ||
if (this.useSignificant && this.maxSig > 0 && this.maxSig > 0) { | ||
if (this.useSignificant && this.minSig > 0 && this.maxSig > 0) { | ||
if (n.precision() > this.maxSig) { | ||
@@ -43,0 +49,0 @@ // Scale the number to have at most the maximum significant digits. |
import { Bundle, CurrencyType } from '@phensley/cldr-schema'; | ||
import { NumbersInternal } from './internal'; | ||
import { CurrencyFormatOptions, CurrencySymbolWidthType, DecimalFormatOptions, NumberParams } from './options'; | ||
import { CurrencyFormatOptions, CurrencySymbolWidthType, DecimalFormatOptions, NumberParams, NumberSystemType } from './options'; | ||
import { DecimalArg, Part } from '../../types'; | ||
/** | ||
* Locale-specific number parameters. | ||
*/ | ||
export declare const getNumberParams: (bundle: Bundle, internal: NumbersInternal) => NumberParams; | ||
/** | ||
* Number and currency formatting. | ||
@@ -15,5 +11,5 @@ */ | ||
protected readonly bundle: Bundle; | ||
private params; | ||
private numberParams; | ||
constructor(internal: NumbersInternal, bundle: Bundle); | ||
getNumberParams(): NumberParams; | ||
getNumberParams(numberSystem?: NumberSystemType): NumberParams; | ||
/** | ||
@@ -33,6 +29,6 @@ * Return the symbol for the given currency. | ||
getPluralOrdinal(n: DecimalArg): string; | ||
formatDecimal(n: DecimalArg, options: DecimalFormatOptions): string; | ||
formatDecimalParts(n: DecimalArg, options: DecimalFormatOptions): Part[]; | ||
formatCurrency(n: DecimalArg, code: CurrencyType, options: CurrencyFormatOptions): string; | ||
formatCurrencyParts(n: DecimalArg, code: CurrencyType, options: CurrencyFormatOptions): Part[]; | ||
formatDecimal(n: DecimalArg, options?: DecimalFormatOptions): string; | ||
formatDecimalParts(n: DecimalArg, options?: DecimalFormatOptions): Part[]; | ||
formatCurrency(n: DecimalArg, code: CurrencyType, options?: CurrencyFormatOptions): string; | ||
formatCurrencyParts(n: DecimalArg, code: CurrencyType, options?: CurrencyFormatOptions): Part[]; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var cldr_schema_1 = require("@phensley/cldr-schema"); | ||
var params_1 = require("./params"); | ||
var plurals_1 = require("../plurals"); | ||
@@ -8,19 +9,2 @@ var render_1 = require("./render"); | ||
/** | ||
* Locale-specific number parameters. | ||
*/ | ||
exports.getNumberParams = function (bundle, internal) { | ||
var root = internal.root; | ||
var currencySpacing = root.Numbers.currencyFormats.currencySpacing; | ||
var standardRaw = root.Numbers.decimalFormats.standard(bundle); | ||
var standard = internal.getNumberPattern(standardRaw, false); | ||
return { | ||
symbols: root.Numbers.symbols(bundle), | ||
minimumGroupingDigits: Number(root.Numbers.minimumGroupingDigits(bundle)), | ||
primaryGroupingSize: standard.priGroup, | ||
secondaryGroupingSize: standard.secGroup, | ||
beforeCurrency: currencySpacing.beforeCurrency(bundle), | ||
afterCurrency: currencySpacing.afterCurrency(bundle) | ||
}; | ||
}; | ||
/** | ||
* Number and currency formatting. | ||
@@ -32,6 +16,6 @@ */ | ||
this.bundle = bundle; | ||
this.params = exports.getNumberParams(bundle, internal); | ||
this.numberParams = new params_1.NumberParamsCache(bundle, internal); | ||
} | ||
NumbersEngine.prototype.getNumberParams = function () { | ||
return this.params; | ||
NumbersEngine.prototype.getNumberParams = function (numberSystem) { | ||
return this.numberParams.getNumberParams(numberSystem); | ||
}; | ||
@@ -71,18 +55,26 @@ /** | ||
NumbersEngine.prototype.formatDecimal = function (n, options) { | ||
if (options === void 0) { options = {}; } | ||
var d = types_1.coerceDecimal(n); | ||
var _a = this.internal.formatDecimal(this.bundle, render_1.STRING_RENDERER, d, options, this.params), result = _a[0], plural = _a[1]; | ||
var params = this.getNumberParams(options.nu); | ||
var _a = this.internal.formatDecimal(this.bundle, render_1.STRING_RENDERER, d, options, params), result = _a[0], plural = _a[1]; | ||
return result; | ||
}; | ||
NumbersEngine.prototype.formatDecimalParts = function (n, options) { | ||
if (options === void 0) { options = {}; } | ||
var d = types_1.coerceDecimal(n); | ||
var _a = this.internal.formatDecimal(this.bundle, render_1.PARTS_RENDERER, d, options, this.params), result = _a[0], plural = _a[1]; | ||
var params = this.getNumberParams(options.nu); | ||
var _a = this.internal.formatDecimal(this.bundle, render_1.PARTS_RENDERER, d, options, params), result = _a[0], plural = _a[1]; | ||
return result; | ||
}; | ||
NumbersEngine.prototype.formatCurrency = function (n, code, options) { | ||
if (options === void 0) { options = {}; } | ||
var d = types_1.coerceDecimal(n); | ||
return this.internal.formatCurrency(this.bundle, render_1.STRING_RENDERER, d, code, options, this.params); | ||
var params = this.getNumberParams(options.nu); | ||
return this.internal.formatCurrency(this.bundle, render_1.STRING_RENDERER, d, code, options, params); | ||
}; | ||
NumbersEngine.prototype.formatCurrencyParts = function (n, code, options) { | ||
if (options === void 0) { options = {}; } | ||
var d = types_1.coerceDecimal(n); | ||
return this.internal.formatCurrency(this.bundle, render_1.PARTS_RENDERER, d, code, options, this.params); | ||
var params = this.getNumberParams(options.nu); | ||
return this.internal.formatCurrency(this.bundle, render_1.PARTS_RENDERER, d, code, options, params); | ||
}; | ||
@@ -89,0 +81,0 @@ return NumbersEngine; |
export * from './engine'; | ||
export * from './internal'; | ||
export * from './options'; | ||
export * from './params'; |
@@ -9,2 +9,3 @@ "use strict"; | ||
__export(require("./options")); | ||
__export(require("./params")); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { Bundle, CurrencyType, CurrencyInfo, CurrencyFormats, DecimalFormats, DigitsArrow, DivisorArrow, PercentFormats, Plural, Schema, ScopeArrow } from '@phensley/cldr-schema'; | ||
import { Bundle, CurrencyType, CurrencyInfo, DigitsArrow, DivisorArrow, Numbers, Plural, Schema, ScopeArrow } from '@phensley/cldr-schema'; | ||
import { Decimal } from '../../types'; | ||
@@ -16,5 +16,3 @@ import { NumberContext } from './context'; | ||
readonly Currencies: ScopeArrow<CurrencyType, CurrencyInfo>; | ||
readonly currencyFormats: CurrencyFormats; | ||
readonly decimalFormats: DecimalFormats; | ||
readonly percentFormats: PercentFormats; | ||
readonly Numbers: Numbers; | ||
protected readonly numberPatternCache: Cache<NumberPattern[]>; | ||
@@ -21,0 +19,0 @@ constructor(root: Schema, wrapper: WrapperInternal, cacheSize?: number); |
@@ -18,6 +18,7 @@ "use strict"; | ||
this.Currencies = root.Currencies; | ||
this.currencyFormats = root.Numbers.currencyFormats; | ||
this.decimalFormats = root.Numbers.decimalFormats; | ||
this.percentFormats = root.Numbers.percentFormats; | ||
this.Numbers = root.Numbers; | ||
this.numberPatternCache = new cache_1.Cache(number_1.parseNumberPattern, cacheSize); | ||
// this.currencyFormats = root.Numbers.currencyFormats; | ||
// this.decimalFormats = root.Numbers.decimalFormats; | ||
// this.percentFormats = root.Numbers.percentFormats; | ||
} | ||
@@ -28,2 +29,3 @@ NumbersInternal.prototype.formatDecimal = function (bundle, renderer, n, options, params) { | ||
var plural = cldr_schema_1.Plural.OTHER; | ||
var decimalFormats = this.Numbers.numberSystem(params.numberSystemName).decimalFormats; | ||
switch (style) { | ||
@@ -33,9 +35,9 @@ case "long" /* LONG */: | ||
{ | ||
var standardRaw = this.decimalFormats.standard(bundle); | ||
var standardRaw = decimalFormats.standard(bundle); | ||
var isShort = style === "short" /* SHORT */; | ||
var divisorImpl = isShort ? this.decimalFormats.short.decimalFormatDivisor | ||
: this.decimalFormats.long.decimalFormatDivisor; | ||
var patternImpl = isShort ? this.decimalFormats.short.decimalFormat | ||
: this.decimalFormats.long.decimalFormat; | ||
var ctx = new context_1.NumberContext(options); | ||
var divisorImpl = isShort ? decimalFormats.short.decimalFormatDivisor | ||
: decimalFormats.long.decimalFormatDivisor; | ||
var patternImpl = isShort ? decimalFormats.short.decimalFormat | ||
: decimalFormats.long.decimalFormat; | ||
var ctx = new context_1.NumberContext(options, true); | ||
// Adjust the number using the compact pattern and divisor. | ||
@@ -59,3 +61,4 @@ var _a = this.setupCompact(bundle, n, ctx, standardRaw, patternImpl, divisorImpl), q2 = _a[0], ndigits = _a[1]; | ||
// Get percent pattern. | ||
var raw = this.percentFormats.standard(bundle); | ||
var percentFormats = this.Numbers.numberSystem(params.numberSystemName).percentFormats; | ||
var raw = percentFormats.standard(bundle); | ||
var pattern = this.getNumberPattern(raw, n.isNegative()); | ||
@@ -73,3 +76,3 @@ // Scale the number to a percent or permille form as needed. | ||
// Adjust number using pattern and options, then render. | ||
var ctx = new context_1.NumberContext(options, -1); | ||
var ctx = new context_1.NumberContext(options, false, -1); | ||
ctx.setPattern(pattern); | ||
@@ -86,6 +89,6 @@ n = ctx.adjust(n); | ||
// Get decimal pattern. | ||
var raw = this.decimalFormats.standard(bundle); | ||
var raw = decimalFormats.standard(bundle); | ||
var pattern = this.getNumberPattern(raw, n.isNegative()); | ||
// Adjust number using pattern and options, then render. | ||
var ctx = new context_1.NumberContext(options, -1); | ||
var ctx = new context_1.NumberContext(options, false, -1); | ||
ctx.setPattern(pattern); | ||
@@ -110,3 +113,5 @@ n = ctx.adjust(n); | ||
var style = options.style === undefined ? "symbol" /* SYMBOL */ : options.style; | ||
var standardRaw = this.currencyFormats.standard(bundle); | ||
var info = this.Numbers.numberSystem(params.numberSystemName); | ||
var currencyFormats = info.currencyFormats; | ||
var standardRaw = currencyFormats.standard(bundle); | ||
switch (style) { | ||
@@ -116,6 +121,6 @@ case "code" /* CODE */: | ||
{ | ||
var raw = this.decimalFormats.standard(bundle); | ||
var raw = info.decimalFormats.standard(bundle); | ||
var pattern = this.getNumberPattern(raw, n.isNegative()); | ||
// Adjust number using pattern and options, then render. | ||
var ctx = new context_1.NumberContext(options, fractions.digits); | ||
var ctx = new context_1.NumberContext(options, false, fractions.digits); | ||
ctx.setPattern(pattern); | ||
@@ -130,3 +135,3 @@ n = ctx.adjust(n); | ||
// Wrap number and unit together. | ||
var unitWrapper = this.currencyFormats.unitPattern(bundle, plural); | ||
var unitWrapper = currencyFormats.unitPattern(bundle, plural); | ||
return renderer.wrap(this.wrapper, unitWrapper, num, renderer.part('unit', unit)); | ||
@@ -138,5 +143,5 @@ } | ||
// correct pluralized pattern for the final rounded form. | ||
var divisorImpl = this.currencyFormats.short.standardDivisor; | ||
var patternImpl = this.currencyFormats.short.standard; | ||
var ctx = new context_1.NumberContext(options, fractions.digits); | ||
var divisorImpl = currencyFormats.short.standardDivisor; | ||
var patternImpl = currencyFormats.short.standard; | ||
var ctx = new context_1.NumberContext(options, true, fractions.digits); | ||
var symbol = this.Currencies(code).symbol(bundle, width); | ||
@@ -159,6 +164,6 @@ // Adjust the number using the compact pattern and divisor. | ||
var raw = style === "symbol" /* SYMBOL */ ? | ||
this.currencyFormats.standard(bundle) : this.currencyFormats.accounting(bundle); | ||
currencyFormats.standard(bundle) : currencyFormats.accounting(bundle); | ||
var pattern = this.getNumberPattern(raw, n.isNegative()); | ||
// Adjust number using pattern and options, then render. | ||
var ctx = new context_1.NumberContext(options, fractions.digits); | ||
var ctx = new context_1.NumberContext(options, false, fractions.digits); | ||
ctx.setPattern(pattern); | ||
@@ -165,0 +170,0 @@ n = ctx.adjust(n); |
@@ -1,3 +0,5 @@ | ||
import { CurrencySpacing, NumberSymbols } from '@phensley/cldr-schema'; | ||
import { CurrencySpacing, NumberSymbols, NumberSystemName } from '@phensley/cldr-schema'; | ||
export interface NumberParams { | ||
numberSystemName: NumberSystemName; | ||
digits: string[]; | ||
symbols: NumberSymbols; | ||
@@ -10,4 +12,6 @@ minimumGroupingDigits: number; | ||
} | ||
export declare type NumberSystemType = 'default' | 'native' | 'finance' | 'traditional' | NumberSystemName; | ||
export declare type RoundingModeType = 'up' | 'down' | 'ceiling' | 'floor' | 'half-up' | 'half-down' | 'half-even' | '05up' | 'truncate'; | ||
export interface NumberFormatOptions { | ||
nu?: NumberSystemType; | ||
round?: RoundingModeType; | ||
@@ -14,0 +18,0 @@ group?: boolean; |
@@ -11,3 +11,3 @@ "use strict"; | ||
StringRenderer.prototype.render = function (n, pattern, params, currency, percent, group, minInt) { | ||
var formatted = n.format(params.symbols.decimal, group ? params.symbols.group : '', minInt, params.minimumGroupingDigits, pattern.priGroup <= 0 ? params.primaryGroupingSize : pattern.priGroup, pattern.secGroup <= 0 ? params.secondaryGroupingSize : pattern.secGroup); | ||
var formatted = n.format(params.symbols.decimal, group ? params.symbols.group : '', minInt, params.minimumGroupingDigits, pattern.priGroup <= 0 ? params.primaryGroupingSize : pattern.priGroup, pattern.secGroup <= 0 ? params.secondaryGroupingSize : pattern.secGroup, params.digits); | ||
// Track relative position of the currency symbol and formatted number. | ||
@@ -80,3 +80,3 @@ var currencyIdx = -1; | ||
PartsRenderer.prototype.render = function (n, pattern, params, currency, percent, group, minInt) { | ||
var formatted = n.formatParts(params.symbols.decimal, group ? params.symbols.group : '', minInt, params.minimumGroupingDigits, pattern.priGroup <= 0 ? params.primaryGroupingSize : pattern.priGroup, pattern.secGroup <= 0 ? params.secondaryGroupingSize : pattern.secGroup); | ||
var formatted = n.formatParts(params.symbols.decimal, group ? params.symbols.group : '', minInt, params.minimumGroupingDigits, pattern.priGroup <= 0 ? params.primaryGroupingSize : pattern.priGroup, pattern.secGroup <= 0 ? params.secondaryGroupingSize : pattern.secGroup, params.digits); | ||
// Track relative position of the currency symbol and formatted number. | ||
@@ -83,0 +83,0 @@ var currencyIdx = -1; |
@@ -11,3 +11,3 @@ "use strict"; | ||
this.bundle = bundle; | ||
this.numberParams = numbers_1.getNumberParams(bundle, numbers); | ||
this.numberParams = new numbers_1.NumberParamsCache(bundle, numbers); | ||
} | ||
@@ -20,7 +20,9 @@ UnitsEngine.prototype.getDisplayName = function (name, length) { | ||
if (options === void 0) { options = defaultOptions; } | ||
return this.internal.format(this.bundle, render_1.STRING_RENDERER, q, options, this.numberParams); | ||
var params = this.numberParams.getNumberParams(options.nu); | ||
return this.internal.format(this.bundle, render_1.STRING_RENDERER, q, options, params); | ||
}; | ||
UnitsEngine.prototype.formatParts = function (q, options) { | ||
if (options === void 0) { options = defaultOptions; } | ||
return this.internal.format(this.bundle, render_1.PARTS_RENDERER, q, options, this.numberParams); | ||
var params = this.numberParams.getNumberParams(options.nu); | ||
return this.internal.format(this.bundle, render_1.PARTS_RENDERER, q, options, params); | ||
}; | ||
@@ -27,0 +29,0 @@ // TODO: use list pattern formatter to join unit sequences instead of single space |
@@ -1,2 +0,2 @@ | ||
import { Bundle, FieldArrow, Schema, UnitInfo, Units, UnitType } from '@phensley/cldr-schema'; | ||
import { Bundle, FieldArrow, Numbers, Schema, UnitInfo, Units, UnitType } from '@phensley/cldr-schema'; | ||
import { WrapperInternal } from '..'; | ||
@@ -12,2 +12,3 @@ import { NumbersInternal } from '../numbers/internal'; | ||
readonly cacheSize: number; | ||
readonly Numbers: Numbers; | ||
readonly Units: Units; | ||
@@ -14,0 +15,0 @@ readonly standardFormat: FieldArrow; |
@@ -12,3 +12,3 @@ "use strict"; | ||
this.Units = root.Units; | ||
this.standardFormat = root.Numbers.decimalFormats.standard; | ||
this.Numbers = root.Numbers; | ||
} | ||
@@ -15,0 +15,0 @@ UnitsInternal.prototype.getDisplayName = function (bundle, name, length) { |
@@ -5,2 +5,3 @@ import { NumberOperands } from './operands'; | ||
import { MathContext, RoundingModeType } from './types'; | ||
export declare const DECIMAL_DIGITS: string[]; | ||
export declare type DecimalArg = number | string | Decimal; | ||
@@ -125,14 +126,15 @@ export declare const coerceDecimal: (n: DecimalArg) => Decimal; | ||
* secGroup - secondary digit grouping size | ||
* digits - digit symbols to use | ||
* | ||
* TODO: support alternate digit systems, algorithmic / spellout | ||
*/ | ||
format(decimal: string, group: string, minInt: number, minGroup: number, priGroup: number, secGroup: number): string; | ||
format(decimal: string, group: string, minInt: number, minGroup: number, priGroup: number, secGroup: number, digits?: string[]): string; | ||
/** | ||
* Render this number to an array of parts. | ||
*/ | ||
formatParts(decimal: string, group: string, minInt: number, minGroup: number, priGroup: number, secGroup: number): Part[]; | ||
formatParts(decimal: string, group: string, minInt: number, minGroup: number, priGroup: number, secGroup: number, digits?: string[]): Part[]; | ||
/** | ||
* Low-level formatting of string and Part[] forms. | ||
*/ | ||
protected _format(formatter: Formatter<any>, decimal: string, group: string, minInt: number, minGroup: number, priGroup: number, secGroup: number): void; | ||
protected _format(formatter: Formatter<any>, decimal: string, group: string, minInt: number, minGroup: number, priGroup: number, secGroup: number, digits: string[]): void; | ||
protected static fromRaw(sign: number, exp: number, data: number[]): Decimal; | ||
@@ -139,0 +141,0 @@ /** |
@@ -12,2 +12,3 @@ "use strict"; | ||
var DEFAULT_PRECISION = 28; | ||
exports.DECIMAL_DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; | ||
exports.coerceDecimal = function (n) { | ||
@@ -286,3 +287,3 @@ return typeof n === 'number' || typeof n === 'string' ? new Decimal(n) : n; | ||
var len = this.data.length; | ||
return ((len - 1) * 7 /* RDIGITS */) + operations_1.digits(this.data[len - 1]); | ||
return ((len - 1) * 7 /* RDIGITS */) + operations_1.digitCount(this.data[len - 1]); | ||
}; | ||
@@ -465,8 +466,10 @@ /** | ||
* secGroup - secondary digit grouping size | ||
* digits - digit symbols to use | ||
* | ||
* TODO: support alternate digit systems, algorithmic / spellout | ||
*/ | ||
Decimal.prototype.format = function (decimal, group, minInt, minGroup, priGroup, secGroup) { | ||
Decimal.prototype.format = function (decimal, group, minInt, minGroup, priGroup, secGroup, digits) { | ||
if (digits === void 0) { digits = exports.DECIMAL_DIGITS; } | ||
var formatter = new format_1.StringFormatter(); | ||
this._format(formatter, decimal, group, minInt, minGroup, priGroup, secGroup); | ||
this._format(formatter, decimal, group, minInt, minGroup, priGroup, secGroup, digits); | ||
return formatter.render(); | ||
@@ -477,5 +480,6 @@ }; | ||
*/ | ||
Decimal.prototype.formatParts = function (decimal, group, minInt, minGroup, priGroup, secGroup) { | ||
Decimal.prototype.formatParts = function (decimal, group, minInt, minGroup, priGroup, secGroup, digits) { | ||
if (digits === void 0) { digits = exports.DECIMAL_DIGITS; } | ||
var formatter = new format_1.PartsFormatter(decimal, group); | ||
this._format(formatter, decimal, group, minInt, minGroup, priGroup, secGroup); | ||
this._format(formatter, decimal, group, minInt, minGroup, priGroup, secGroup, digits); | ||
return formatter.render(); | ||
@@ -486,3 +490,3 @@ }; | ||
*/ | ||
Decimal.prototype._format = function (formatter, decimal, group, minInt, minGroup, priGroup, secGroup) { | ||
Decimal.prototype._format = function (formatter, decimal, group, minInt, minGroup, priGroup, secGroup, digits) { | ||
// Determine if grouping is enabled, and set the primary and | ||
@@ -526,3 +530,3 @@ // secondary group sizes. | ||
while (zeros > 0) { | ||
formatter.add('0'); | ||
formatter.add(digits[0]); | ||
emitted++; | ||
@@ -540,7 +544,7 @@ int--; | ||
var d = this.data[i]; | ||
var c = i === last ? operations_1.digits(d) : 7 /* RDIGITS */; | ||
var c = i === last ? operations_1.digitCount(d) : 7 /* RDIGITS */; | ||
// Loop over the decimal digits | ||
for (var j = 0; j < c; j++) { | ||
// Push decimal digit | ||
formatter.add(String(d % 10)); | ||
formatter.add(digits[d % 10]); | ||
d = (d / 10) | 0; | ||
@@ -566,3 +570,3 @@ // When we've reached exponent of 0, push the decimal point. | ||
while (exp < 0) { | ||
formatter.add('0'); | ||
formatter.add(digits[0]); | ||
// When we've reached exponent of 0, push the decimal point | ||
@@ -576,3 +580,3 @@ exp++; | ||
while (int > 0) { | ||
formatter.add('0'); | ||
formatter.add(digits[0]); | ||
emitted++; | ||
@@ -579,0 +583,0 @@ int--; |
@@ -19,3 +19,3 @@ "use strict"; | ||
var dec = exp < 0; | ||
var precision = (last * 7 /* RDIGITS */) + operations_1.digits(data[last]); | ||
var precision = (last * 7 /* RDIGITS */) + operations_1.digitCount(data[last]); | ||
// Local operands | ||
@@ -42,3 +42,3 @@ var n = 0; | ||
var r = data[x]; | ||
var c = x !== last ? 7 /* RDIGITS */ : operations_1.digits(r); | ||
var c = x !== last ? 7 /* RDIGITS */ : operations_1.digitCount(r); | ||
y = c - 1; | ||
@@ -45,0 +45,0 @@ // Scan each decimal digit of the radix number from |
@@ -6,2 +6,2 @@ export declare const compare: (a: number[], b: number[], shift: number) => number; | ||
*/ | ||
export declare const digits: (w: number) => number; | ||
export declare const digitCount: (w: number) => number; |
@@ -65,3 +65,3 @@ "use strict"; | ||
*/ | ||
exports.digits = function (w) { | ||
exports.digitCount = function (w) { | ||
if (w < 10000 /* P4 */) { | ||
@@ -68,0 +68,0 @@ if (w < 100 /* P2 */) { |
{ | ||
"name": "@phensley/cldr-core", | ||
"version": "0.2.10", | ||
"version": "0.2.11", | ||
"description": "Core library for @phensley/cldr", | ||
@@ -30,3 +30,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@phensley/cldr-schema": "^0.2.10" | ||
"@phensley/cldr-schema": "^0.2.11" | ||
}, | ||
@@ -33,0 +33,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
749330
242
8832