@phensley/messageformat
Advanced tools
Comparing version 0.20.2 to 0.20.3
@@ -0,1 +1,2 @@ | ||
import { DecimalConstants } from '@phensley/decimal'; | ||
import { pluralRules } from '@phensley/plurals'; | ||
@@ -7,2 +8,8 @@ import { asdecimal, asstring } from './args'; | ||
}; | ||
// Save a bit of processing of common exact matches | ||
var DECIMAL_EXACT = { | ||
0: DecimalConstants.ZERO, | ||
1: DecimalConstants.ONE, | ||
2: DecimalConstants.TWO | ||
}; | ||
/** | ||
@@ -59,3 +66,7 @@ * Evaluates a message format against a set of arguments, producing a string. | ||
case 0 /* EXACT */: | ||
if (num.compare(c[1]) === 0) { | ||
var v = DECIMAL_EXACT[c[1]]; | ||
if (v === undefined) { | ||
v = asdecimal(c[1]); | ||
} | ||
if (num.compare(v) === 0) { | ||
this._evaluate(c[2], args, num); | ||
@@ -62,0 +73,0 @@ found = 1; |
@@ -1,2 +0,1 @@ | ||
import { Decimal, DecimalConstants } from '@phensley/decimal'; | ||
export var parseMessagePattern = function (raw, matcher) { | ||
@@ -201,9 +200,4 @@ return new MessagePatternParser(raw, matcher).parse(); | ||
if (choice[0] === '=') { | ||
// Conver the exact match into a Decimal type | ||
var num = choice.substring(1); | ||
var value = DECIMAL_EXACT[num]; | ||
if (!value) { | ||
value = new Decimal(num); | ||
} | ||
node = [0 /* EXACT */, value, block]; | ||
node = [0 /* EXACT */, num, block]; | ||
} | ||
@@ -306,8 +300,2 @@ else { | ||
var text = function (s) { return [0 /* TEXT */, s]; }; | ||
// Save a bit of processing of common exact matches | ||
var DECIMAL_EXACT = { | ||
0: DecimalConstants.ZERO, | ||
1: DecimalConstants.ONE, | ||
2: DecimalConstants.TWO | ||
}; | ||
/** | ||
@@ -314,0 +302,0 @@ * Emit a text node, performing argument substitution for all occurrences of |
@@ -1,2 +0,1 @@ | ||
import { Decimal } from '@phensley/decimal'; | ||
export declare type Argument = string | number; | ||
@@ -48,3 +47,3 @@ export declare const enum MessageOpType { | ||
[0]: PluralChoiceType.EXACT; | ||
[1]: Decimal; | ||
[1]: string; | ||
[2]: MessageCode; | ||
@@ -51,0 +50,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var decimal_1 = require("@phensley/decimal"); | ||
var plurals_1 = require("@phensley/plurals"); | ||
@@ -9,2 +10,8 @@ var args_1 = require("./args"); | ||
}; | ||
// Save a bit of processing of common exact matches | ||
var DECIMAL_EXACT = { | ||
0: decimal_1.DecimalConstants.ZERO, | ||
1: decimal_1.DecimalConstants.ONE, | ||
2: decimal_1.DecimalConstants.TWO | ||
}; | ||
/** | ||
@@ -61,3 +68,7 @@ * Evaluates a message format against a set of arguments, producing a string. | ||
case 0 /* EXACT */: | ||
if (num.compare(c[1]) === 0) { | ||
var v = DECIMAL_EXACT[c[1]]; | ||
if (v === undefined) { | ||
v = args_1.asdecimal(c[1]); | ||
} | ||
if (num.compare(v) === 0) { | ||
this._evaluate(c[2], args, num); | ||
@@ -64,0 +75,0 @@ found = 1; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var decimal_1 = require("@phensley/decimal"); | ||
exports.parseMessagePattern = function (raw, matcher) { | ||
@@ -203,9 +202,4 @@ return new MessagePatternParser(raw, matcher).parse(); | ||
if (choice[0] === '=') { | ||
// Conver the exact match into a Decimal type | ||
var num = choice.substring(1); | ||
var value = DECIMAL_EXACT[num]; | ||
if (!value) { | ||
value = new decimal_1.Decimal(num); | ||
} | ||
node = [0 /* EXACT */, value, block]; | ||
node = [0 /* EXACT */, num, block]; | ||
} | ||
@@ -308,8 +302,2 @@ else { | ||
var text = function (s) { return [0 /* TEXT */, s]; }; | ||
// Save a bit of processing of common exact matches | ||
var DECIMAL_EXACT = { | ||
0: decimal_1.DecimalConstants.ZERO, | ||
1: decimal_1.DecimalConstants.ONE, | ||
2: decimal_1.DecimalConstants.TWO | ||
}; | ||
/** | ||
@@ -316,0 +304,0 @@ * Emit a text node, performing argument substitution for all occurrences of |
@@ -1,2 +0,1 @@ | ||
import { Decimal } from '@phensley/decimal'; | ||
export declare type Argument = string | number; | ||
@@ -48,3 +47,3 @@ export declare const enum MessageOpType { | ||
[0]: PluralChoiceType.EXACT; | ||
[1]: Decimal; | ||
[1]: string; | ||
[2]: MessageCode; | ||
@@ -51,0 +50,0 @@ } |
{ | ||
"name": "@phensley/messageformat", | ||
"version": "0.20.2", | ||
"version": "0.20.3", | ||
"description": "Extensible ICU message formatter", | ||
@@ -37,4 +37,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@phensley/decimal": "0.20.2", | ||
"@phensley/plurals": "0.20.2", | ||
"@phensley/decimal": "0.20.3", | ||
"@phensley/plurals": "0.20.3", | ||
"tslib": "1.10.x" | ||
@@ -68,3 +68,3 @@ }, | ||
}, | ||
"gitHead": "a5e09b6883360c7a90764344a010921cee5382f8" | ||
"gitHead": "ae0f80f9cb874ca00ad03b482164991f45b3ddf9" | ||
} |
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
116640
1783
+ Added@phensley/decimal@0.20.3(transitive)
+ Added@phensley/plurals@0.20.3(transitive)
- Removed@phensley/decimal@0.20.2(transitive)
- Removed@phensley/plurals@0.20.2(transitive)
Updated@phensley/decimal@0.20.3
Updated@phensley/plurals@0.20.3