Comparing version 0.6.0 to 0.7.0
# Changelog | ||
## Version 0.7.0 | ||
- `otherwise` function now has two overloads - `Parser * Matcher -> Matcher` and `Parser * Parser -> Parser`; | ||
- `otherwise` function now accepts Parsers/Matchers with different value types, result value type is the union of the two; | ||
- `otherwise` function now has an alias called `eitherOr` which might be more natural for combining parsers. | ||
## Version 0.6.0 | ||
@@ -4,0 +10,0 @@ |
@@ -305,3 +305,4 @@ /** | ||
* | ||
* Combine with {@link otherwise} if you want to return a {@link Matcher}. | ||
* Combine with {@link otherwise} if you want to return a {@link Matcher} | ||
* or you have a limited number of parsers of different types. | ||
* | ||
@@ -313,3 +314,3 @@ * @param ps - Parsers to try. | ||
/** | ||
* Make a {@link Matcher} from a parser and a matcher. | ||
* This overload makes a {@link Matcher} from a parser and a matcher. | ||
* If the parser matched - return the match, | ||
@@ -321,12 +322,30 @@ * otherwise return the match from the matcher. | ||
* | ||
* Combine with {@link choice} if you need multiple alternative parsers. | ||
* Combine with {@link choice} if you need multiple alternative parsers of the same value type. | ||
* | ||
* Nest calls to have union of more than two different value types derived automatically. | ||
* | ||
* Use {@link option} if you just want a constant alternative value | ||
* without consuming input. | ||
* | ||
* @param p - A parser. | ||
* @param m - A matcher that is only called if the parser didn't match. | ||
* @param pa - A parser. | ||
* @param pb - A matcher that is only called if the parser didn't match. | ||
*/ | ||
export declare function otherwise<TToken, TOptions, TValue>(p: Parser<TToken, TOptions, TValue>, m: Matcher<TToken, TOptions, TValue>): Matcher<TToken, TOptions, TValue>; | ||
export declare function otherwise<TToken, TOptions, TValueA, TValueB>(pa: Parser<TToken, TOptions, TValueA>, pb: Matcher<TToken, TOptions, TValueB>): Matcher<TToken, TOptions, TValueA | TValueB>; | ||
/** | ||
* Make a parser that tries two parsers at the same position | ||
* and returns the first successful match | ||
* or a nonmatch if there was none. | ||
* | ||
* Use this if you want to combine parsers of different value types. | ||
* | ||
* Nest calls to have more than two different value types. | ||
* | ||
* Use {@link choice} if you have parsers of the same value type. | ||
* | ||
* @param pa - A parser that is tried first. | ||
* @param pb - A parser that is only tried if the first one didn't match. | ||
*/ | ||
export declare function otherwise<TToken, TOptions, TValueA, TValueB>(pa: Parser<TToken, TOptions, TValueA>, pb: Parser<TToken, TOptions, TValueB>): Parser<TToken, TOptions, TValueA | TValueB>; | ||
export { otherwise as eitherOr }; | ||
/** | ||
* Make a parser that tries all provided parsers at the same position | ||
@@ -333,0 +352,0 @@ * and returns the longest successful match |
{ | ||
"name": "peberminta", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Simple, transparent parser combinators toolkit that supports any tokens", | ||
@@ -69,3 +69,3 @@ "keywords": [ | ||
"prepublishOnly": "npm run build && npm run checkAll", | ||
"test": "ava", | ||
"test": "ava --timeout=20s", | ||
"ts": "node --experimental-specifier-resolution=node --loader ts-node/esm" | ||
@@ -77,21 +77,21 @@ }, | ||
"@tsconfig/node12": "^1.0.9", | ||
"@types/node": "12.20.41", | ||
"@typescript-eslint/eslint-plugin": "^4.33.0", | ||
"@typescript-eslint/parser": "^4.33.0", | ||
"ava": "^3.15.0", | ||
"@types/node": "12.20.46", | ||
"@typescript-eslint/eslint-plugin": "^5.12.0", | ||
"@typescript-eslint/parser": "^5.12.0", | ||
"ava": "^4.0.1", | ||
"c8": "^7.11.0", | ||
"concurrently": "^7.0.0", | ||
"denoify": "^0.10.6", | ||
"eslint": "^7.32.0", | ||
"eslint-plugin-jsonc": "^2.0.0", | ||
"denoify": "^0.11.0", | ||
"eslint": "^8.9.0", | ||
"eslint-plugin-jsonc": "^2.1.0", | ||
"eslint-plugin-tsdoc": "^0.2.14", | ||
"leac": "^0.5.0", | ||
"markdownlint-cli2": "^0.3.2", | ||
"leac": "^0.5.1", | ||
"markdownlint-cli2": "^0.4.0", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.63.0", | ||
"rollup": "^2.67.2", | ||
"rollup-plugin-cleanup": "^3.2.1", | ||
"ts-node": "^10.4.0", | ||
"ts-node": "^10.5.0", | ||
"tslib": "^2.3.1", | ||
"typedoc": "^0.22.10", | ||
"typescript": "~4.5.4" | ||
"typedoc": "^0.22.11", | ||
"typescript": "~4.5.5" | ||
}, | ||
@@ -109,5 +109,2 @@ "ava": { | ||
], | ||
"nonSemVerExperiments": { | ||
"configurableModuleFormat": true | ||
}, | ||
"verbose": true | ||
@@ -114,0 +111,0 @@ }, |
@@ -140,13 +140,13 @@ # peberminta | ||
| [chainReduce](https://mxxii.github.io/peberminta/modules/core.html#chainReduce) | [choice](https://mxxii.github.io/peberminta/modules/core.html#choice) | [condition](https://mxxii.github.io/peberminta/modules/core.html#condition) | [decide](https://mxxii.github.io/peberminta/modules/core.html#decide) | ||
| _[discard](https://mxxii.github.io/peberminta/modules/core.html#discard)_ | [emit](https://mxxii.github.io/peberminta/modules/core.html#emit) | [end](https://mxxii.github.io/peberminta/modules/core.html#end) | _[eof](https://mxxii.github.io/peberminta/modules/core.html#eof)_ | ||
| [error](https://mxxii.github.io/peberminta/modules/core.html#error) | [fail](https://mxxii.github.io/peberminta/modules/core.html#fail) | [flatten](https://mxxii.github.io/peberminta/modules/core.html#flatten) | [flatten1](https://mxxii.github.io/peberminta/modules/core.html#flatten1) | ||
| [left](https://mxxii.github.io/peberminta/modules/core.html#left) | [leftAssoc1](https://mxxii.github.io/peberminta/modules/core.html#leftAssoc1) | [leftAssoc2](https://mxxii.github.io/peberminta/modules/core.html#leftAssoc2) | [longest](https://mxxii.github.io/peberminta/modules/core.html#longest) | ||
| _[lookAhead](https://mxxii.github.io/peberminta/modules/core.html#lookAhead)_ | [make](https://mxxii.github.io/peberminta/modules/core.html#make) | [many](https://mxxii.github.io/peberminta/modules/core.html#many) | [many1](https://mxxii.github.io/peberminta/modules/core.html#many1) | ||
| [map](https://mxxii.github.io/peberminta/modules/core.html#map) | [map1](https://mxxii.github.io/peberminta/modules/core.html#map1) | [middle](https://mxxii.github.io/peberminta/modules/core.html#middle) | [not](https://mxxii.github.io/peberminta/modules/core.html#not) | ||
| _[of](https://mxxii.github.io/peberminta/modules/core.html#of)_ | [option](https://mxxii.github.io/peberminta/modules/core.html#option) | _[or](https://mxxii.github.io/peberminta/modules/core.html#or)_ | [otherwise](https://mxxii.github.io/peberminta/modules/core.html#otherwise) | ||
| [peek](https://mxxii.github.io/peberminta/modules/core.html#peek) | [recursive](https://mxxii.github.io/peberminta/modules/core.html#recursive) | [reduceLeft](https://mxxii.github.io/peberminta/modules/core.html#reduceLeft) | [reduceRight](https://mxxii.github.io/peberminta/modules/core.html#reduceRight) | ||
| [right](https://mxxii.github.io/peberminta/modules/core.html#right) | [rightAssoc1](https://mxxii.github.io/peberminta/modules/core.html#rightAssoc1) | [rightAssoc2](https://mxxii.github.io/peberminta/modules/core.html#rightAssoc2) | [satisfy](https://mxxii.github.io/peberminta/modules/core.html#satisfy) | ||
| [sepBy](https://mxxii.github.io/peberminta/modules/core.html#sepBy) | [sepBy1](https://mxxii.github.io/peberminta/modules/core.html#sepBy1) | [skip](https://mxxii.github.io/peberminta/modules/core.html#skip) | _[some](https://mxxii.github.io/peberminta/modules/core.html#some)_ | ||
| [start](https://mxxii.github.io/peberminta/modules/core.html#start) | [takeUntil](https://mxxii.github.io/peberminta/modules/core.html#takeUntil) | [takeUntilP](https://mxxii.github.io/peberminta/modules/core.html#takeUntilP) | [takeWhile](https://mxxii.github.io/peberminta/modules/core.html#takeWhile) | ||
| [takeWhileP](https://mxxii.github.io/peberminta/modules/core.html#takeWhileP) | [token](https://mxxii.github.io/peberminta/modules/core.html#token) | ||
| _[discard](https://mxxii.github.io/peberminta/modules/core.html#discard)_ | _[eitherOr](https://mxxii.github.io/peberminta/modules/core.html#eitherOr)_ | [emit](https://mxxii.github.io/peberminta/modules/core.html#emit) | [end](https://mxxii.github.io/peberminta/modules/core.html#end) | ||
| _[eof](https://mxxii.github.io/peberminta/modules/core.html#eof)_ | [error](https://mxxii.github.io/peberminta/modules/core.html#error) | [fail](https://mxxii.github.io/peberminta/modules/core.html#fail) | [flatten](https://mxxii.github.io/peberminta/modules/core.html#flatten) | ||
| [flatten1](https://mxxii.github.io/peberminta/modules/core.html#flatten1) | [left](https://mxxii.github.io/peberminta/modules/core.html#left) | [leftAssoc1](https://mxxii.github.io/peberminta/modules/core.html#leftAssoc1) | [leftAssoc2](https://mxxii.github.io/peberminta/modules/core.html#leftAssoc2) | ||
| [longest](https://mxxii.github.io/peberminta/modules/core.html#longest) | _[lookAhead](https://mxxii.github.io/peberminta/modules/core.html#lookAhead)_ | [make](https://mxxii.github.io/peberminta/modules/core.html#make) | [many](https://mxxii.github.io/peberminta/modules/core.html#many) | ||
| [many1](https://mxxii.github.io/peberminta/modules/core.html#many1) | [map](https://mxxii.github.io/peberminta/modules/core.html#map) | [map1](https://mxxii.github.io/peberminta/modules/core.html#map1) | [middle](https://mxxii.github.io/peberminta/modules/core.html#middle) | ||
| [not](https://mxxii.github.io/peberminta/modules/core.html#not) | _[of](https://mxxii.github.io/peberminta/modules/core.html#of)_ | [option](https://mxxii.github.io/peberminta/modules/core.html#option) | _[or](https://mxxii.github.io/peberminta/modules/core.html#or)_ | ||
| [otherwise](https://mxxii.github.io/peberminta/modules/core.html#otherwise) | [peek](https://mxxii.github.io/peberminta/modules/core.html#peek) | [recursive](https://mxxii.github.io/peberminta/modules/core.html#recursive) | [reduceLeft](https://mxxii.github.io/peberminta/modules/core.html#reduceLeft) | ||
| [reduceRight](https://mxxii.github.io/peberminta/modules/core.html#reduceRight) | [right](https://mxxii.github.io/peberminta/modules/core.html#right) | [rightAssoc1](https://mxxii.github.io/peberminta/modules/core.html#rightAssoc1) | [rightAssoc2](https://mxxii.github.io/peberminta/modules/core.html#rightAssoc2) | ||
| [satisfy](https://mxxii.github.io/peberminta/modules/core.html#satisfy) | [sepBy](https://mxxii.github.io/peberminta/modules/core.html#sepBy) | [sepBy1](https://mxxii.github.io/peberminta/modules/core.html#sepBy1) | [skip](https://mxxii.github.io/peberminta/modules/core.html#skip) | ||
| _[some](https://mxxii.github.io/peberminta/modules/core.html#some)_ | [start](https://mxxii.github.io/peberminta/modules/core.html#start) | [takeUntil](https://mxxii.github.io/peberminta/modules/core.html#takeUntil) | [takeUntilP](https://mxxii.github.io/peberminta/modules/core.html#takeUntilP) | ||
| [takeWhile](https://mxxii.github.io/peberminta/modules/core.html#takeWhile) | [takeWhileP](https://mxxii.github.io/peberminta/modules/core.html#takeWhileP) | [token](https://mxxii.github.io/peberminta/modules/core.html#token) | ||
@@ -153,0 +153,0 @@ </div> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
93649
2123