Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Authors: @jneen and @laughinghan
Maintainer: @wavebeem
Parsimmon is a small library for writing big parsers made up of lots of little parsers. The API is inspired by parsec and Promises/A+.
Parsimmon supports IE7 and newer browsers, along with Node.js. It can be used as a standard Node module through npm (named parsimmon
), or directly in the browser through a script tag, where it exports a global variable called Parsimmon
. To download the latest browser build, use the unpkg version. For more information on how to use unpkg, see the unpkg homepage.
Full API documentation in API.md
.
See the examples directory for annotated examples of parsing JSON, Lisp, and math.
A Parsimmon parser is an object that represents an action on a stream of text, and the promise of either an object yielded by that action on success or a message in case of failure. For example, Parsimmon.string('foo')
yields the string 'foo'
if the beginning of the stream is 'foo'
, and otherwise fails.
The method .map
is used to transform the yielded value. For example,
Parsimmon.string('foo')
.map(function(x) { return x + 'bar'; })
will yield 'foobar'
if the stream starts with 'foo'
. The parser
Parsimmon.regexp(/[0-9]+/)
.map(function(x) { return Number(x) * 2; })
will yield the number 24
when it encounters the string '12'
.
Calling .parse(string)
on a parser parses the string and returns an object with a boolean status
flag, indicating whether the parse succeeded. If it succeeded, the value
attribute will contain the yielded value. Otherwise, the index
and expected
attributes will contain the index of the parse error (with offset
, line
and column
properties), and a sorted, unique array of messages indicating what was expected.
The error object can be passed along with the original source to Parsimmon.formatError(source, error)
to obtain a human-readable error string.
Feel free to ask a question by filing a GitHub Issue. I'm happy to help point you in the right direction with the library, and hopefully improve the documentation so less people get confused in the future.
Contributions are not just pull requests. Issues clearly describing bugs or confusing parts of Parsimmon are welcome! Also, documentation enhancements and examples are very desirable. Feeling overwhelmed about contributing? Open an issue about what you want to contribute and I'm happy to help you through to completion!
Thanks to @bd82 we have a good benchmark comparing Parsimmon CPU performance to several other parser libraries with a simple JSON parser example.
Parsimmon is also compatible with fantasyland. It is a Semigroup, an Applicative Functor, and a Monad.
1.2.0 (2016-12-22)
Parsimmon.lookahead(parser)
parser.lookahead(anotherParser)
FAQs
A monadic LL(infinity) parser combinator library
The npm package parsimmon receives a total of 82,785 weekly downloads. As such, parsimmon popularity was classified as popular.
We found that parsimmon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.