Skip to content

Commit

Permalink
Added uniUpper, removed duplicated test code, upped version
Browse files Browse the repository at this point in the history
  • Loading branch information
GregRos committed Dec 29, 2019
1 parent fb2740a commit 8748b3b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parjs",
"version": "0.12.3",
"version": "0.12.6",
"repository": "https://github.com/GregRos/parjs",
"homepage": "https://github.com/GregRos/parjs",
"typings": "index",
Expand All @@ -9,7 +9,8 @@
"scripts": {
"test": "nyc node ./dist/test/runner.js",
"build": "rm -rf dist/ && tsc",
"docs": "node dist/generate-docs/run.js"
"docs": "node dist/generate-docs/run.js",
"do-publish": "yarn run build; node dist/publish.js; cd .tmp/publish; yarn publish"
},
"keywords": [
"parser",
Expand All @@ -28,7 +29,6 @@
"lodash": "^4.17.13"
},
"devDependencies": {
"@types/globby": "^9.1.0",
"@types/jasmine": "^3.3.0",
"@types/lodash": "^4.14.104",
"@types/node": "^10.12.9",
Expand Down
12 changes: 11 additions & 1 deletion src/lib/internal/parsers/char-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
isHex,
isUpper,
isLower,
isSpace, isNewline
isSpace, isNewline, uniIsUpper
} from "char-info";
import {must} from "../combinators/must";

Expand Down Expand Up @@ -102,6 +102,16 @@ export function uniDecimal() {
});
}

/**
* Returns a parser that parses a single Unicode upper-case character.
*/
export function uniUpper() {
return charWhere(x => uniIsUpper.char(x) || {
reason: `expecting a Unicode upper-case letter`
});
}


/**
* Returns a parser that parses a single hex digit.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/lib/internal/parsers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ export {state} from "./state";
export {string} from "./string";
export {stringLen} from "./string-len";
export {anyStringOf} from "./string-of";
export {anyChar, anyCharOf, noCharOf, whitespace, uniLower, uniDecimal, digit, hex, letter, lower, space, spaces1, uniLetter, upper} from "./char-types";
export {anyChar, anyCharOf, noCharOf, whitespace, uniLower, uniDecimal, uniUpper, digit, hex, letter, lower, space, spaces1, uniLetter, upper} from "./char-types";
10 changes: 0 additions & 10 deletions src/test/unit/standalone/string.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,6 @@ describe("basic string parsers", () => {
expectSuccess(parser.parse(macNewline), macNewline);
});

it("success on all newline string, incl unicode newline", () => {
let unicodeNewline = uniNewline().pipe(
many()
);
let result = unicodeNewline.parse(allNewlines);
expect(result.kind).toBe(ResultKind.Ok);
if (result.kind !== ResultKind.Ok) return;
expect(result.value.length).toBe(allNewlines.length - 1);
});

it("fails on empty", () => {
expectFailure(parser.parse(empty));
});
Expand Down

0 comments on commit 8748b3b

Please sign in to comment.