Socket
Socket
Sign inDemoInstall

messageformat-parser

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

messageformat-parser - npm Package Compare versions

Comparing version 3.0.0-beta.1 to 3.0.0-beta.2

2

package.json
{
"name": "messageformat-parser",
"version": "3.0.0-beta.1",
"version": "3.0.0-beta.2",
"description": "A PEG.js parser for ICU MessageFormat strings",

@@ -5,0 +5,0 @@ "keywords": [

@@ -193,3 +193,3 @@ /*

},
peg$c22 = function(arg, key, params) {
peg$c22 = function(arg, key, param) {
return {

@@ -199,3 +199,3 @@ type: 'function',

key: key,
params: params
param: param
};

@@ -214,34 +214,29 @@ },

peg$c33 = peg$literalExpectation("=", false),
peg$c34 = function(p) { return options.strictFunctionParams; },
peg$c35 = function(p) { return p; },
peg$c36 = function(p) { return p.replace(whitespaceTrimRE, ''); },
peg$c37 = "''",
peg$c38 = peg$literalExpectation("''", false),
peg$c39 = function() { return "'"; },
peg$c40 = /^[^']/,
peg$c41 = peg$classExpectation(["'"], true, false),
peg$c42 = "'{",
peg$c43 = peg$literalExpectation("'{", false),
peg$c44 = "'",
peg$c45 = peg$literalExpectation("'", false),
peg$c46 = function(str) { return '\u007B'+str.join(''); },
peg$c47 = "'}",
peg$c48 = peg$literalExpectation("'}", false),
peg$c49 = function(str) { return '\u007D'+str.join(''); },
peg$c50 = "'#",
peg$c51 = peg$literalExpectation("'#", false),
peg$c52 = function(str) { return "#"+str.join(''); },
peg$c53 = function(quotedOcto) { return quotedOcto[0]; },
peg$c54 = function(octo) { return !inPlural; },
peg$c55 = function(octo) { return octo; },
peg$c56 = /^[^{}#\0-\x08\x0E-\x1F\x7F]/,
peg$c57 = peg$classExpectation(["{", "}", "#", ["\0", "\b"], ["\x0E", "\x1F"], "\x7F"], true, false),
peg$c58 = /^[^',}]/,
peg$c59 = peg$classExpectation(["'", ",", "}"], true, false),
peg$c60 = /^[^'}]/,
peg$c61 = peg$classExpectation(["'", "}"], true, false),
peg$c62 = /^[0-9]/,
peg$c63 = peg$classExpectation([["0", "9"]], false, false),
peg$c64 = /^[\t-\r \x85\u200E\u200F\u2028\u2029]/,
peg$c65 = peg$classExpectation([["\t", "\r"], " ", "\x85", "\u200E", "\u200F", "\u2028", "\u2029"], false, false),
peg$c34 = /^[^}]/,
peg$c35 = peg$classExpectation(["}"], true, false),
peg$c36 = "''",
peg$c37 = peg$literalExpectation("''", false),
peg$c38 = function() { return "'"; },
peg$c39 = /^[^']/,
peg$c40 = peg$classExpectation(["'"], true, false),
peg$c41 = "'{",
peg$c42 = peg$literalExpectation("'{", false),
peg$c43 = "'",
peg$c44 = peg$literalExpectation("'", false),
peg$c45 = function(str) { return '\u007B'+str.join(''); },
peg$c46 = "'}",
peg$c47 = peg$literalExpectation("'}", false),
peg$c48 = function(str) { return '\u007D'+str.join(''); },
peg$c49 = "'#",
peg$c50 = peg$literalExpectation("'#", false),
peg$c51 = function(str) { return "#"+str.join(''); },
peg$c52 = function(quotedOcto) { return quotedOcto[0]; },
peg$c53 = function(octo) { return !inPlural; },
peg$c54 = function(octo) { return octo; },
peg$c55 = /^[^{}#\0-\x08\x0E-\x1F\x7F]/,
peg$c56 = peg$classExpectation(["{", "}", "#", ["\0", "\b"], ["\x0E", "\x1F"], "\x7F"], true, false),
peg$c57 = /^[0-9]/,
peg$c58 = peg$classExpectation([["0", "9"]], false, false),
peg$c59 = /^[\t-\r \x85\u200E\u200F\u2028\u2029]/,
peg$c60 = peg$classExpectation([["\t", "\r"], " ", "\x85", "\u200E", "\u200F", "\u2028", "\u2029"], false, false),

@@ -839,3 +834,6 @@ peg$currPos = 0,

if (s8 !== peg$FAILED) {
s9 = peg$parsefunctionParams();
s9 = peg$parsefunctionParam();
if (s9 === peg$FAILED) {
s9 = null;
}
if (s9 !== peg$FAILED) {

@@ -932,48 +930,2 @@ if (input.charCodeAt(peg$currPos) === 125) {

function peg$parseparamDefault() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = [];
s2 = peg$parseparamcharsDefault();
if (s2 !== peg$FAILED) {
while (s2 !== peg$FAILED) {
s1.push(s2);
s2 = peg$parseparamcharsDefault();
}
} else {
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c4(s1);
}
s0 = s1;
return s0;
}
function peg$parseparamStrict() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = [];
s2 = peg$parseparamcharsStrict();
if (s2 !== peg$FAILED) {
while (s2 !== peg$FAILED) {
s1.push(s2);
s2 = peg$parseparamcharsStrict();
}
} else {
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c4(s1);
}
s0 = s1;
return s0;
}
function peg$parseselectCase() {

@@ -1236,69 +1188,6 @@ var s0, s1, s2, s3, s4;

function peg$parsefunctionParams() {
var s0, s1, s2;
function peg$parsefunctionParam() {
var s0, s1, s2, s3, s4;
s0 = peg$currPos;
s1 = [];
s2 = peg$parsefunctionParamsDefault();
while (s2 !== peg$FAILED) {
s1.push(s2);
s2 = peg$parsefunctionParamsDefault();
}
if (s1 !== peg$FAILED) {
peg$savedPos = peg$currPos;
s2 = peg$c34(s1);
if (s2) {
s2 = peg$FAILED;
} else {
s2 = void 0;
}
if (s2 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c35(s1);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = [];
s2 = peg$parsefunctionParamsStrict();
while (s2 !== peg$FAILED) {
s1.push(s2);
s2 = peg$parsefunctionParamsStrict();
}
if (s1 !== peg$FAILED) {
peg$savedPos = peg$currPos;
s2 = peg$c34(s1);
if (s2) {
s2 = void 0;
} else {
s2 = peg$FAILED;
}
if (s2 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c35(s1);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
}
return s0;
}
function peg$parsefunctionParamsStrict() {
var s0, s1, s2, s3;
s0 = peg$currPos;
s1 = peg$parse_();

@@ -1314,6 +1203,15 @@ if (s1 !== peg$FAILED) {

if (s2 !== peg$FAILED) {
s3 = peg$parseparamStrict();
s3 = [];
s4 = peg$parseparamChars();
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parseparamChars();
}
} else {
s3 = peg$FAILED;
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c35(s3);
s1 = peg$c4(s3);
s0 = s1;

@@ -1336,44 +1234,17 @@ } else {

function peg$parsefunctionParamsDefault() {
var s0, s1, s2, s3, s4, s5;
function peg$parseparamChars() {
var s0;
s0 = peg$currPos;
s1 = peg$parse_();
if (s1 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 44) {
s2 = peg$c10;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}
if (s2 !== peg$FAILED) {
s3 = peg$parse_();
if (s3 !== peg$FAILED) {
s4 = peg$parseparamDefault();
if (s4 !== peg$FAILED) {
s5 = peg$parse_();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c36(s4);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
s0 = peg$parsedoubleapos();
if (s0 === peg$FAILED) {
s0 = peg$parsequotedCurly();
if (s0 === peg$FAILED) {
if (peg$c34.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c35); }
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}

@@ -1388,12 +1259,12 @@

s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c37) {
s1 = peg$c37;
if (input.substr(peg$currPos, 2) === peg$c36) {
s1 = peg$c36;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c38); }
if (peg$silentFails === 0) { peg$fail(peg$c37); }
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c39();
s1 = peg$c38();
}

@@ -1412,3 +1283,3 @@ s0 = s1;

s1 = [];
if (peg$c40.test(input.charAt(peg$currPos))) {
if (peg$c39.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1418,3 +1289,3 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c41); }
if (peg$silentFails === 0) { peg$fail(peg$c40); }
}

@@ -1424,3 +1295,3 @@ if (s2 !== peg$FAILED) {

s1.push(s2);
if (peg$c40.test(input.charAt(peg$currPos))) {
if (peg$c39.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1430,3 +1301,3 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c41); }
if (peg$silentFails === 0) { peg$fail(peg$c40); }
}

@@ -1451,8 +1322,8 @@ }

s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c42) {
s1 = peg$c42;
if (input.substr(peg$currPos, 2) === peg$c41) {
s1 = peg$c41;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c43); }
if (peg$silentFails === 0) { peg$fail(peg$c42); }
}

@@ -1468,11 +1339,11 @@ if (s1 !== peg$FAILED) {

if (input.charCodeAt(peg$currPos) === 39) {
s3 = peg$c44;
s3 = peg$c43;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c45); }
if (peg$silentFails === 0) { peg$fail(peg$c44); }
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c46(s2);
s1 = peg$c45(s2);
s0 = s1;

@@ -1493,8 +1364,8 @@ } else {

s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c47) {
s1 = peg$c47;
if (input.substr(peg$currPos, 2) === peg$c46) {
s1 = peg$c46;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c48); }
if (peg$silentFails === 0) { peg$fail(peg$c47); }
}

@@ -1510,11 +1381,11 @@ if (s1 !== peg$FAILED) {

if (input.charCodeAt(peg$currPos) === 39) {
s3 = peg$c44;
s3 = peg$c43;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c45); }
if (peg$silentFails === 0) { peg$fail(peg$c44); }
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c49(s2);
s1 = peg$c48(s2);
s0 = s1;

@@ -1546,8 +1417,8 @@ } else {

s2 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c50) {
s3 = peg$c50;
if (input.substr(peg$currPos, 2) === peg$c49) {
s3 = peg$c49;
peg$currPos += 2;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c51); }
if (peg$silentFails === 0) { peg$fail(peg$c50); }
}

@@ -1563,11 +1434,11 @@ if (s3 !== peg$FAILED) {

if (input.charCodeAt(peg$currPos) === 39) {
s5 = peg$c44;
s5 = peg$c43;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c45); }
if (peg$silentFails === 0) { peg$fail(peg$c44); }
}
if (s5 !== peg$FAILED) {
peg$savedPos = s2;
s3 = peg$c52(s4);
s3 = peg$c51(s4);
s2 = s3;

@@ -1607,3 +1478,3 @@ } else {

peg$savedPos = s0;
s1 = peg$c53(s1);
s1 = peg$c52(s1);
}

@@ -1613,7 +1484,7 @@ s0 = s1;

if (input.charCodeAt(peg$currPos) === 39) {
s0 = peg$c44;
s0 = peg$c43;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c45); }
if (peg$silentFails === 0) { peg$fail(peg$c44); }
}

@@ -1626,19 +1497,2 @@ }

function peg$parsequotedFunctionParams() {
var s0;
s0 = peg$parsequotedCurly();
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 39) {
s0 = peg$c44;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c45); }
}
}
return s0;
}
function peg$parsechar() {

@@ -1661,3 +1515,3 @@ var s0, s1, s2;

peg$savedPos = peg$currPos;
s2 = peg$c54(s1);
s2 = peg$c53(s1);
if (s2) {

@@ -1670,3 +1524,3 @@ s2 = void 0;

peg$savedPos = s0;
s1 = peg$c55(s1);
s1 = peg$c54(s1);
s0 = s1;

@@ -1682,3 +1536,3 @@ } else {

if (s0 === peg$FAILED) {
if (peg$c56.test(input.charAt(peg$currPos))) {
if (peg$c55.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);

@@ -1688,3 +1542,3 @@ peg$currPos++;

s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c57); }
if (peg$silentFails === 0) { peg$fail(peg$c56); }
}

@@ -1698,89 +1552,2 @@ }

function peg$parseparamcharsCommon() {
var s0;
s0 = peg$parsedoubleapos();
if (s0 === peg$FAILED) {
s0 = peg$parsequotedFunctionParams();
}
return s0;
}
function peg$parseparamcharsDefault() {
var s0, s1, s2;
s0 = peg$parseparamcharsCommon();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = [];
if (peg$c58.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c59); }
}
if (s2 !== peg$FAILED) {
while (s2 !== peg$FAILED) {
s1.push(s2);
if (peg$c58.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c59); }
}
}
} else {
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c4(s1);
}
s0 = s1;
}
return s0;
}
function peg$parseparamcharsStrict() {
var s0, s1, s2;
s0 = peg$parseparamcharsCommon();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = [];
if (peg$c60.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c61); }
}
if (s2 !== peg$FAILED) {
while (s2 !== peg$FAILED) {
s1.push(s2);
if (peg$c60.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c61); }
}
}
} else {
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c4(s1);
}
s0 = s1;
}
return s0;
}
function peg$parsedigits() {

@@ -1791,3 +1558,3 @@ var s0, s1, s2;

s1 = [];
if (peg$c62.test(input.charAt(peg$currPos))) {
if (peg$c57.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1797,3 +1564,3 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c63); }
if (peg$silentFails === 0) { peg$fail(peg$c58); }
}

@@ -1803,3 +1570,3 @@ if (s2 !== peg$FAILED) {

s1.push(s2);
if (peg$c62.test(input.charAt(peg$currPos))) {
if (peg$c57.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1809,3 +1576,3 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c63); }
if (peg$silentFails === 0) { peg$fail(peg$c58); }
}

@@ -1830,3 +1597,3 @@ }

s1 = [];
if (peg$c64.test(input.charAt(peg$currPos))) {
if (peg$c59.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1836,7 +1603,7 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c65); }
if (peg$silentFails === 0) { peg$fail(peg$c60); }
}
while (s2 !== peg$FAILED) {
s1.push(s2);
if (peg$c64.test(input.charAt(peg$currPos))) {
if (peg$c59.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);

@@ -1846,3 +1613,3 @@ peg$currPos++;

s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c65); }
if (peg$silentFails === 0) { peg$fail(peg$c60); }
}

@@ -1861,4 +1628,2 @@ }

var inPlural = false;
var whitespaceChars = "[\u0009-\u000d \u0085\u200e\u200f\u2028\u2029]*";
var whitespaceTrimRE = new RegExp("^" + whitespaceChars + "|" + whitespaceChars + "$", "g");

@@ -1865,0 +1630,0 @@

@@ -16,8 +16,2 @@ # messageformat-parser <a href="http://travis-ci.org/messageformat/parser"><img align="right" alt="Build Status" src="https://secure.travis-ci.org/messageformat/parser.png"></a>

- `strictFunctionParams` – By default, function parameters are split on commas
and trimmed, so the parameters in `{x,fn, a, b }` are parsed as
`['a','b']`. Setting `strictFunctionParams` to true will make the parser
follow the ICU MessageFormat spec more closely, and result in a params array
with a single element: `[' a, b ']`.
- `strictNumberSign` – Inside a `plural` or `selectordinal` statement, a pound

@@ -115,3 +109,3 @@ symbol (`#`) is replaced with the input number. By default, `#` is also parsed

```js
```typescript
type Token = string | Argument | Plural | Select | Function

@@ -141,3 +135,3 @@

key: Identifier,
params: string[]
param: string | null
}

@@ -144,0 +138,0 @@

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