Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bread-n-butter

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bread-n-butter - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

10

CHANGELOG.md

@@ -8,2 +8,10 @@ # Changelog

## [0.4.0] - 2020-08-13
### Added
- Method `parser.skip`
- Method `parser.next`
- Function `bnb.choice(...parsers)`
## [0.3.0] - 2020-08-12

@@ -45,3 +53,1 @@

## Unreleased
Nothing, yet

@@ -27,2 +27,6 @@ /**

and<B>(parserB: Parser<B>): Parser<[A, B]>;
/** Parse both and return the value of the first */
skip<B>(parserB: Parser<B>): Parser<A>;
/** Parse both and return the value of the second */
next<B>(parserB: Parser<B>): Parser<B>;
/**

@@ -125,2 +129,4 @@ * Try to parse using the current parser. If that fails, parse using the

export declare function all<A extends any[]>(...parsers: ManyParsers<A>): Parser<A>;
/** Parse using the parsers given, returning the first one that succeeds. */
export declare function choice<A>(...parsers: Parser<A>[]): Parser<A>;
/**

@@ -127,0 +133,0 @@ * Takes a lazily invoked callback that returns a parser, so you can create

19

dist/cjs/bread-n-butter.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.lazy = exports.all = exports.match = exports.text = exports.eof = exports.fail = exports.ok = exports.location = exports.Parser = void 0;
exports.lazy = exports.choice = exports.all = exports.match = exports.text = exports.eof = exports.fail = exports.ok = exports.location = exports.Parser = void 0;
/**

@@ -66,2 +66,10 @@ * Represents a parsing action; typically not created directly via `new`.

}
/** Parse both and return the value of the first */
skip(parserB) {
return this.and(parserB).map(([a]) => a);
}
/** Parse both and return the value of the second */
next(parserB) {
return this.and(parserB).map(([, b]) => b);
}
/**

@@ -291,2 +299,11 @@ * Try to parse using the current parser. If that fails, parse using the

exports.all = all;
/** Parse using the parsers given, returning the first one that succeeds. */
function choice(...parsers) {
// TODO: This could be optimized with a custom parser, but I should probably add
// benchmarking first to see if it really matters enough to rewrite it
return parsers.reduce((acc, p) => {
return acc.or(p);
});
}
exports.choice = choice;
/**

@@ -293,0 +310,0 @@ * Takes a lazily invoked callback that returns a parser, so you can create

@@ -27,2 +27,6 @@ /**

and<B>(parserB: Parser<B>): Parser<[A, B]>;
/** Parse both and return the value of the first */
skip<B>(parserB: Parser<B>): Parser<A>;
/** Parse both and return the value of the second */
next<B>(parserB: Parser<B>): Parser<B>;
/**

@@ -125,2 +129,4 @@ * Try to parse using the current parser. If that fails, parse using the

export declare function all<A extends any[]>(...parsers: ManyParsers<A>): Parser<A>;
/** Parse using the parsers given, returning the first one that succeeds. */
export declare function choice<A>(...parsers: Parser<A>[]): Parser<A>;
/**

@@ -127,0 +133,0 @@ * Takes a lazily invoked callback that returns a parser, so you can create

@@ -63,2 +63,10 @@ /**

}
/** Parse both and return the value of the first */
skip(parserB) {
return this.and(parserB).map(([a]) => a);
}
/** Parse both and return the value of the second */
next(parserB) {
return this.and(parserB).map(([, b]) => b);
}
/**

@@ -282,2 +290,10 @@ * Try to parse using the current parser. If that fails, parse using the

}
/** Parse using the parsers given, returning the first one that succeeds. */
export function choice(...parsers) {
// TODO: This could be optimized with a custom parser, but I should probably add
// benchmarking first to see if it really matters enough to rewrite it
return parsers.reduce((acc, p) => {
return acc.or(p);
});
}
/**

@@ -284,0 +300,0 @@ * Takes a lazily invoked callback that returns a parser, so you can create

{
"name": "bread-n-butter",
"version": "0.3.0",
"version": "0.4.0",
"description": "Parser combinators for JavaScript and TypeScript",

@@ -5,0 +5,0 @@ "main": "dist/cjs/bread-n-butter.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc