@phensley/cldr-core
Version:
Core library for @phensley/cldr
71 lines • 3.41 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var internals_1 = require("../../internals");
var types_1 = require("../../types");
/**
* Number and currency formatting.
*/
var NumbersImpl = /** @class */ (function () {
function NumbersImpl(bundle, internal, privateApi) {
this.bundle = bundle;
this.internal = internal;
this.privateApi = privateApi;
this.numbers = internal.numbers;
this.plurals = internal.plurals;
}
NumbersImpl.prototype.getCurrencySymbol = function (code, width) {
return this.numbers.getCurrencySymbol(this.bundle, code, width);
};
NumbersImpl.prototype.getCurrencyDisplayName = function (code) {
return this.numbers.getCurrencyDisplayName(this.bundle, code);
};
NumbersImpl.prototype.getCurrencyFractions = function (code) {
return internals_1.getCurrencyFractions(code);
};
NumbersImpl.prototype.getCurrencyPluralName = function (code, plural) {
var name = this.numbers.getCurrencyPluralName(this.bundle, code, plural);
return name !== '' ? name : this.numbers.getCurrencyPluralName(this.bundle, code, 'other');
};
NumbersImpl.prototype.getPluralCardinal = function (n) {
var d = types_1.coerceDecimal(n);
return this.plurals.cardinal(this.bundle.language(), d.operands());
};
NumbersImpl.prototype.getPluralOrdinal = function (n) {
var d = types_1.coerceDecimal(n);
return this.plurals.ordinal(this.bundle.language(), d.operands());
};
NumbersImpl.prototype.formatDecimal = function (n, options) {
options = options || {};
var params = this.privateApi.getNumberParams(options.nu);
var renderer = this.numbers.stringRenderer(params);
return this.formatDecimalImpl(renderer, params, n, options);
};
NumbersImpl.prototype.formatDecimalToParts = function (n, options) {
options = options || {};
var params = this.privateApi.getNumberParams(options.nu);
var renderer = this.numbers.partsRenderer(params);
return this.formatDecimalImpl(renderer, params, n, options);
};
NumbersImpl.prototype.formatCurrency = function (n, code, options) {
options = options || {};
var params = this.privateApi.getNumberParams(options.nu, 'finance');
var renderer = this.numbers.stringRenderer(params);
return this.formatCurrencyImpl(renderer, params, n, code, options);
};
NumbersImpl.prototype.formatCurrencyToParts = function (n, code, options) {
options = options || {};
var params = this.privateApi.getNumberParams(options.nu, 'finance');
var renderer = this.numbers.partsRenderer(params);
return this.formatCurrencyImpl(renderer, params, n, code, options || {});
};
NumbersImpl.prototype.formatDecimalImpl = function (renderer, params, n, options) {
var _a = this.numbers.formatDecimal(this.bundle, renderer, types_1.coerceDecimal(n), options, params), result = _a[0], plural = _a[1];
return result;
};
NumbersImpl.prototype.formatCurrencyImpl = function (renderer, params, n, code, options) {
return this.numbers.formatCurrency(this.bundle, renderer, types_1.coerceDecimal(n), code, options, params);
};
return NumbersImpl;
}());
exports.NumbersImpl = NumbersImpl;
//# sourceMappingURL=api.js.map