bread-n-butter
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -1,18 +0,45 @@ | ||
# v0.2.0 (2020-07-28) | ||
# Changelog | ||
- Exports interface `SourceLocation` | ||
- Exports interfaces `ActionResult`, `ActionOK`, `ActionFail` | ||
- Exports interfaces `ParseOK`, `ParseFail` | ||
- Exports class `Context` | ||
All notable changes to this project will be documented in this file. | ||
# v0.1.0 (2020-07-28) | ||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
- Adds ES Modules build | ||
## [0.3.0] - 2020-08-12 | ||
# v0.0.2 (2020-07-27) | ||
### Added | ||
- Fixes a bug where `parser.many1` was equivalent to `parser.many0` | ||
- Function `bnb.all` (thanks [@sveyret] for the type signature) | ||
# v0.0.1 (2020-07-26) | ||
## [0.2.0] - 2020-07-28 | ||
### Added | ||
- Interface `SourceLocation` | ||
- Interfaces `ActionResult`, `ActionOK`, `ActionFail` | ||
- Interfaces `ParseOK`, `ParseFail` | ||
- Class `Context` | ||
## [0.1.0] - 2020-07-28 | ||
### Added | ||
- ES Modules build | ||
## [0.0.2] - 2020-07-27 | ||
### Fixed | ||
- `parser.many1` was equivalent to `parser.many0` | ||
## [0.0.1] - 2020-07-26 | ||
### Added | ||
- Initial release | ||
[@sveyret]: https://github.com/sveyret | ||
## Unreleased | ||
Nothing, yet |
@@ -118,2 +118,8 @@ /** | ||
export declare function match(regexp: RegExp): Parser<string>; | ||
/** A tuple of parsers */ | ||
declare type ManyParsers<A extends any[]> = { | ||
[P in keyof A]: Parser<A[P]>; | ||
}; | ||
/** Parse all items, returning their values in the same order. */ | ||
export declare function all<A extends any[]>(...parsers: ManyParsers<A>): Parser<A>; | ||
/** | ||
@@ -120,0 +126,0 @@ * Takes a lazily invoked callback that returns a parser, so you can create |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lazy = exports.match = exports.text = exports.eof = exports.fail = exports.ok = exports.location = exports.Parser = void 0; | ||
exports.lazy = exports.all = exports.match = exports.text = exports.eof = exports.fail = exports.ok = exports.location = exports.Parser = void 0; | ||
/** | ||
@@ -276,2 +276,16 @@ * Represents a parsing action; typically not created directly via `new`. | ||
exports.match = match; | ||
/** Parse all items, returning their values in the same order. */ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function all(...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.chain((array) => { | ||
return p.map((value) => { | ||
return [...array, value]; | ||
}); | ||
}); | ||
}, ok([])); | ||
} | ||
exports.all = all; | ||
/** | ||
@@ -278,0 +292,0 @@ * Takes a lazily invoked callback that returns a parser, so you can create |
@@ -118,2 +118,8 @@ /** | ||
export declare function match(regexp: RegExp): Parser<string>; | ||
/** A tuple of parsers */ | ||
declare type ManyParsers<A extends any[]> = { | ||
[P in keyof A]: Parser<A[P]>; | ||
}; | ||
/** Parse all items, returning their values in the same order. */ | ||
export declare function all<A extends any[]>(...parsers: ManyParsers<A>): Parser<A>; | ||
/** | ||
@@ -120,0 +126,0 @@ * Takes a lazily invoked callback that returns a parser, so you can create |
@@ -268,2 +268,15 @@ /** | ||
} | ||
/** Parse all items, returning their values in the same order. */ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function all(...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.chain((array) => { | ||
return p.map((value) => { | ||
return [...array, value]; | ||
}); | ||
}); | ||
}, ok([])); | ||
} | ||
/** | ||
@@ -270,0 +283,0 @@ * Takes a lazily invoked callback that returns a parser, so you can create |
{ | ||
"name": "bread-n-butter", | ||
"version": "0.2.0", | ||
"description": "Parser combinators for JavaScript and TypeScript", | ||
"version": "0.3.0", | ||
"description": "Parser combinators for JavaScript and TypeScript", | ||
"main": "dist/cjs/bread-n-butter.js", | ||
"module": "dist/esm/bread-n-butter.js", | ||
"browser": "dist/esm/bread-n-butter.js", | ||
"types": "dist/esm/bread-n-butter.d.ts", | ||
@@ -12,4 +13,6 @@ "files": [ | ||
"scripts": { | ||
"build": "rimraf dist && tsc --module es2015 --outDir dist/esm && tsc --module commonjs --outdir dist/cjs && cp dist/esm/bread-n-butter.js docs/js", | ||
"docs": "rimraf dist && tsc --module es2015 --outDir dist/esm && eleventy", | ||
"build:esm": "tsc --module es2015 --outDir dist/esm && cp dist/esm/bread-n-butter.js docs/js", | ||
"build:cjs": "tsc --module commonjs --outdir dist/cjs", | ||
"build": "rimraf dist && npm run -s build:esm && npm run -s build:cjs", | ||
"docs": "rimraf dist && npm run -s build:esm && eleventy", | ||
"docs-serve": "eleventy --serve", | ||
@@ -16,0 +19,0 @@ "check": "prettier --check src examples __test__ && eslint --ext .js,.ts src examples __test__", |
@@ -8,2 +8,5 @@ **EXPERIMENTAL: Do not use in production** | ||
Read [the documentation](https://wavebeem-bread-n-butter.netlify.app/). | ||
- [Documentation](https://wavebeem-bread-n-butter.netlify.app/) | ||
- [Changelog](https://github.com/wavebeem/bread-n-butter/blob/main/CHANGELOG.md) | ||
- [Code of Conduct](https://github.com/wavebeem/bread-n-butter/blob/main/CODE_OF_CONDUCT.md) | ||
- [npm](https://www.npmjs.com/package/bread-n-butter) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42761
1232
12
8