intl-messageformat-parser
- Version 6.4.4
- Published
- 306 kB
- 2 dependencies
- BSD-3-Clause license
Install
npm i intl-messageformat-parseryarn add intl-messageformat-parserpnpm add intl-messageformat-parserOverview
Parses ICU Message strings into an AST via JavaScript.
Index
Variables
Functions
Classes
Interfaces
Enums
Type Aliases
Variables
variable pegParse
const pegParse: ParseFunction;Functions
function createLiteralElement
createLiteralElement: (value: string) => LiteralElement;function createNumberElement
createNumberElement: (value: string, style?: string | null) => NumberElement;function isArgumentElement
isArgumentElement: (el: MessageFormatElement) => el is ArgumentElement;function isDateElement
isDateElement: (el: MessageFormatElement) => el is DateElement;function isDateTimeSkeleton
isDateTimeSkeleton: ( el?: DateElement['style'] | TimeElement['style'] | Skeleton) => el is DateTimeSkeleton;function isLiteralElement
isLiteralElement: (el: MessageFormatElement) => el is LiteralElement;Type Guards
function isNumberElement
isNumberElement: (el: MessageFormatElement) => el is NumberElement;function isNumberSkeleton
isNumberSkeleton: ( el: NumberElement['style'] | Skeleton) => el is NumberSkeleton;function isPluralElement
isPluralElement: (el: MessageFormatElement) => el is PluralElement;function isPoundElement
isPoundElement: (el: MessageFormatElement) => el is PoundElement;function isSelectElement
isSelectElement: (el: MessageFormatElement) => el is SelectElement;function isTagElement
isTagElement: (el: MessageFormatElement) => el is TagElement;function isTimeElement
isTimeElement: (el: MessageFormatElement) => el is TimeElement;function parse
parse: (input: string, opts?: ParseOptions) => MessageFormatElement[];Classes
class SyntaxError
class SyntaxError extends Error {}constructor
constructor( message: string, expected: Expectation[], found: string, location: IFileRange);property expected
expected: Expectation[];property found
found: string;property location
location: IFileRange;property message
message: string;property name
name: string;method buildMessage
static buildMessage: (expected: Expectation[], found: string | null) => string;Interfaces
interface BaseElement
interface BaseElement<T extends TYPE> {}interface DateTimeSkeleton
interface DateTimeSkeleton {}property location
location?: Location;property parsedOptions
parsedOptions: Intl.DateTimeFormatOptions;property pattern
pattern: string;property type
type: SKELETON_TYPE.dateTime;interface ExtendedNumberFormatOptions
interface ExtendedNumberFormatOptions extends NumberFormatOptions {}property scale
scale?: number;interface IAnyExpectation
interface IAnyExpectation {}property type
type: 'any';interface IClassExpectation
interface IClassExpectation {}property ignoreCase
ignoreCase: boolean;property inverted
inverted: boolean;property parts
parts: IClassParts;property type
type: 'class';interface IClassParts
interface IClassParts extends Array<string | IClassParts> {}interface IEndExpectation
interface IEndExpectation {}property type
type: 'end';interface IFilePosition
interface IFilePosition {}interface IFileRange
interface IFileRange {}interface ILiteralExpectation
interface ILiteralExpectation {}interface IOtherExpectation
interface IOtherExpectation {}property description
description: string;property type
type: 'other';interface IParseOptions
interface IParseOptions {}property filename
filename?: string;property startRule
startRule?: string;property tracer
tracer?: any;index signature
[key: string]: any;interface Location
interface Location {}interface LocationDetails
interface LocationDetails {}interface NumberSkeleton
interface NumberSkeleton {}property location
location?: Location;property parsedOptions
parsedOptions: ExtendedNumberFormatOptions;property tokens
tokens: NumberSkeletonToken[];property type
type: SKELETON_TYPE.number;interface NumberSkeletonToken
interface NumberSkeletonToken {}interface Options
interface Options {}property captureLocation
captureLocation?: boolean;Capture location info in AST Default is false
property ignoreTag
ignoreTag?: boolean;Whether to treat HTML/XML tags as string literal instead of parsing them as tag token. When this is false we only allow simple tags without any attributes
property normalizeHashtagInPlural
normalizeHashtagInPlural?: boolean;Whether to convert
#in plural rule options to{var, number}Default is true
property shouldParseSkeletons
shouldParseSkeletons?: boolean;Whether to parse number/datetime skeleton into Intl.NumberFormatOptions & Intl.DateTimeFormatOptions
interface PluralElement
interface PluralElement extends BaseElement<TYPE.plural> {}property offset
offset: number;property options
options: Record<ValidPluralRule, PluralOrSelectOption>;property pluralType
pluralType: Intl.PluralRulesOptions['type'];interface PluralOrSelectOption
interface PluralOrSelectOption {}interface PoundElement
interface PoundElement {}interface SelectElement
interface SelectElement extends BaseElement<TYPE.select> {}property options
options: Record<string, PluralOrSelectOption>;interface SelectOption
interface SelectOption {}interface SimpleFormatElement
interface SimpleFormatElement<T extends TYPE, S extends Skeleton> extends BaseElement<T> {}property style
style?: string | S | null;interface TagElement
interface TagElement {}Enums
enum SKELETON_TYPE
enum SKELETON_TYPE { number = 0, dateTime = 1,}enum TYPE
enum TYPE { literal = 0, argument = 1, number = 2, date = 3, time = 4, select = 5, plural = 6, pound = 7, tag = 8,}member argument
argument = 1Variable w/o any format, e.g
varinthis is a {var}
member date
date = 3Variable w/ date format
member literal
literal = 0Raw text
member number
number = 2Variable w/ number format
member plural
plural = 6Variable w/ plural format
member pound
pound = 7Only possible within plural argument. This is the
#symbol that will be substituted with the count.
member select
select = 5Variable w/ select format
member tag
tag = 8XML-like tag
member time
time = 4Variable w/ time format
Type Aliases
type ArgumentElement
type ArgumentElement = BaseElement<TYPE.argument>;type DateElement
type DateElement = SimpleFormatElement<TYPE.date, DateTimeSkeleton>;type Expectation
type Expectation = | ILiteralExpectation | IClassExpectation | IAnyExpectation | IEndExpectation | IOtherExpectation;type LiteralElement
type LiteralElement = BaseElement<TYPE.literal>;type MessageFormatElement
type MessageFormatElement = | LiteralElement | ArgumentElement | NumberElement | DateElement | TimeElement | SelectElement | PluralElement | TagElement | PoundElement;type NumberElement
type NumberElement = SimpleFormatElement<TYPE.number, NumberSkeleton>;type ParseFunction
type ParseFunction = ( input: string, options?: IParseOptions) => MessageFormatElement[];type ParseOptions
type ParseOptions = Options & IParseOptions;type Skeleton
type Skeleton = NumberSkeleton | DateTimeSkeleton;type TimeElement
type TimeElement = SimpleFormatElement<TYPE.time, DateTimeSkeleton>;type ValidPluralRule
type ValidPluralRule = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other' | string;Package Files (3)
Dependencies (2)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/intl-messageformat-parser.
- Markdown[](https://www.jsdocs.io/package/intl-messageformat-parser)
- HTML<a href="https://www.jsdocs.io/package/intl-messageformat-parser"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 5162 ms. - Missing or incorrect documentation? Open an issue for this package.
