
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
fruitsconfits
Advanced tools
FruitsConfits - A well typed and sugared parser combinator framework for TypeScript/JavaScript.
npm install fruitsconfits
NOTICE:
Use withwebpack >= 5If you get the error:
Module not found: Error: Can't resolve '(importing/path/to/filename)' in '(path/to/node_modules/path/to/dirname)' Did you mean '(filename).js'?`Add following setting to your
webpack.config.js.{ test: /\.m?js/, resolve: { fullySpecified: false, }, },On
webpack >= 5, the extension in the request is mandatory for it to be fully specified if the origin is a '.mjs' file or a '.js' file where the package.json contains '"type": "module"'.
See CHANGELOG.md.
Get the string parser generators.
export function getStringParsers<C, R>(
params: {
rawToToken: (rawToken: string) => R,
concatTokens: (tokens: R[]) => R[],
});
rawToToken : function to convert string token to AST element.concatTokens : function to merge two AST elements into one AST element.returns an object that containing the parsers.
seq(needle: string)
needlecls(...needles: string[])
needlesnotCls(...needles: string[])
needlesclsFn(needle: (src: string) => number)
needle
alpha
upper
lower
num
nonzero
0bin
oct
hex
alnum
space
spaceWithinSingleLine
ctrl
newline
word
any
bin(...prefixes: StringParserFnWithCtx<C, R>[])
oct(...prefixes: StringParserFnWithCtx<C, R>[])
hex(...prefixes: StringParserFnWithCtx<C, R>[])
int
bigint
float
isParam(criteria: (o: any) => boolean, conv?: (o: any) => any)
cat(...parsers: StringParserFnWithCtx<C, R>[])
parsersonce(parser: StringParserFnWithCtx<C, R>)
parserrepeat(parser: StringParserFnWithCtx<C, R>)
parserqty(min?: number, max?: number) => (parser: StringParserFnWithCtx<C, R>)
parser
repeat parserzeroWidth(helper?: () => R)
helpererr(message: string)
messagebeginning(helper?: () => R)
helperend(helper?: () => R)
helperfirst(...parsers: StringParserFnWithCtx<C, R>[])
parsersor(...parsers: StringParserFnWithCtx<C, R>[])
parserscombine(...parsers: StringParserFnWithCtx<C, R>[])
parserserase(...parsers: StringParserFnWithCtx<C, R>[])
parsers and return empty result []trans(fn: (tokens: R[]) => R[]) => (...parsers: StringParserFnWithCtx<C, R>[])
parsers and transform the result by fnahead(...parsers: StringParserFnWithCtx<C, R>[])
parsersbehind(n: number, helper?: () => R)(...parsers: StringParserFnWithCtx<C, R>[])
parsers and return result that is provided by helperrules(args: ApplyProductionRulesArg<string, C, R>) => (lexer: StringParserFnWithCtx<C, R>)
args
makeProgram
ParseError thrown to a return valueGet the object list parser generators.
export function getObjectParsers<T extends ArrayLike<T[number]>, C, R>(
params: {
rawToToken: (rawToken: T[number]) => R,
concatTokens: (tokens: R[]) => R[],
comparator: (a: T[number], b: T[number]) => boolean,
});
rawToToken : function to convert the input object list item to AST element.concatTokens : function to merge two AST elements into one AST element.comparator : function to compare two input object list items.returns an object that containing the parsers.
seq(needle: T)
needlecls(...needles: T[number][])
needlesnotCls(...needles: T[number][])
needlesclsFn(needle: (src: T[number]) => boolean)
needle
any
cat(...parsers: ParserFnWithCtx<T, C, R>[])
parsersonce(parser: ParserFnWithCtx<T, C, R>)
parserrepeat(parser: ParserFnWithCtx<T, C, R>)
parserqty(min?: number, max?: number) => (parser: ParserFnWithCtx<T, C, R>)
parser
repeat parserzeroWidth(helper?: () => R)
helpererr(message: string)
messagebeginning(helper?: () => R)
helperend(helper?: () => R)
helperfirst(...parsers: ParserFnWithCtx<T, C, R>[])
parsersor(...parsers: ParserFnWithCtx<T, C, R>[])
parserscombine(...parsers: ParserFnWithCtx<T, C, R>[])
parserserase(...parsers: ParserFnWithCtx<T, C, R>[])
parsers and return empty result []trans(fn: (tokens: R[]) => R[]) => (...parsers: ParserFnWithCtx<T, C, R>[])
parsers and transform the result by fnahead(...parsers: ParserFnWithCtx<T, C, R>[])
parsersbehind(n: number, helper?: () => R)(...parsers: ParserFnWithCtx<T, C, R>[])
parsers and return result that is provided by helperrules(args: ApplyProductionRulesArg<T, C, R>) => (lexer: ParserFnWithCtx<T, C, R>)
args
makeProgram
ParseError thrown to a return valueBuild a parser input.
Example:
...
const program = makeProgram(trans(tokens => tokens)(
erase(repeat(commentOrSpace)),
first(listValue, objectValue, constExpr(end())),
erase(repeat(commentOrSpace)),
end(), ));
export function parse(s: string) {
const z = program(parserInput(s));
if (! z.succeeded) {
throw new Error(formatErrorMessage(z));
}
return z.tokens[0].value;
}
Build a parser input from ES6 template strings.
Example:
const program = makeProgram(combine(
seq('Hello,'),
isParam(o => String(o) === 'world'),
seq('!'),
end(), ));
export function parse(strings: TemplateStringsArray, ...values: any[]) {
const z = program(templateStringsParserInput(strings, values));
if (! z.succeeded) {
throw new Error(formatErrorMessage(z));
}
return z.tokens;
}
ISC
Copyright (c) 2019 Shellyl_N and Authors.
FAQs
FruitsConfits - A well typed and sugared parser combinator framework for TypeScript/JavaScript.
The npm package fruitsconfits receives a total of 50 weekly downloads. As such, fruitsconfits popularity was classified as not popular.
We found that fruitsconfits demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.