Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@phensley/cldr-ext-rbnf

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@phensley/cldr-ext-rbnf - npm Package Compare versions

Comparing version 1.6.1 to 1.6.2

90

lib-es/debug.js

@@ -135,20 +135,20 @@ /* istanbul ignore file */

switch (rule[0]) {
case 2 /* IMPROPER_FRACTION */:
case 1 /* PROPER_FRACTION */:
case 2 /* RuleType.IMPROPER_FRACTION */:
case 1 /* RuleType.PROPER_FRACTION */:
var sym = rule[2] === 1 ? ',' : '.';
res += "\"".concat(rule[0] === 2 /* IMPROPER_FRACTION */ ? 'x' : '0').concat(sym, "x\"");
res += "\"".concat(rule[0] === 2 /* RuleType.IMPROPER_FRACTION */ ? 'x' : '0').concat(sym, "x\"");
break;
case 0 /* MINUS */:
case 0 /* RuleType.MINUS */:
res += '"-x"';
break;
case 5 /* INFINITY */:
case 5 /* RuleType.INFINITY */:
res += "\"Inf\"";
break;
case 6 /* NOT_A_NUMBER */:
case 6 /* RuleType.NOT_A_NUMBER */:
res += 'NaN';
break;
case 3 /* NORMAL */:
case 3 /* RuleType.NORMAL */:
res += "\"".concat(rbnf.numbers[rule[2]], "\"");
break;
case 4 /* NORMAL_RADIX */:
case 4 /* RuleType.NORMAL_RADIX */:
res += "\"".concat(rbnf.numbers[rule[2]], "/").concat(rbnf.numbers[rule[3]], "\"");

@@ -164,29 +164,29 @@ break;

switch (i[0]) {
case 13 /* APPLY_LEFT_NUM_FORMAT */:
case 13 /* Opcode.APPLY_LEFT_NUM_FORMAT */:
return "<".concat(rbnf.symbols[i[1]], "<");
case 7 /* APPLY_LEFT_RULE */:
case 7 /* Opcode.APPLY_LEFT_RULE */:
return "<%".concat(rbnf.allnames[i[1]], "%<");
case 14 /* APPLY_LEFT_2_NUM_FORMAT */:
case 14 /* Opcode.APPLY_LEFT_2_NUM_FORMAT */:
return "<".concat(rbnf.symbols[i[1]], "<<");
case 11 /* APPLY_LEFT_2_RULE */:
case 11 /* Opcode.APPLY_LEFT_2_RULE */:
return "<%".concat(rbnf.allnames[i[1]], "%<<");
case 3 /* APPLY_RIGHT_RULE */:
case 3 /* Opcode.APPLY_RIGHT_RULE */:
return ">%".concat(rbnf.allnames[i[1]], "%>");
case 2 /* OPTIONAL */:
case 2 /* Opcode.OPTIONAL */:
return '[' + i[1].map(function (_i) { return instrepr(rbnf, _i); }).join('') + ']';
case 0 /* LITERAL */:
case 0 /* Opcode.LITERAL */:
return rbnf.symbols[i[1]];
case 4 /* SUB_LEFT */:
case 4 /* Opcode.SUB_LEFT */:
return '<<';
case 1 /* SUB_RIGHT */:
case 1 /* Opcode.SUB_RIGHT */:
return '>>';
case 9 /* SUB_RIGHT_3 */:
case 9 /* Opcode.SUB_RIGHT_3 */:
return '>>>';
case 6 /* UNCHANGED_NUM_FORMAT */:
case 6 /* Opcode.UNCHANGED_NUM_FORMAT */:
return "=".concat(rbnf.symbols[i[1]], "=");
case 5 /* UNCHANGED_RULE */:
case 5 /* Opcode.UNCHANGED_RULE */:
return "=%".concat(rbnf.allnames[i[1]], "%=");
case 8 /* CARDINAL */:
case 10 /* ORDINAL */:
var r = i[0] === 8 /* CARDINAL */ ? 'cardinal' : 'ordinal';
case 8 /* Opcode.CARDINAL */:
case 10 /* Opcode.ORDINAL */:
var r = i[0] === 8 /* Opcode.CARDINAL */ ? 'cardinal' : 'ordinal';
var subs = i[1].map(function (s) { return "".concat(REVPLURALS[s[0]], "{").concat(rbnf.symbols[s[1]], "}"); }).join('');

@@ -199,27 +199,27 @@ return "$(".concat(r, ",").concat(subs, ")$");

export var OPCODES = (_a = {},
_a[14 /* APPLY_LEFT_2_NUM_FORMAT */] = 'APPLY_LEFT_2_NUM_FORMAT',
_a[11 /* APPLY_LEFT_2_RULE */] = 'APPLY_LEFT_2_RULE',
_a[13 /* APPLY_LEFT_NUM_FORMAT */] = 'APPLY_LEFT_NUM_FORMAT',
_a[7 /* APPLY_LEFT_RULE */] = 'APPLY_LEFT_RULE',
_a[12 /* APPLY_RIGHT_NUM_FORMAT */] = 'APPLY_RIGHT_NUM_FORMAT',
_a[3 /* APPLY_RIGHT_RULE */] = 'APPLY_RIGHT_RULE',
_a[8 /* CARDINAL */] = 'CARDINAL',
_a[0 /* LITERAL */] = 'LITERAL',
_a[2 /* OPTIONAL */] = 'OPTIONAL',
_a[10 /* ORDINAL */] = 'ORDINAL',
_a[4 /* SUB_LEFT */] = 'SUB_LEFT',
_a[1 /* SUB_RIGHT */] = 'SUB_RIGHT',
_a[9 /* SUB_RIGHT_3 */] = 'SUB_RIGHT_3',
_a[6 /* UNCHANGED_NUM_FORMAT */] = 'UNCHANGED_NUM_FORMAT',
_a[5 /* UNCHANGED_RULE */] = 'UNCHANGED_RULE',
_a[14 /* Opcode.APPLY_LEFT_2_NUM_FORMAT */] = 'APPLY_LEFT_2_NUM_FORMAT',
_a[11 /* Opcode.APPLY_LEFT_2_RULE */] = 'APPLY_LEFT_2_RULE',
_a[13 /* Opcode.APPLY_LEFT_NUM_FORMAT */] = 'APPLY_LEFT_NUM_FORMAT',
_a[7 /* Opcode.APPLY_LEFT_RULE */] = 'APPLY_LEFT_RULE',
_a[12 /* Opcode.APPLY_RIGHT_NUM_FORMAT */] = 'APPLY_RIGHT_NUM_FORMAT',
_a[3 /* Opcode.APPLY_RIGHT_RULE */] = 'APPLY_RIGHT_RULE',
_a[8 /* Opcode.CARDINAL */] = 'CARDINAL',
_a[0 /* Opcode.LITERAL */] = 'LITERAL',
_a[2 /* Opcode.OPTIONAL */] = 'OPTIONAL',
_a[10 /* Opcode.ORDINAL */] = 'ORDINAL',
_a[4 /* Opcode.SUB_LEFT */] = 'SUB_LEFT',
_a[1 /* Opcode.SUB_RIGHT */] = 'SUB_RIGHT',
_a[9 /* Opcode.SUB_RIGHT_3 */] = 'SUB_RIGHT_3',
_a[6 /* Opcode.UNCHANGED_NUM_FORMAT */] = 'UNCHANGED_NUM_FORMAT',
_a[5 /* Opcode.UNCHANGED_RULE */] = 'UNCHANGED_RULE',
_a);
export var RULETYPES = (_b = {},
_b[2 /* IMPROPER_FRACTION */] = 'IMPROPER_FRACTION',
_b[5 /* INFINITY */] = 'INFINITY',
_b[0 /* MINUS */] = 'MINUS',
_b[3 /* NORMAL */] = 'NORMAL',
_b[4 /* NORMAL_RADIX */] = 'NORMAL_RADIX',
_b[6 /* NOT_A_NUMBER */] = 'NOT_A_NUMBER',
_b[1 /* PROPER_FRACTION */] = 'PROPER_FRACTION',
_b[2 /* RuleType.IMPROPER_FRACTION */] = 'IMPROPER_FRACTION',
_b[5 /* RuleType.INFINITY */] = 'INFINITY',
_b[0 /* RuleType.MINUS */] = 'MINUS',
_b[3 /* RuleType.NORMAL */] = 'NORMAL',
_b[4 /* RuleType.NORMAL_RADIX */] = 'NORMAL_RADIX',
_b[6 /* RuleType.NOT_A_NUMBER */] = 'NOT_A_NUMBER',
_b[1 /* RuleType.PROPER_FRACTION */] = 'PROPER_FRACTION',
_b);
//# sourceMappingURL=debug.js.map

@@ -138,3 +138,3 @@ import { Decimal, DecimalConstants } from '@phensley/decimal';

switch (r[0]) {
case 6 /* NOT_A_NUMBER */:
case 6 /* RuleType.NOT_A_NUMBER */:
if (n.isNaN()) {

@@ -144,3 +144,3 @@ return { value: i };

break;
case 5 /* INFINITY */:
case 5 /* RuleType.INFINITY */:
if (n.isInfinity()) {

@@ -150,3 +150,3 @@ return { value: i };

break;
case 0 /* MINUS */:
case 0 /* RuleType.MINUS */:
if (neg) {

@@ -156,3 +156,3 @@ return { value: i };

break;
case 1 /* PROPER_FRACTION */:
case 1 /* RuleType.PROPER_FRACTION */:
if (!int &&

@@ -165,3 +165,3 @@ fin &&

break;
case 2 /* IMPROPER_FRACTION */:
case 2 /* RuleType.IMPROPER_FRACTION */:
// If present it always follows a proper fraction rule, catching anything that falls through

@@ -172,4 +172,4 @@ if (!int && fin && r[2] === this_1.decimal) {

break;
case 3 /* NORMAL */:
case 4 /* NORMAL_RADIX */:
case 3 /* RuleType.NORMAL */:
case 4 /* RuleType.NORMAL_RADIX */:
if (fin) {

@@ -200,6 +200,6 @@ var m_1 = n.abs();

switch (inst[0]) {
case 0 /* LITERAL */:
case 0 /* Opcode.LITERAL */:
this_2.symbol(inst[1]);
break;
case 2 /* OPTIONAL */:
case 2 /* Opcode.OPTIONAL */:
// If number is not a multiple of radix, execute the optional block

@@ -210,6 +210,6 @@ if (ZERO.compare(n.divmod(this_2.getradix(r))[1]) !== 0) {

break;
case 8 /* CARDINAL */:
case 10 /* ORDINAL */:
case 8 /* Opcode.CARDINAL */:
case 10 /* Opcode.ORDINAL */:
var q = n.divmod(this_2.getradix(r))[0];
var cat_1 = this_2.plural(q.stripTrailingZeros(), inst[0] === 8 /* CARDINAL */);
var cat_1 = this_2.plural(q.stripTrailingZeros(), inst[0] === 8 /* Opcode.CARDINAL */);
// Select string matching plural category, and fall back to 'other'

@@ -224,12 +224,12 @@ var subs = inst[1].filter(function (s) { return s[0] === cat_1; });

break;
case 4 /* SUB_LEFT */:
case 7 /* APPLY_LEFT_RULE */:
case 11 /* APPLY_LEFT_2_RULE */:
case 13 /* APPLY_LEFT_NUM_FORMAT */:
case 14 /* APPLY_LEFT_2_NUM_FORMAT */:
if (r[0] === 1 /* PROPER_FRACTION */ || r[0] === 2 /* IMPROPER_FRACTION */) {
case 4 /* Opcode.SUB_LEFT */:
case 7 /* Opcode.APPLY_LEFT_RULE */:
case 11 /* Opcode.APPLY_LEFT_2_RULE */:
case 13 /* Opcode.APPLY_LEFT_NUM_FORMAT */:
case 14 /* Opcode.APPLY_LEFT_2_NUM_FORMAT */:
if (r[0] === 1 /* RuleType.PROPER_FRACTION */ || r[0] === 2 /* RuleType.IMPROPER_FRACTION */) {
this_2.integersub(n, inst, ri, si);
}
else if (this_2.fractions.has(si)) {
var base = r[0] === 3 /* NORMAL */ || r[0] === 4 /* NORMAL_RADIX */ ? r[2] : -1;
var base = r[0] === 3 /* RuleType.NORMAL */ || r[0] === 4 /* RuleType.NORMAL_RADIX */ ? r[2] : -1;
if (base !== -1) {

@@ -243,15 +243,15 @@ this_2.numeratorsub(n, inst, base, ri, si);

break;
case 5 /* UNCHANGED_RULE */:
case 5 /* Opcode.UNCHANGED_RULE */:
this_2._format(n, inst[1]);
break;
case 6 /* UNCHANGED_NUM_FORMAT */:
case 6 /* Opcode.UNCHANGED_NUM_FORMAT */:
this_2.buf += this_2.fallback(this_2.rbnf.symbols[inst[1]], n);
break;
case 1 /* SUB_RIGHT */:
case 9 /* SUB_RIGHT_3 */:
case 3 /* APPLY_RIGHT_RULE */:
if (r[0] === 0 /* MINUS */) {
this_2._format(n.abs(), inst[0] === 3 /* APPLY_RIGHT_RULE */ ? inst[1] : si);
case 1 /* Opcode.SUB_RIGHT */:
case 9 /* Opcode.SUB_RIGHT_3 */:
case 3 /* Opcode.APPLY_RIGHT_RULE */:
if (r[0] === 0 /* RuleType.MINUS */) {
this_2._format(n.abs(), inst[0] === 3 /* Opcode.APPLY_RIGHT_RULE */ ? inst[1] : si);
}
else if (r[0] === 1 /* PROPER_FRACTION */ || r[0] === 2 /* IMPROPER_FRACTION */) {
else if (r[0] === 1 /* RuleType.PROPER_FRACTION */ || r[0] === 2 /* RuleType.IMPROPER_FRACTION */) {
var m = n.abs();

@@ -279,5 +279,5 @@ this_2.fractionsub(m.subtract(m.toInteger()), inst, ri, si);

RBNFEngine.prototype.fractionsub = function (n, inst, ri, si) {
var _si = inst[0] === 3 /* APPLY_RIGHT_RULE */ ? inst[1] : si;
var digits = inst[0] === 1 /* SUB_RIGHT */ || inst[0] === 9 /* SUB_RIGHT_3 */ || _si === si;
var spaces = inst[0] !== 9 /* SUB_RIGHT_3 */;
var _si = inst[0] === 3 /* Opcode.APPLY_RIGHT_RULE */ ? inst[1] : si;
var digits = inst[0] === 1 /* Opcode.SUB_RIGHT */ || inst[0] === 9 /* Opcode.SUB_RIGHT_3 */ || _si === si;
var spaces = inst[0] !== 9 /* Opcode.SUB_RIGHT_3 */;
if (digits) {

@@ -308,9 +308,9 @@ this.bydigit(n, ri, si, spaces);

switch (inst[0]) {
case 7 /* APPLY_LEFT_RULE */:
case 11 /* APPLY_LEFT_2_RULE */:
case 4 /* SUB_LEFT */:
this._format(n, inst[0] === 4 /* SUB_LEFT */ ? si : inst[1]);
case 7 /* Opcode.APPLY_LEFT_RULE */:
case 11 /* Opcode.APPLY_LEFT_2_RULE */:
case 4 /* Opcode.SUB_LEFT */:
this._format(n, inst[0] === 4 /* Opcode.SUB_LEFT */ ? si : inst[1]);
break;
case 13 /* APPLY_LEFT_NUM_FORMAT */:
case 14 /* APPLY_LEFT_2_NUM_FORMAT */:
case 13 /* Opcode.APPLY_LEFT_NUM_FORMAT */:
case 14 /* Opcode.APPLY_LEFT_2_NUM_FORMAT */:
// TODO: implement number format

@@ -323,3 +323,3 @@ this.buf += '#';

switch (inst[0]) {
case 11 /* APPLY_LEFT_2_RULE */:
case 11 /* Opcode.APPLY_LEFT_2_RULE */:
this._format(n, inst[1]);

@@ -332,5 +332,5 @@ break;

switch (inst[0]) {
case 7 /* APPLY_LEFT_RULE */:
case 4 /* SUB_LEFT */:
this._format(q, inst[0] === 4 /* SUB_LEFT */ ? si : inst[1]);
case 7 /* Opcode.APPLY_LEFT_RULE */:
case 4 /* Opcode.SUB_LEFT */:
this._format(q, inst[0] === 4 /* Opcode.SUB_LEFT */ ? si : inst[1]);
break;

@@ -346,5 +346,5 @@ default:

switch (inst[0]) {
case 3 /* APPLY_RIGHT_RULE */:
case 1 /* SUB_RIGHT */:
this._format(r, inst[0] === 1 /* SUB_RIGHT */ ? si : inst[1]);
case 3 /* Opcode.APPLY_RIGHT_RULE */:
case 1 /* Opcode.SUB_RIGHT */:
this._format(r, inst[0] === 1 /* Opcode.SUB_RIGHT */ ? si : inst[1]);
break;

@@ -375,5 +375,5 @@ }

var n = this.rbnf.numbers;
return r[0] === 4 /* NORMAL_RADIX */
return r[0] === 4 /* RuleType.NORMAL_RADIX */
? n[r[3]]
: r[0] === 3 /* NORMAL */
: r[0] === 3 /* RuleType.NORMAL */
? DIVISORS[n[r[2]].integerDigits()]

@@ -380,0 +380,0 @@ : TEN;

@@ -140,20 +140,20 @@ "use strict";

switch (rule[0]) {
case 2 /* IMPROPER_FRACTION */:
case 1 /* PROPER_FRACTION */:
case 2 /* RuleType.IMPROPER_FRACTION */:
case 1 /* RuleType.PROPER_FRACTION */:
var sym = rule[2] === 1 ? ',' : '.';
res += "\"".concat(rule[0] === 2 /* IMPROPER_FRACTION */ ? 'x' : '0').concat(sym, "x\"");
res += "\"".concat(rule[0] === 2 /* RuleType.IMPROPER_FRACTION */ ? 'x' : '0').concat(sym, "x\"");
break;
case 0 /* MINUS */:
case 0 /* RuleType.MINUS */:
res += '"-x"';
break;
case 5 /* INFINITY */:
case 5 /* RuleType.INFINITY */:
res += "\"Inf\"";
break;
case 6 /* NOT_A_NUMBER */:
case 6 /* RuleType.NOT_A_NUMBER */:
res += 'NaN';
break;
case 3 /* NORMAL */:
case 3 /* RuleType.NORMAL */:
res += "\"".concat(rbnf.numbers[rule[2]], "\"");
break;
case 4 /* NORMAL_RADIX */:
case 4 /* RuleType.NORMAL_RADIX */:
res += "\"".concat(rbnf.numbers[rule[2]], "/").concat(rbnf.numbers[rule[3]], "\"");

@@ -169,29 +169,29 @@ break;

switch (i[0]) {
case 13 /* APPLY_LEFT_NUM_FORMAT */:
case 13 /* Opcode.APPLY_LEFT_NUM_FORMAT */:
return "<".concat(rbnf.symbols[i[1]], "<");
case 7 /* APPLY_LEFT_RULE */:
case 7 /* Opcode.APPLY_LEFT_RULE */:
return "<%".concat(rbnf.allnames[i[1]], "%<");
case 14 /* APPLY_LEFT_2_NUM_FORMAT */:
case 14 /* Opcode.APPLY_LEFT_2_NUM_FORMAT */:
return "<".concat(rbnf.symbols[i[1]], "<<");
case 11 /* APPLY_LEFT_2_RULE */:
case 11 /* Opcode.APPLY_LEFT_2_RULE */:
return "<%".concat(rbnf.allnames[i[1]], "%<<");
case 3 /* APPLY_RIGHT_RULE */:
case 3 /* Opcode.APPLY_RIGHT_RULE */:
return ">%".concat(rbnf.allnames[i[1]], "%>");
case 2 /* OPTIONAL */:
case 2 /* Opcode.OPTIONAL */:
return '[' + i[1].map(function (_i) { return instrepr(rbnf, _i); }).join('') + ']';
case 0 /* LITERAL */:
case 0 /* Opcode.LITERAL */:
return rbnf.symbols[i[1]];
case 4 /* SUB_LEFT */:
case 4 /* Opcode.SUB_LEFT */:
return '<<';
case 1 /* SUB_RIGHT */:
case 1 /* Opcode.SUB_RIGHT */:
return '>>';
case 9 /* SUB_RIGHT_3 */:
case 9 /* Opcode.SUB_RIGHT_3 */:
return '>>>';
case 6 /* UNCHANGED_NUM_FORMAT */:
case 6 /* Opcode.UNCHANGED_NUM_FORMAT */:
return "=".concat(rbnf.symbols[i[1]], "=");
case 5 /* UNCHANGED_RULE */:
case 5 /* Opcode.UNCHANGED_RULE */:
return "=%".concat(rbnf.allnames[i[1]], "%=");
case 8 /* CARDINAL */:
case 10 /* ORDINAL */:
var r = i[0] === 8 /* CARDINAL */ ? 'cardinal' : 'ordinal';
case 8 /* Opcode.CARDINAL */:
case 10 /* Opcode.ORDINAL */:
var r = i[0] === 8 /* Opcode.CARDINAL */ ? 'cardinal' : 'ordinal';
var subs = i[1].map(function (s) { return "".concat(REVPLURALS[s[0]], "{").concat(rbnf.symbols[s[1]], "}"); }).join('');

@@ -204,27 +204,27 @@ return "$(".concat(r, ",").concat(subs, ")$");

exports.OPCODES = (_a = {},
_a[14 /* APPLY_LEFT_2_NUM_FORMAT */] = 'APPLY_LEFT_2_NUM_FORMAT',
_a[11 /* APPLY_LEFT_2_RULE */] = 'APPLY_LEFT_2_RULE',
_a[13 /* APPLY_LEFT_NUM_FORMAT */] = 'APPLY_LEFT_NUM_FORMAT',
_a[7 /* APPLY_LEFT_RULE */] = 'APPLY_LEFT_RULE',
_a[12 /* APPLY_RIGHT_NUM_FORMAT */] = 'APPLY_RIGHT_NUM_FORMAT',
_a[3 /* APPLY_RIGHT_RULE */] = 'APPLY_RIGHT_RULE',
_a[8 /* CARDINAL */] = 'CARDINAL',
_a[0 /* LITERAL */] = 'LITERAL',
_a[2 /* OPTIONAL */] = 'OPTIONAL',
_a[10 /* ORDINAL */] = 'ORDINAL',
_a[4 /* SUB_LEFT */] = 'SUB_LEFT',
_a[1 /* SUB_RIGHT */] = 'SUB_RIGHT',
_a[9 /* SUB_RIGHT_3 */] = 'SUB_RIGHT_3',
_a[6 /* UNCHANGED_NUM_FORMAT */] = 'UNCHANGED_NUM_FORMAT',
_a[5 /* UNCHANGED_RULE */] = 'UNCHANGED_RULE',
_a[14 /* Opcode.APPLY_LEFT_2_NUM_FORMAT */] = 'APPLY_LEFT_2_NUM_FORMAT',
_a[11 /* Opcode.APPLY_LEFT_2_RULE */] = 'APPLY_LEFT_2_RULE',
_a[13 /* Opcode.APPLY_LEFT_NUM_FORMAT */] = 'APPLY_LEFT_NUM_FORMAT',
_a[7 /* Opcode.APPLY_LEFT_RULE */] = 'APPLY_LEFT_RULE',
_a[12 /* Opcode.APPLY_RIGHT_NUM_FORMAT */] = 'APPLY_RIGHT_NUM_FORMAT',
_a[3 /* Opcode.APPLY_RIGHT_RULE */] = 'APPLY_RIGHT_RULE',
_a[8 /* Opcode.CARDINAL */] = 'CARDINAL',
_a[0 /* Opcode.LITERAL */] = 'LITERAL',
_a[2 /* Opcode.OPTIONAL */] = 'OPTIONAL',
_a[10 /* Opcode.ORDINAL */] = 'ORDINAL',
_a[4 /* Opcode.SUB_LEFT */] = 'SUB_LEFT',
_a[1 /* Opcode.SUB_RIGHT */] = 'SUB_RIGHT',
_a[9 /* Opcode.SUB_RIGHT_3 */] = 'SUB_RIGHT_3',
_a[6 /* Opcode.UNCHANGED_NUM_FORMAT */] = 'UNCHANGED_NUM_FORMAT',
_a[5 /* Opcode.UNCHANGED_RULE */] = 'UNCHANGED_RULE',
_a);
exports.RULETYPES = (_b = {},
_b[2 /* IMPROPER_FRACTION */] = 'IMPROPER_FRACTION',
_b[5 /* INFINITY */] = 'INFINITY',
_b[0 /* MINUS */] = 'MINUS',
_b[3 /* NORMAL */] = 'NORMAL',
_b[4 /* NORMAL_RADIX */] = 'NORMAL_RADIX',
_b[6 /* NOT_A_NUMBER */] = 'NOT_A_NUMBER',
_b[1 /* PROPER_FRACTION */] = 'PROPER_FRACTION',
_b[2 /* RuleType.IMPROPER_FRACTION */] = 'IMPROPER_FRACTION',
_b[5 /* RuleType.INFINITY */] = 'INFINITY',
_b[0 /* RuleType.MINUS */] = 'MINUS',
_b[3 /* RuleType.NORMAL */] = 'NORMAL',
_b[4 /* RuleType.NORMAL_RADIX */] = 'NORMAL_RADIX',
_b[6 /* RuleType.NOT_A_NUMBER */] = 'NOT_A_NUMBER',
_b[1 /* RuleType.PROPER_FRACTION */] = 'PROPER_FRACTION',
_b);
//# sourceMappingURL=debug.js.map

@@ -141,3 +141,3 @@ "use strict";

switch (r[0]) {
case 6 /* NOT_A_NUMBER */:
case 6 /* RuleType.NOT_A_NUMBER */:
if (n.isNaN()) {

@@ -147,3 +147,3 @@ return { value: i };

break;
case 5 /* INFINITY */:
case 5 /* RuleType.INFINITY */:
if (n.isInfinity()) {

@@ -153,3 +153,3 @@ return { value: i };

break;
case 0 /* MINUS */:
case 0 /* RuleType.MINUS */:
if (neg) {

@@ -159,3 +159,3 @@ return { value: i };

break;
case 1 /* PROPER_FRACTION */:
case 1 /* RuleType.PROPER_FRACTION */:
if (!int &&

@@ -168,3 +168,3 @@ fin &&

break;
case 2 /* IMPROPER_FRACTION */:
case 2 /* RuleType.IMPROPER_FRACTION */:
// If present it always follows a proper fraction rule, catching anything that falls through

@@ -175,4 +175,4 @@ if (!int && fin && r[2] === this_1.decimal) {

break;
case 3 /* NORMAL */:
case 4 /* NORMAL_RADIX */:
case 3 /* RuleType.NORMAL */:
case 4 /* RuleType.NORMAL_RADIX */:
if (fin) {

@@ -203,6 +203,6 @@ var m_1 = n.abs();

switch (inst[0]) {
case 0 /* LITERAL */:
case 0 /* Opcode.LITERAL */:
this_2.symbol(inst[1]);
break;
case 2 /* OPTIONAL */:
case 2 /* Opcode.OPTIONAL */:
// If number is not a multiple of radix, execute the optional block

@@ -213,6 +213,6 @@ if (ZERO.compare(n.divmod(this_2.getradix(r))[1]) !== 0) {

break;
case 8 /* CARDINAL */:
case 10 /* ORDINAL */:
case 8 /* Opcode.CARDINAL */:
case 10 /* Opcode.ORDINAL */:
var q = n.divmod(this_2.getradix(r))[0];
var cat_1 = this_2.plural(q.stripTrailingZeros(), inst[0] === 8 /* CARDINAL */);
var cat_1 = this_2.plural(q.stripTrailingZeros(), inst[0] === 8 /* Opcode.CARDINAL */);
// Select string matching plural category, and fall back to 'other'

@@ -227,12 +227,12 @@ var subs = inst[1].filter(function (s) { return s[0] === cat_1; });

break;
case 4 /* SUB_LEFT */:
case 7 /* APPLY_LEFT_RULE */:
case 11 /* APPLY_LEFT_2_RULE */:
case 13 /* APPLY_LEFT_NUM_FORMAT */:
case 14 /* APPLY_LEFT_2_NUM_FORMAT */:
if (r[0] === 1 /* PROPER_FRACTION */ || r[0] === 2 /* IMPROPER_FRACTION */) {
case 4 /* Opcode.SUB_LEFT */:
case 7 /* Opcode.APPLY_LEFT_RULE */:
case 11 /* Opcode.APPLY_LEFT_2_RULE */:
case 13 /* Opcode.APPLY_LEFT_NUM_FORMAT */:
case 14 /* Opcode.APPLY_LEFT_2_NUM_FORMAT */:
if (r[0] === 1 /* RuleType.PROPER_FRACTION */ || r[0] === 2 /* RuleType.IMPROPER_FRACTION */) {
this_2.integersub(n, inst, ri, si);
}
else if (this_2.fractions.has(si)) {
var base = r[0] === 3 /* NORMAL */ || r[0] === 4 /* NORMAL_RADIX */ ? r[2] : -1;
var base = r[0] === 3 /* RuleType.NORMAL */ || r[0] === 4 /* RuleType.NORMAL_RADIX */ ? r[2] : -1;
if (base !== -1) {

@@ -246,15 +246,15 @@ this_2.numeratorsub(n, inst, base, ri, si);

break;
case 5 /* UNCHANGED_RULE */:
case 5 /* Opcode.UNCHANGED_RULE */:
this_2._format(n, inst[1]);
break;
case 6 /* UNCHANGED_NUM_FORMAT */:
case 6 /* Opcode.UNCHANGED_NUM_FORMAT */:
this_2.buf += this_2.fallback(this_2.rbnf.symbols[inst[1]], n);
break;
case 1 /* SUB_RIGHT */:
case 9 /* SUB_RIGHT_3 */:
case 3 /* APPLY_RIGHT_RULE */:
if (r[0] === 0 /* MINUS */) {
this_2._format(n.abs(), inst[0] === 3 /* APPLY_RIGHT_RULE */ ? inst[1] : si);
case 1 /* Opcode.SUB_RIGHT */:
case 9 /* Opcode.SUB_RIGHT_3 */:
case 3 /* Opcode.APPLY_RIGHT_RULE */:
if (r[0] === 0 /* RuleType.MINUS */) {
this_2._format(n.abs(), inst[0] === 3 /* Opcode.APPLY_RIGHT_RULE */ ? inst[1] : si);
}
else if (r[0] === 1 /* PROPER_FRACTION */ || r[0] === 2 /* IMPROPER_FRACTION */) {
else if (r[0] === 1 /* RuleType.PROPER_FRACTION */ || r[0] === 2 /* RuleType.IMPROPER_FRACTION */) {
var m = n.abs();

@@ -282,5 +282,5 @@ this_2.fractionsub(m.subtract(m.toInteger()), inst, ri, si);

RBNFEngine.prototype.fractionsub = function (n, inst, ri, si) {
var _si = inst[0] === 3 /* APPLY_RIGHT_RULE */ ? inst[1] : si;
var digits = inst[0] === 1 /* SUB_RIGHT */ || inst[0] === 9 /* SUB_RIGHT_3 */ || _si === si;
var spaces = inst[0] !== 9 /* SUB_RIGHT_3 */;
var _si = inst[0] === 3 /* Opcode.APPLY_RIGHT_RULE */ ? inst[1] : si;
var digits = inst[0] === 1 /* Opcode.SUB_RIGHT */ || inst[0] === 9 /* Opcode.SUB_RIGHT_3 */ || _si === si;
var spaces = inst[0] !== 9 /* Opcode.SUB_RIGHT_3 */;
if (digits) {

@@ -311,9 +311,9 @@ this.bydigit(n, ri, si, spaces);

switch (inst[0]) {
case 7 /* APPLY_LEFT_RULE */:
case 11 /* APPLY_LEFT_2_RULE */:
case 4 /* SUB_LEFT */:
this._format(n, inst[0] === 4 /* SUB_LEFT */ ? si : inst[1]);
case 7 /* Opcode.APPLY_LEFT_RULE */:
case 11 /* Opcode.APPLY_LEFT_2_RULE */:
case 4 /* Opcode.SUB_LEFT */:
this._format(n, inst[0] === 4 /* Opcode.SUB_LEFT */ ? si : inst[1]);
break;
case 13 /* APPLY_LEFT_NUM_FORMAT */:
case 14 /* APPLY_LEFT_2_NUM_FORMAT */:
case 13 /* Opcode.APPLY_LEFT_NUM_FORMAT */:
case 14 /* Opcode.APPLY_LEFT_2_NUM_FORMAT */:
// TODO: implement number format

@@ -326,3 +326,3 @@ this.buf += '#';

switch (inst[0]) {
case 11 /* APPLY_LEFT_2_RULE */:
case 11 /* Opcode.APPLY_LEFT_2_RULE */:
this._format(n, inst[1]);

@@ -335,5 +335,5 @@ break;

switch (inst[0]) {
case 7 /* APPLY_LEFT_RULE */:
case 4 /* SUB_LEFT */:
this._format(q, inst[0] === 4 /* SUB_LEFT */ ? si : inst[1]);
case 7 /* Opcode.APPLY_LEFT_RULE */:
case 4 /* Opcode.SUB_LEFT */:
this._format(q, inst[0] === 4 /* Opcode.SUB_LEFT */ ? si : inst[1]);
break;

@@ -349,5 +349,5 @@ default:

switch (inst[0]) {
case 3 /* APPLY_RIGHT_RULE */:
case 1 /* SUB_RIGHT */:
this._format(r, inst[0] === 1 /* SUB_RIGHT */ ? si : inst[1]);
case 3 /* Opcode.APPLY_RIGHT_RULE */:
case 1 /* Opcode.SUB_RIGHT */:
this._format(r, inst[0] === 1 /* Opcode.SUB_RIGHT */ ? si : inst[1]);
break;

@@ -378,5 +378,5 @@ }

var n = this.rbnf.numbers;
return r[0] === 4 /* NORMAL_RADIX */
return r[0] === 4 /* RuleType.NORMAL_RADIX */
? n[r[3]]
: r[0] === 3 /* NORMAL */
: r[0] === 3 /* RuleType.NORMAL */
? DIVISORS[n[r[2]].integerDigits()]

@@ -383,0 +383,0 @@ : TEN;

{
"name": "@phensley/cldr-ext-rbnf",
"version": "1.6.1",
"version": "1.6.2",
"description": "Extension for rule-based number formatting",

@@ -23,5 +23,5 @@ "main": "lib/index.js",

"dependencies": {
"@phensley/cldr-types": "~1.6.1",
"@phensley/decimal": "~1.6.1",
"@phensley/plurals": "~1.6.1",
"@phensley/cldr-types": "~1.6.2",
"@phensley/decimal": "~1.6.2",
"@phensley/plurals": "~1.6.2",
"tslib": "^2.4.0"

@@ -28,0 +28,0 @@ },

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc