MCPcopy
hub / github.com/formatjs/formatjs / parse

Function parse

packages/icu-messageformat-parser/index.ts:39–62  ·  view source on GitHub ↗
(
  message: string,
  opts: ParserOptions = {}
)

Source from the content-addressed store, hash-verified

37}
38
39export function parse(
40 message: string,
41 opts: ParserOptions = {}
42): MessageFormatElement[] {
43 opts = {
44 shouldParseSkeletons: true,
45 requiresOtherClause: true,
46 ...opts,
47 }
48 const result = new Parser(message, opts).parse()
49 if (result.err) {
50 const error = SyntaxError(ErrorKind[result.err.kind])
51 // @ts-expect-error Assign to error object
52 error.location = result.err.location
53 // @ts-expect-error Assign to error object
54 error.originalMessage = result.err.message
55 throw error
56 }
57
58 if (!opts?.captureLocation) {
59 pruneLocation(result.val)
60 }
61 return result.val
62}
63export * from '#packages/icu-messageformat-parser/types.js'
64export type {ParserOptions}
65// only for testing

Callers 15

processDescriptorFunction · 0.90
MessageFunction · 0.90
extractMessageDescriptorFunction · 0.90
setAttributesInObjectFunction · 0.90
generateNewPropertiesFunction · 0.90
getICUMessageValueFunction · 0.90
visitorFunction · 0.90
processMessageObjectFunction · 0.90
generateXXLSFunction · 0.90
generateXXACFunction · 0.90

Calls 2

pruneLocationFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected