Socket
Socket
Sign inDemoInstall

@formatjs/icu-messageformat-parser

Package Overview
Dependencies
Maintainers
3
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formatjs/icu-messageformat-parser - npm Package Compare versions

Comparing version 2.7.2 to 2.7.3

16

lib/date-time-pattern-generator.js

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBestPattern = void 0;
var time_data_generated_1 = require("./time-data.generated");
import { timeData } from './time-data.generated';
/**

@@ -12,3 +9,3 @@ * Returns the best matching date time pattern if a date time skeleton

*/
function getBestPattern(skeleton, locale) {
export function getBestPattern(skeleton, locale) {
var skeletonCopy = '';

@@ -47,3 +44,2 @@ for (var patternPos = 0; patternPos < skeleton.length; patternPos++) {

}
exports.getBestPattern = getBestPattern;
/**

@@ -84,7 +80,7 @@ * Maps the [hour cycle type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle)

}
var hourCycles = time_data_generated_1.timeData[regionTag || ''] ||
time_data_generated_1.timeData[languageTag || ''] ||
time_data_generated_1.timeData["".concat(languageTag, "-001")] ||
time_data_generated_1.timeData['001'];
var hourCycles = timeData[regionTag || ''] ||
timeData[languageTag || ''] ||
timeData["".concat(languageTag, "-001")] ||
timeData['001'];
return hourCycles[0];
}

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorKind = void 0;
var ErrorKind;
export var ErrorKind;
(function (ErrorKind) {

@@ -66,2 +63,2 @@ /** Argument is unclosed (e.g. `{0`) */

ErrorKind[ErrorKind["UNCLOSED_TAG"] = 27] = "UNCLOSED_TAG";
})(ErrorKind || (exports.ErrorKind = ErrorKind = {}));
})(ErrorKind || (ErrorKind = {}));

@@ -1,12 +0,9 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._Parser = exports.parse = void 0;
var tslib_1 = require("tslib");
var error_1 = require("./error");
var parser_1 = require("./parser");
var types_1 = require("./types");
import { __assign } from "tslib";
import { ErrorKind } from './error';
import { Parser } from './parser';
import { isDateElement, isDateTimeSkeleton, isNumberElement, isNumberSkeleton, isPluralElement, isSelectElement, isTagElement, isTimeElement, } from './types';
function pruneLocation(els) {
els.forEach(function (el) {
delete el.location;
if ((0, types_1.isSelectElement)(el) || (0, types_1.isPluralElement)(el)) {
if (isSelectElement(el) || isPluralElement(el)) {
for (var k in el.options) {

@@ -17,10 +14,10 @@ delete el.options[k].location;

}
else if ((0, types_1.isNumberElement)(el) && (0, types_1.isNumberSkeleton)(el.style)) {
else if (isNumberElement(el) && isNumberSkeleton(el.style)) {
delete el.style.location;
}
else if (((0, types_1.isDateElement)(el) || (0, types_1.isTimeElement)(el)) &&
(0, types_1.isDateTimeSkeleton)(el.style)) {
else if ((isDateElement(el) || isTimeElement(el)) &&
isDateTimeSkeleton(el.style)) {
delete el.style.location;
}
else if ((0, types_1.isTagElement)(el)) {
else if (isTagElement(el)) {
pruneLocation(el.children);

@@ -30,8 +27,8 @@ }

}
function parse(message, opts) {
export function parse(message, opts) {
if (opts === void 0) { opts = {}; }
opts = tslib_1.__assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);
var result = new parser_1.Parser(message, opts).parse();
opts = __assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);
var result = new Parser(message, opts).parse();
if (result.err) {
var error = SyntaxError(error_1.ErrorKind[result.err.kind]);
var error = SyntaxError(ErrorKind[result.err.kind]);
// @ts-expect-error Assign to error object

@@ -48,5 +45,4 @@ error.location = result.err.location;

}
exports.parse = parse;
tslib_1.__exportStar(require("./types"), exports);
export * from './types';
// only for testing
exports._Parser = parser_1.Parser;
export var _Parser = Parser;

@@ -1,10 +0,7 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hoistSelectors = void 0;
var tslib_1 = require("tslib");
var types_1 = require("./types");
import { __spreadArray } from "tslib";
import { isPluralElement, isSelectElement, isTagElement, } from './types';
function cloneDeep(obj) {
if (Array.isArray(obj)) {
// @ts-expect-error meh
return tslib_1.__spreadArray([], obj.map(cloneDeep), true);
return __spreadArray([], obj.map(cloneDeep), true);
}

@@ -26,3 +23,3 @@ if (obj !== null && typeof obj === 'object') {

cloned.options = Object.keys(options).reduce(function (all, k) {
var newValue = hoistSelectors(tslib_1.__spreadArray(tslib_1.__spreadArray(tslib_1.__spreadArray([], ast.slice(0, positionToInject), true), options[k].value, true), ast.slice(positionToInject + 1), true));
var newValue = hoistSelectors(__spreadArray(__spreadArray(__spreadArray([], ast.slice(0, positionToInject), true), options[k].value, true), ast.slice(positionToInject + 1), true));
all[k] = {

@@ -36,3 +33,3 @@ value: newValue,

function isPluralOrSelectElement(el) {
return (0, types_1.isPluralElement)(el) || (0, types_1.isSelectElement)(el);
return isPluralElement(el) || isSelectElement(el);
}

@@ -44,3 +41,3 @@ function findPluralOrSelectElement(ast) {

}
if ((0, types_1.isTagElement)(el)) {
if (isTagElement(el)) {
return findPluralOrSelectElement(el.children);

@@ -62,3 +59,3 @@ }

*/
function hoistSelectors(ast) {
export function hoistSelectors(ast) {
for (var i = 0; i < ast.length; i++) {

@@ -69,3 +66,3 @@ var el = ast[i];

}
if ((0, types_1.isTagElement)(el) && findPluralOrSelectElement([el])) {
if (isTagElement(el) && findPluralOrSelectElement([el])) {
throw new Error('Cannot hoist plural/select within a tag element. Please put the tag element inside each plural/select option');

@@ -76,2 +73,1 @@ }

}
exports.hoistSelectors = hoistSelectors;

@@ -1,10 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._Parser = exports.parse = void 0;
var tslib_1 = require("tslib");
function parse() {
export function parse() {
throw new Error("You're trying to format an uncompiled message with react-intl without parser, please import from 'react-intl' instead");
}
exports.parse = parse;
tslib_1.__exportStar(require("./types"), exports);
exports._Parser = undefined;
export * from './types';
export var _Parser = undefined;

@@ -1,13 +0,10 @@

"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Parser = void 0;
var tslib_1 = require("tslib");
var error_1 = require("./error");
var types_1 = require("./types");
var regex_generated_1 = require("./regex.generated");
var icu_skeleton_parser_1 = require("@formatjs/icu-skeleton-parser");
var date_time_pattern_generator_1 = require("./date-time-pattern-generator");
var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(regex_generated_1.SPACE_SEPARATOR_REGEX.source, "*"));
var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(regex_generated_1.SPACE_SEPARATOR_REGEX.source, "*$"));
import { __assign } from "tslib";
import { ErrorKind } from './error';
import { SKELETON_TYPE, TYPE, } from './types';
import { SPACE_SEPARATOR_REGEX } from './regex.generated';
import { parseNumberSkeleton, parseNumberSkeletonFromString, parseDateTimeSkeleton, } from '@formatjs/icu-skeleton-parser';
import { getBestPattern } from './date-time-pattern-generator';
var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*"));
var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$"));
function createLocation(start, end) {

@@ -198,3 +195,3 @@ return { start: start, end: end };

elements.push({
type: types_1.TYPE.pound,
type: TYPE.pound,
location: createLocation(position, this.clonePosition()),

@@ -211,3 +208,3 @@ });

else {
return this.error(error_1.ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
}

@@ -261,3 +258,3 @@ }

val: {
type: types_1.TYPE.literal,
type: TYPE.literal,
value: "<".concat(tagName, "/>"),

@@ -279,3 +276,3 @@ location: createLocation(startPosition, this.clonePosition()),

if (this.isEOF() || !_isAlpha(this.char())) {
return this.error(error_1.ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
}

@@ -285,11 +282,11 @@ var closingTagNameStartPosition = this.clonePosition();

if (tagName !== closingTagName) {
return this.error(error_1.ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(closingTagNameStartPosition, this.clonePosition()));
return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(closingTagNameStartPosition, this.clonePosition()));
}
this.bumpSpace();
if (!this.bumpIf('>')) {
return this.error(error_1.ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
}
return {
val: {
type: types_1.TYPE.tag,
type: TYPE.tag,
value: tagName,

@@ -303,7 +300,7 @@ children: children,

else {
return this.error(error_1.ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition()));
return this.error(ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition()));
}
}
else {
return this.error(error_1.ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition()));
return this.error(ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition()));
}

@@ -345,3 +342,3 @@ };

return {
val: { type: types_1.TYPE.literal, value: value, location: location },
val: { type: TYPE.literal, value: value, location: location },
err: null,

@@ -439,7 +436,7 @@ };

if (this.isEOF()) {
return this.error(error_1.ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
}
if (this.char() === 125 /* `}` */) {
this.bump();
return this.error(error_1.ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
return this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
}

@@ -449,7 +446,7 @@ // argument name

if (!value) {
return this.error(error_1.ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
}
this.bumpSpace();
if (this.isEOF()) {
return this.error(error_1.ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
}

@@ -462,3 +459,3 @@ switch (this.char()) {

val: {
type: types_1.TYPE.argument,
type: TYPE.argument,
// value does not include the opening and closing braces.

@@ -476,3 +473,3 @@ value: value,

if (this.isEOF()) {
return this.error(error_1.ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
}

@@ -482,3 +479,3 @@ return this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition);

default:
return this.error(error_1.ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
}

@@ -511,3 +508,3 @@ };

// Expecting a style string number, date, time, plural, selectordinal, or select.
return this.error(error_1.ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
case 'number':

@@ -530,3 +527,3 @@ case 'date':

if (style.length === 0) {
return this.error(error_1.ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
}

@@ -551,3 +548,3 @@ var styleLocation = createLocation(styleStartPosition, this.clonePosition());

return {
val: { type: types_1.TYPE.number, value: value, location: location_1, style: result.val },
val: { type: TYPE.number, value: value, location: location_1, style: result.val },
err: null,

@@ -558,3 +555,3 @@ };

if (skeleton.length === 0) {
return this.error(error_1.ErrorKind.EXPECT_DATE_TIME_SKELETON, location_1);
return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location_1);
}

@@ -566,13 +563,13 @@ var dateTimePattern = skeleton;

if (this.locale) {
dateTimePattern = (0, date_time_pattern_generator_1.getBestPattern)(skeleton, this.locale);
dateTimePattern = getBestPattern(skeleton, this.locale);
}
var style = {
type: types_1.SKELETON_TYPE.dateTime,
type: SKELETON_TYPE.dateTime,
pattern: dateTimePattern,
location: styleAndLocation.styleLocation,
parsedOptions: this.shouldParseSkeletons
? (0, icu_skeleton_parser_1.parseDateTimeSkeleton)(dateTimePattern)
? parseDateTimeSkeleton(dateTimePattern)
: {},
};
var type = argType === 'date' ? types_1.TYPE.date : types_1.TYPE.time;
var type = argType === 'date' ? TYPE.date : TYPE.time;
return {

@@ -588,6 +585,6 @@ val: { type: type, value: value, location: location_1, style: style },

type: argType === 'number'
? types_1.TYPE.number
? TYPE.number
: argType === 'date'
? types_1.TYPE.date
: types_1.TYPE.time,
? TYPE.date
: TYPE.time,
value: value,

@@ -609,3 +606,3 @@ location: location_1,

if (!this.bumpIf(',')) {
return this.error(error_1.ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, tslib_1.__assign({}, typeEndPosition_1)));
return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, __assign({}, typeEndPosition_1)));
}

@@ -625,6 +622,6 @@ this.bumpSpace();

if (!this.bumpIf(':')) {
return this.error(error_1.ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition()));
return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition()));
}
this.bumpSpace();
var result = this.tryParseDecimalInteger(error_1.ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, error_1.ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
if (result.err) {

@@ -650,3 +647,3 @@ return result;

val: {
type: types_1.TYPE.select,
type: TYPE.select,
value: value,

@@ -662,3 +659,3 @@ options: fromEntries(optionsResult.val),

val: {
type: types_1.TYPE.plural,
type: TYPE.plural,
value: value,

@@ -675,3 +672,3 @@ options: fromEntries(optionsResult.val),

default:
return this.error(error_1.ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
}

@@ -683,3 +680,3 @@ };

if (this.isEOF() || this.char() !== 125 /* `}` */) {
return this.error(error_1.ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
}

@@ -704,3 +701,3 @@ this.bump(); // `}`

if (!this.bumpUntil("'")) {
return this.error(error_1.ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition()));
return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition()));
}

@@ -740,14 +737,14 @@ this.bump();

try {
tokens = (0, icu_skeleton_parser_1.parseNumberSkeletonFromString)(skeleton);
tokens = parseNumberSkeletonFromString(skeleton);
}
catch (e) {
return this.error(error_1.ErrorKind.INVALID_NUMBER_SKELETON, location);
return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location);
}
return {
val: {
type: types_1.SKELETON_TYPE.number,
type: SKELETON_TYPE.number,
tokens: tokens,
location: location,
parsedOptions: this.shouldParseSkeletons
? (0, icu_skeleton_parser_1.parseNumberSkeleton)(tokens)
? parseNumberSkeleton(tokens)
: {},

@@ -782,3 +779,3 @@ },

// Try parse `={number}` selector
var result = this.tryParseDecimalInteger(error_1.ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, error_1.ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR);
var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR);
if (result.err) {

@@ -797,4 +794,4 @@ return result;

return this.error(parentArgType === 'select'
? error_1.ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR
: error_1.ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation);
? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR
: ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation);
}

@@ -811,4 +808,4 @@ if (selector === 'other') {

return this.error(parentArgType === 'select'
? error_1.ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT
: error_1.ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition()));
? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT
: ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition()));
}

@@ -838,7 +835,7 @@ var fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag);

return this.error(parentArgType === 'select'
? error_1.ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR
: error_1.ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition()));
? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR
: ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition()));
}
if (this.requiresOtherClause && !hasOtherClause) {
return this.error(error_1.ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
}

@@ -1009,3 +1006,3 @@ return { val: options, err: null };

}());
exports.Parser = Parser;
export { Parser };
/**

@@ -1012,0 +1009,0 @@ * This check if codepoint is alphabet (lower & uppercase)

@@ -1,31 +0,27 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.printDateTimeSkeleton = exports.doPrintAST = exports.printAST = void 0;
var tslib_1 = require("tslib");
var types_1 = require("./types");
function printAST(ast) {
import { __spreadArray } from "tslib";
import { isLiteralElement, isTagElement, isSelectElement, isArgumentElement, isDateElement, isTimeElement, isNumberElement, isPluralElement, TYPE, SKELETON_TYPE, isPoundElement, } from './types';
export function printAST(ast) {
return doPrintAST(ast, false);
}
exports.printAST = printAST;
function doPrintAST(ast, isInPlural) {
export function doPrintAST(ast, isInPlural) {
var printedNodes = ast.map(function (el, i) {
if ((0, types_1.isLiteralElement)(el)) {
if (isLiteralElement(el)) {
return printLiteralElement(el, isInPlural, i === 0, i === ast.length - 1);
}
if ((0, types_1.isArgumentElement)(el)) {
if (isArgumentElement(el)) {
return printArgumentElement(el);
}
if ((0, types_1.isDateElement)(el) || (0, types_1.isTimeElement)(el) || (0, types_1.isNumberElement)(el)) {
if (isDateElement(el) || isTimeElement(el) || isNumberElement(el)) {
return printSimpleFormatElement(el);
}
if ((0, types_1.isPluralElement)(el)) {
if (isPluralElement(el)) {
return printPluralElement(el);
}
if ((0, types_1.isSelectElement)(el)) {
if (isSelectElement(el)) {
return printSelectElement(el);
}
if ((0, types_1.isPoundElement)(el)) {
if (isPoundElement(el)) {
return '#';
}
if ((0, types_1.isTagElement)(el)) {
if (isTagElement(el)) {
return printTagElement(el);

@@ -36,3 +32,2 @@ }

}
exports.doPrintAST = doPrintAST;
function printTagElement(el) {

@@ -64,3 +59,3 @@ return "<".concat(el.value, ">").concat(printAST(el.children), "</").concat(el.value, ">");

function printSimpleFormatElement(el) {
return "{".concat(el.value, ", ").concat(types_1.TYPE[el.type]).concat(el.style ? ", ".concat(printArgumentStyle(el.style)) : '', "}");
return "{".concat(el.value, ", ").concat(TYPE[el.type]).concat(el.style ? ", ".concat(printArgumentStyle(el.style)) : '', "}");
}

@@ -77,3 +72,3 @@ function printNumberSkeletonToken(token) {

}
else if (style.type === types_1.SKELETON_TYPE.dateTime) {
else if (style.type === SKELETON_TYPE.dateTime) {
return "::".concat(printDateTimeSkeleton(style));

@@ -85,6 +80,5 @@ }

}
function printDateTimeSkeleton(style) {
export function printDateTimeSkeleton(style) {
return style.pattern;
}
exports.printDateTimeSkeleton = printDateTimeSkeleton;
function printSelectElement(el) {

@@ -105,3 +99,3 @@ var msg = [

type,
tslib_1.__spreadArray([
__spreadArray([
el.offset ? "offset:".concat(el.offset) : ''

@@ -108,0 +102,0 @@ ], Object.keys(el.options).map(function (id) { return "".concat(id, "{").concat(doPrintAST(el.options[id].value, true), "}"); }), true).filter(Boolean)

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WHITE_SPACE_REGEX = exports.SPACE_SEPARATOR_REGEX = void 0;
// @generated from regex-gen.ts
exports.SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
exports.WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/;
export var SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
export var WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/;

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.timeData = void 0;
// @generated from time-data-gen.ts
// prettier-ignore
exports.timeData = {
export var timeData = {
"001": [

@@ -8,0 +5,0 @@ "H",

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createNumberElement = exports.createLiteralElement = exports.isDateTimeSkeleton = exports.isNumberSkeleton = exports.isTagElement = exports.isPoundElement = exports.isPluralElement = exports.isSelectElement = exports.isTimeElement = exports.isDateElement = exports.isNumberElement = exports.isArgumentElement = exports.isLiteralElement = exports.SKELETON_TYPE = exports.TYPE = void 0;
var TYPE;
export var TYPE;
(function (TYPE) {

@@ -43,56 +40,45 @@ /**

TYPE[TYPE["tag"] = 8] = "tag";
})(TYPE || (exports.TYPE = TYPE = {}));
var SKELETON_TYPE;
})(TYPE || (TYPE = {}));
export var SKELETON_TYPE;
(function (SKELETON_TYPE) {
SKELETON_TYPE[SKELETON_TYPE["number"] = 0] = "number";
SKELETON_TYPE[SKELETON_TYPE["dateTime"] = 1] = "dateTime";
})(SKELETON_TYPE || (exports.SKELETON_TYPE = SKELETON_TYPE = {}));
})(SKELETON_TYPE || (SKELETON_TYPE = {}));
/**
* Type Guards
*/
function isLiteralElement(el) {
export function isLiteralElement(el) {
return el.type === TYPE.literal;
}
exports.isLiteralElement = isLiteralElement;
function isArgumentElement(el) {
export function isArgumentElement(el) {
return el.type === TYPE.argument;
}
exports.isArgumentElement = isArgumentElement;
function isNumberElement(el) {
export function isNumberElement(el) {
return el.type === TYPE.number;
}
exports.isNumberElement = isNumberElement;
function isDateElement(el) {
export function isDateElement(el) {
return el.type === TYPE.date;
}
exports.isDateElement = isDateElement;
function isTimeElement(el) {
export function isTimeElement(el) {
return el.type === TYPE.time;
}
exports.isTimeElement = isTimeElement;
function isSelectElement(el) {
export function isSelectElement(el) {
return el.type === TYPE.select;
}
exports.isSelectElement = isSelectElement;
function isPluralElement(el) {
export function isPluralElement(el) {
return el.type === TYPE.plural;
}
exports.isPluralElement = isPluralElement;
function isPoundElement(el) {
export function isPoundElement(el) {
return el.type === TYPE.pound;
}
exports.isPoundElement = isPoundElement;
function isTagElement(el) {
export function isTagElement(el) {
return el.type === TYPE.tag;
}
exports.isTagElement = isTagElement;
function isNumberSkeleton(el) {
export function isNumberSkeleton(el) {
return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.number);
}
exports.isNumberSkeleton = isNumberSkeleton;
function isDateTimeSkeleton(el) {
export function isDateTimeSkeleton(el) {
return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.dateTime);
}
exports.isDateTimeSkeleton = isDateTimeSkeleton;
function createLiteralElement(value) {
export function createLiteralElement(value) {
return {

@@ -103,4 +89,3 @@ type: TYPE.literal,

}
exports.createLiteralElement = createLiteralElement;
function createNumberElement(value, style) {
export function createNumberElement(value, style) {
return {

@@ -112,2 +97,1 @@ type: TYPE.number,

}
exports.createNumberElement = createNumberElement;
MIT License
Copyright (c) 2021 FormatJS
Copyright (c) 2023 FormatJS

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

{
"name": "@formatjs/icu-messageformat-parser",
"version": "2.7.2",
"version": "2.7.3",
"main": "index.js",

@@ -15,5 +15,5 @@ "module": "lib/index.js",

"tslib": "^2.4.0",
"@formatjs/ecma402-abstract": "1.17.4",
"@formatjs/icu-skeleton-parser": "1.6.4"
"@formatjs/ecma402-abstract": "1.18.0",
"@formatjs/icu-skeleton-parser": "1.7.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