
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
format-message-parse
Advanced tools
Parse ICU MessageFormat pattern strings to a compact ast
Turns a ICU Message Format string:
`You have {
numBananas, plural,
=0 {no bananas}
one {a banana}
other {# bananas}
} for sale`
into a compact format-message ast:
[ "You have ", [ "numBananas", "plural", 0, {
"=0": [ "no bananas" ],
"one": [ "a banana" ],
"other": [ [ '#' ], " bananas" ]
} ], " for sale." ]
npm install format-message-parse --save
import parse from 'format-message-parse'
import interpret from 'format-message-interpret'
interpret('en', parse('Hello, {name}!'))({ name: 'Jane' })
parse(pattern: string, tokens?: ?Token[]): ASTGenerate a compact array-based AST from an ICU MessageFormat string pattern. If an empty tokens array is passed in, it will be filled with found tokens.
This can throw a SyntaxError if the pattern is not valid. The offset property of the error lets you know how far into the pattern tokenization was able to go before the error. The tokens array will have all the found tokens up until the bad syntax.
Note that the only semantic validation done in parsing is ensuring that select, selectordinal, and plural include an other sub-message. It does not validate that a plural keyword applies to the locale, or that a style is supported by the type, or even that the type will be supported by the interpreter. Successful parsing is not a guarantee the final message will format as expected.
SyntaxErrorclass SyntaxError extends Error {
name: 'SyntaxError';
message: string;
expected: ?string;
found: ?string;
offset: number;
line: number;
column: number;
}
This software is free to use under the MIT license. See the LICENSE-MIT file for license text and copyright information.
FAQs
Parse ICU MessageFormat pattern strings to a compact ast
The npm package format-message-parse receives a total of 5,335 weekly downloads. As such, format-message-parse popularity was classified as popular.
We found that format-message-parse demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.