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

@phensley/messageformat

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@phensley/messageformat - npm Package Compare versions

Comparing version 1.5.2 to 1.6.0

20

lib-es/evaluation/evaluation.js

@@ -34,6 +34,6 @@ import { DecimalConstants } from '@phensley/decimal';

switch (code[0]) {
case 0 /* TEXT */:
case 0 /* MessageOpType.TEXT */:
this.buf += code[1];
break;
case 4 /* BLOCK */:
case 4 /* MessageOpType.BLOCK */:
for (var _i = 0, _a = code[1]; _i < _a.length; _i++) {

@@ -44,3 +44,3 @@ var n = _a[_i];

break;
case 1 /* ARG */: {
case 1 /* MessageOpType.ARG */: {
var arg = get(code[1], args);

@@ -50,7 +50,7 @@ this.buf += this.converter.asString(arg);

}
case 7 /* ARGSUB */: {
case 7 /* MessageOpType.ARGSUB */: {
this.buf += this.converter.asString(argsub);
break;
}
case 2 /* PLURAL */: {
case 2 /* MessageOpType.PLURAL */: {
var arg = get(code[1][0], args);

@@ -60,3 +60,3 @@ var offset = code[2];

argsub = offset ? num.subtract(offset) : num;
var category = code[3] === 0 /* CARDINAL */ ? this.plurals.cardinal(argsub) : this.plurals.ordinal(argsub);
var category = code[3] === 0 /* PluralNumberType.CARDINAL */ ? this.plurals.cardinal(argsub) : this.plurals.ordinal(argsub);
var other = void 0;

@@ -67,3 +67,3 @@ var found = 0;

switch (c[0]) {
case 0 /* EXACT */:
case 0 /* PluralChoiceType.EXACT */:
var v = DECIMAL_EXACT[c[1]];

@@ -79,3 +79,3 @@ if (v === undefined) {

break;
case 1 /* CATEGORY */:
case 1 /* PluralChoiceType.CATEGORY */:
if (c[1] === category) {

@@ -99,3 +99,3 @@ this._evaluate(c[2], args, argsub);

}
case 3 /* SELECT */: {
case 3 /* MessageOpType.SELECT */: {
var arg = get(code[1][0], args);

@@ -123,3 +123,3 @@ var str = this.converter.asString(arg);

}
case 6 /* SIMPLE */: {
case 6 /* MessageOpType.SIMPLE */: {
// One or more arguments and zero or more options

@@ -126,0 +126,0 @@ var name_1 = code[1];

@@ -57,3 +57,3 @@ /**

switch (c) {
case "{" /* LEFT */: {
case "{" /* Chars.LEFT */: {
// Push non-empty buffer

@@ -64,3 +64,3 @@ if (buf) {

}
var hidden = str[r.s + 1] === "-" /* MINUS */;
var hidden = str[r.s + 1] === "-" /* Chars.MINUS */;
var k = this.seek(r.s, r.e);

@@ -73,3 +73,3 @@ if (k === -1) {

// Tag is hidden from processor, emit as text
n.push(text("{" /* LEFT */ + str.substring(r.s + 2, k + 1)));
n.push(text("{" /* Chars.LEFT */ + str.substring(r.s + 2, k + 1)));
// Skip over hidden tag

@@ -95,3 +95,3 @@ r.s = k;

}
case "'" /* APOS */: {
case "'" /* Chars.APOS */: {
if (c === str[r.s + 1]) {

@@ -145,3 +145,3 @@ // Convert double apostrophe to single

// We have a simple argument.
return [1 /* ARG */, args[0]];
return [1 /* MessageOpType.ARG */, args[0]];
}

@@ -158,3 +158,3 @@ // See if any of our known formatters are present

case 'selectordinal':
var type = name === 'plural' ? 0 /* CARDINAL */ : 1 /* ORDINAL */;
var type = name === 'plural' ? 0 /* PluralNumberType.CARDINAL */ : 1 /* PluralNumberType.ORDINAL */;
return this.plural(args, type, m, r);

@@ -178,6 +178,6 @@ case 'select':

// Ensure we see a tag start next
if (m.char(r) !== "{" /* LEFT */) {
if (m.char(r) !== "{" /* Chars.LEFT */) {
return undefined;
}
var hidden = this.raw[r.s + 1] === "-" /* MINUS */;
var hidden = this.raw[r.s + 1] === "-" /* Chars.MINUS */;
// Find matching end delimter

@@ -192,3 +192,3 @@ var k = this.seek(r.s, r.e);

var node = hidden
? text("{" /* LEFT */ + this.raw.substring(r.s + 2, k + 1))
? text("{" /* Chars.LEFT */ + this.raw.substring(r.s + 2, k + 1))
: this.outer({ t: r.t, s: r.s + 1, e: k }, argsub);

@@ -222,7 +222,7 @@ r.s = k + 1;

var num = choice.substring(1);
node = [0 /* EXACT */, num, block];
node = [0 /* PluralChoiceType.EXACT */, num, block];
}
else {
// Plural category match
node = [1 /* CATEGORY */, choice, block];
node = [1 /* PluralChoiceType.CATEGORY */, choice, block];
}

@@ -234,3 +234,3 @@ // Append and skip spaces

// If we parsed no choices, emit a no-op
return choices.length ? [2 /* PLURAL */, args, offset, type, choices] : NOOP;
return choices.length ? [2 /* MessageOpType.PLURAL */, args, offset, type, choices] : NOOP;
};

@@ -258,3 +258,3 @@ /**

// If we parsed no choices, just emit a no-op
return choices.length ? [3 /* SELECT */, args, choices] : NOOP;
return choices.length ? [3 /* MessageOpType.SELECT */, args, choices] : NOOP;
};

@@ -266,3 +266,3 @@ /**

var options = m.options(r);
return [6 /* SIMPLE */, name, args, options];
return [6 /* MessageOpType.SIMPLE */, name, args, options];
};

@@ -282,7 +282,7 @@ /**

switch (c) {
case "{" /* LEFT */:
case "{" /* Chars.LEFT */:
// Increase depth
d++;
break;
case "}" /* RIGHT */:
case "}" /* Chars.RIGHT */:
// Reduce depth

@@ -295,3 +295,3 @@ d--;

break;
case "'" /* APOS */:
case "'" /* Chars.APOS */:
if (c === r[i + 1]) {

@@ -321,5 +321,5 @@ // Skip single escaped apostrophe

var flatten = function (n) {
return !n.length ? NOOP : n.length === 1 ? n[0] : [4 /* BLOCK */, n];
return !n.length ? NOOP : n.length === 1 ? n[0] : [4 /* MessageOpType.BLOCK */, n];
};
var text = function (s) { return [0 /* TEXT */, s]; };
var text = function (s) { return [0 /* MessageOpType.TEXT */, s]; };
/**

@@ -337,3 +337,3 @@ * Emit a text node, performing argument substitution for all occurrences of

// If no '#' character is found, return plain text
j = s.indexOf("#" /* POUND */);
j = s.indexOf("#" /* Chars.POUND */);
if (j === -1) {

@@ -354,6 +354,6 @@ return text(s);

// Add a substitution op
n.push([7 /* ARGSUB */]);
n.push([7 /* MessageOpType.ARGSUB */]);
// Skip over '#' and search for next occurrence
i = j + 1;
j = s.indexOf("#" /* POUND */, i);
j = s.indexOf("#" /* Chars.POUND */, i);
}

@@ -366,3 +366,3 @@ // Push trailing text

};
var NOOP = [5 /* NOOP */];
var NOOP = [5 /* MessageOpType.NOOP */];
//# sourceMappingURL=parser.js.map

@@ -37,6 +37,6 @@ "use strict";

switch (code[0]) {
case 0 /* TEXT */:
case 0 /* MessageOpType.TEXT */:
this.buf += code[1];
break;
case 4 /* BLOCK */:
case 4 /* MessageOpType.BLOCK */:
for (var _i = 0, _a = code[1]; _i < _a.length; _i++) {

@@ -47,3 +47,3 @@ var n = _a[_i];

break;
case 1 /* ARG */: {
case 1 /* MessageOpType.ARG */: {
var arg = get(code[1], args);

@@ -53,7 +53,7 @@ this.buf += this.converter.asString(arg);

}
case 7 /* ARGSUB */: {
case 7 /* MessageOpType.ARGSUB */: {
this.buf += this.converter.asString(argsub);
break;
}
case 2 /* PLURAL */: {
case 2 /* MessageOpType.PLURAL */: {
var arg = get(code[1][0], args);

@@ -63,3 +63,3 @@ var offset = code[2];

argsub = offset ? num.subtract(offset) : num;
var category = code[3] === 0 /* CARDINAL */ ? this.plurals.cardinal(argsub) : this.plurals.ordinal(argsub);
var category = code[3] === 0 /* PluralNumberType.CARDINAL */ ? this.plurals.cardinal(argsub) : this.plurals.ordinal(argsub);
var other = void 0;

@@ -70,3 +70,3 @@ var found = 0;

switch (c[0]) {
case 0 /* EXACT */:
case 0 /* PluralChoiceType.EXACT */:
var v = DECIMAL_EXACT[c[1]];

@@ -82,3 +82,3 @@ if (v === undefined) {

break;
case 1 /* CATEGORY */:
case 1 /* PluralChoiceType.CATEGORY */:
if (c[1] === category) {

@@ -102,3 +102,3 @@ this._evaluate(c[2], args, argsub);

}
case 3 /* SELECT */: {
case 3 /* MessageOpType.SELECT */: {
var arg = get(code[1][0], args);

@@ -126,3 +126,3 @@ var str = this.converter.asString(arg);

}
case 6 /* SIMPLE */: {
case 6 /* MessageOpType.SIMPLE */: {
// One or more arguments and zero or more options

@@ -129,0 +129,0 @@ var name_1 = code[1];

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

switch (c) {
case "{" /* LEFT */: {
case "{" /* Chars.LEFT */: {
// Push non-empty buffer

@@ -68,3 +68,3 @@ if (buf) {

}
var hidden = str[r.s + 1] === "-" /* MINUS */;
var hidden = str[r.s + 1] === "-" /* Chars.MINUS */;
var k = this.seek(r.s, r.e);

@@ -77,3 +77,3 @@ if (k === -1) {

// Tag is hidden from processor, emit as text
n.push(text("{" /* LEFT */ + str.substring(r.s + 2, k + 1)));
n.push(text("{" /* Chars.LEFT */ + str.substring(r.s + 2, k + 1)));
// Skip over hidden tag

@@ -99,3 +99,3 @@ r.s = k;

}
case "'" /* APOS */: {
case "'" /* Chars.APOS */: {
if (c === str[r.s + 1]) {

@@ -149,3 +149,3 @@ // Convert double apostrophe to single

// We have a simple argument.
return [1 /* ARG */, args[0]];
return [1 /* MessageOpType.ARG */, args[0]];
}

@@ -162,3 +162,3 @@ // See if any of our known formatters are present

case 'selectordinal':
var type = name === 'plural' ? 0 /* CARDINAL */ : 1 /* ORDINAL */;
var type = name === 'plural' ? 0 /* PluralNumberType.CARDINAL */ : 1 /* PluralNumberType.ORDINAL */;
return this.plural(args, type, m, r);

@@ -182,6 +182,6 @@ case 'select':

// Ensure we see a tag start next
if (m.char(r) !== "{" /* LEFT */) {
if (m.char(r) !== "{" /* Chars.LEFT */) {
return undefined;
}
var hidden = this.raw[r.s + 1] === "-" /* MINUS */;
var hidden = this.raw[r.s + 1] === "-" /* Chars.MINUS */;
// Find matching end delimter

@@ -196,3 +196,3 @@ var k = this.seek(r.s, r.e);

var node = hidden
? text("{" /* LEFT */ + this.raw.substring(r.s + 2, k + 1))
? text("{" /* Chars.LEFT */ + this.raw.substring(r.s + 2, k + 1))
: this.outer({ t: r.t, s: r.s + 1, e: k }, argsub);

@@ -226,7 +226,7 @@ r.s = k + 1;

var num = choice.substring(1);
node = [0 /* EXACT */, num, block];
node = [0 /* PluralChoiceType.EXACT */, num, block];
}
else {
// Plural category match
node = [1 /* CATEGORY */, choice, block];
node = [1 /* PluralChoiceType.CATEGORY */, choice, block];
}

@@ -238,3 +238,3 @@ // Append and skip spaces

// If we parsed no choices, emit a no-op
return choices.length ? [2 /* PLURAL */, args, offset, type, choices] : NOOP;
return choices.length ? [2 /* MessageOpType.PLURAL */, args, offset, type, choices] : NOOP;
};

@@ -262,3 +262,3 @@ /**

// If we parsed no choices, just emit a no-op
return choices.length ? [3 /* SELECT */, args, choices] : NOOP;
return choices.length ? [3 /* MessageOpType.SELECT */, args, choices] : NOOP;
};

@@ -270,3 +270,3 @@ /**

var options = m.options(r);
return [6 /* SIMPLE */, name, args, options];
return [6 /* MessageOpType.SIMPLE */, name, args, options];
};

@@ -286,7 +286,7 @@ /**

switch (c) {
case "{" /* LEFT */:
case "{" /* Chars.LEFT */:
// Increase depth
d++;
break;
case "}" /* RIGHT */:
case "}" /* Chars.RIGHT */:
// Reduce depth

@@ -299,3 +299,3 @@ d--;

break;
case "'" /* APOS */:
case "'" /* Chars.APOS */:
if (c === r[i + 1]) {

@@ -325,5 +325,5 @@ // Skip single escaped apostrophe

var flatten = function (n) {
return !n.length ? NOOP : n.length === 1 ? n[0] : [4 /* BLOCK */, n];
return !n.length ? NOOP : n.length === 1 ? n[0] : [4 /* MessageOpType.BLOCK */, n];
};
var text = function (s) { return [0 /* TEXT */, s]; };
var text = function (s) { return [0 /* MessageOpType.TEXT */, s]; };
/**

@@ -341,3 +341,3 @@ * Emit a text node, performing argument substitution for all occurrences of

// If no '#' character is found, return plain text
j = s.indexOf("#" /* POUND */);
j = s.indexOf("#" /* Chars.POUND */);
if (j === -1) {

@@ -358,6 +358,6 @@ return text(s);

// Add a substitution op
n.push([7 /* ARGSUB */]);
n.push([7 /* MessageOpType.ARGSUB */]);
// Skip over '#' and search for next occurrence
i = j + 1;
j = s.indexOf("#" /* POUND */, i);
j = s.indexOf("#" /* Chars.POUND */, i);
}

@@ -370,3 +370,3 @@ // Push trailing text

};
var NOOP = [5 /* NOOP */];
var NOOP = [5 /* MessageOpType.NOOP */];
//# sourceMappingURL=parser.js.map
{
"name": "@phensley/messageformat",
"version": "1.5.2",
"version": "1.6.0",
"description": "Extensible ICU message formatter",

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

"dependencies": {
"@phensley/cldr-utils": "~1.5.2",
"@phensley/decimal": "~1.5.2",
"@phensley/plurals": "~1.5.2",
"@phensley/cldr-utils": "~1.6.0",
"@phensley/decimal": "~1.6.0",
"@phensley/plurals": "~1.6.0",
"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