🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

messageformat

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

messageformat - npm Package Compare versions

Comparing version

to
4.0.0-11

3

lib/formatted-parts.d.ts

@@ -32,3 +32,2 @@ import type { MessageDateTimePart } from './functions/datetime.ts';

type: P;
source: string;
dir?: 'ltr' | 'rtl';

@@ -39,3 +38,2 @@ locale?: string;

type: string;
source?: string;
value?: unknown;

@@ -58,3 +56,2 @@ }>;

kind: 'open' | 'standalone' | 'close';
source: string;
name: string;

@@ -61,0 +58,0 @@ id?: string;

@@ -27,3 +27,2 @@ import type { MessageExpressionPart } from '../formatted-parts.ts';

type: 'datetime';
source: string;
locale: string;

@@ -30,0 +29,0 @@ parts: Intl.DateTimeFormatPart[];

10

lib/functions/datetime.js

@@ -132,3 +132,3 @@ import { getLocaleDir } from "../dir-utils.js";

function dateTimeImplementation(ctx, input, parseOptions) {
const { localeMatcher, locales, source } = ctx;
const { localeMatcher, locales } = ctx;
const opt = { localeMatcher };

@@ -154,3 +154,3 @@ if (input && typeof input === 'object') {

const msg = 'Input is not a date';
throw new MessageResolutionError('bad-operand', msg, source);
throw new MessageResolutionError('bad-operand', msg, ctx.source);
}

@@ -165,3 +165,3 @@ parseOptions(opt);

type: 'datetime',
source,
source: ctx.source,
get dir() {

@@ -183,4 +183,4 @@ if (dir == null) {

return dir === 'ltr' || dir === 'rtl'
? [{ type: 'datetime', source, dir, locale, parts }]
: [{ type: 'datetime', source, locale, parts }];
? [{ type: 'datetime', dir, locale, parts }]
: [{ type: 'datetime', locale, parts }];
},

@@ -187,0 +187,0 @@ toString() {

@@ -35,3 +35,2 @@ import type { MessageExpressionPart } from '../formatted-parts.ts';

type: 'number';
source: string;
locale: string;

@@ -38,0 +37,0 @@ parts: Intl.NumberFormatPart[];

@@ -28,3 +28,3 @@ import { getLocaleDir } from "../dir-utils.js";

export function getMessageNumber(ctx, value, options, canSelect) {
let { dir, locales, source } = ctx;
let { dir, locales } = ctx;
// @ts-expect-error We may have been a bit naughty earlier.

@@ -37,3 +37,3 @@ if (options.useGrouping === 'never')

const msg = 'The option select may only be set by a literal value';
ctx.onError(new MessageResolutionError('bad-option', msg, source));
ctx.onError(new MessageResolutionError('bad-option', msg, ctx.source));
canSelect = false;

@@ -47,3 +47,3 @@ }

type: 'number',
source,
source: ctx.source,
get dir() {

@@ -80,4 +80,4 @@ if (dir == null) {

return dir === 'ltr' || dir === 'rtl'
? [{ type: 'number', source, dir, locale, parts }]
: [{ type: 'number', source, locale, parts }];
? [{ type: 'number', dir, locale, parts }]
: [{ type: 'number', locale, parts }];
},

@@ -84,0 +84,0 @@ toString() {

@@ -24,3 +24,2 @@ import type { MessageExpressionPart } from '../formatted-parts.ts';

type: 'string';
source: string;
locale: string;

@@ -27,0 +26,0 @@ value: string;

@@ -10,7 +10,7 @@ export function string(ctx, _options, operand) {

toParts() {
const { dir, source } = ctx;
const { dir } = ctx;
const locale = ctx.locales[0];
return dir === 'ltr' || dir === 'rtl'
? [{ type: 'string', source, dir, locale, value: str }]
: [{ type: 'string', source, locale, value: str }];
? [{ type: 'string', dir, locale, value: str }]
: [{ type: 'string', locale, value: str }];
},

@@ -17,0 +17,0 @@ toString: () => str,

@@ -11,4 +11,3 @@ import { MessageError, MessageResolutionError } from "../errors.js";

export function unit(ctx, exprOpt, operand) {
const { source } = ctx;
const input = readNumericOperand(operand, source);
const input = readNumericOperand(operand, ctx.source);
const options = Object.assign({}, input.options, {

@@ -50,3 +49,3 @@ localeMatcher: ctx.localeMatcher,

const msg = `Value ${optval} is not valid for :currency option ${name}`;
ctx.onError(new MessageResolutionError('bad-option', msg, source));
ctx.onError(new MessageResolutionError('bad-option', msg, ctx.source));
}

@@ -57,5 +56,5 @@ }

const msg = 'A unit identifier is required for :unit';
throw new MessageResolutionError('bad-operand', msg, source);
throw new MessageResolutionError('bad-operand', msg, ctx.source);
}
return getMessageNumber(ctx, input.value, options, false);
}

@@ -14,5 +14,4 @@ import type { MessageExpressionPart } from '../formatted-parts.ts';

type: 'unknown';
source: string;
value: unknown;
}
export declare const unknown: (source: string, input: unknown) => MessageUnknownValue;

@@ -5,5 +5,5 @@ export const unknown = (source, input) => ({

dir: 'auto',
toParts: () => [{ type: 'unknown', source, value: input }],
toParts: () => [{ type: 'unknown', value: input }],
toString: () => String(input),
valueOf: () => input
});

@@ -102,3 +102,3 @@ import type { Message } from './data-model/types.ts';

* { type: 'bidiIsolation', value: '\u2068' },
* { type: 'string', source: '$user.name', locale: 'en', value: 'Kat' },
* { type: 'string', locale: 'en', value: 'Kat' },
* { type: 'bidiIsolation', value: '\u2069' },

@@ -108,3 +108,2 @@ * { type: 'text', value: ', today is ' },

* type: 'datetime',
* source: '$date',
* dir: 'ltr',

@@ -111,0 +110,0 @@ * locale: 'en',

@@ -120,3 +120,3 @@ import { parseMessage } from "./data-model/parse.js";

* { type: 'bidiIsolation', value: '\u2068' },
* { type: 'string', source: '$user.name', locale: 'en', value: 'Kat' },
* { type: 'string', locale: 'en', value: 'Kat' },
* { type: 'bidiIsolation', value: '\u2069' },

@@ -126,3 +126,2 @@ * { type: 'text', value: ', today is ' },

* type: 'datetime',
* source: '$date',
* dir: 'ltr',

@@ -129,0 +128,0 @@ * locale: 'en',

import { MessageResolutionError } from "../errors.js";
import { getValueSource, resolveValue } from "./resolve-value.js";
export function formatMarkup(ctx, { kind, name, options }) {
const source = kind === 'close' ? `/${name}` : kind === 'open' ? `#${name}` : `#${name}/`;
const part = { type: 'markup', kind, source, name };
const part = { type: 'markup', kind, name };
if (options?.size) {

@@ -7,0 +6,0 @@ part.options = {};

{
"name": "messageformat",
"version": "4.0.0-10",
"version": "4.0.0-11",
"description": "Intl.MessageFormat / Unicode MessageFormat 2 parser, runtime and polyfill",

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