-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from marihachi/develop
0.3.0
- Loading branch information
Showing
10 changed files
with
264 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +0,0 @@ | ||
## 0.2.0 | ||
|
||
- API: Rename class `Carol` -> `Pattern` | ||
- API: Rename function `regex()` -> `pattern()` | ||
- API: Reanme function `.build()` -> `.toRegex()` | ||
- API: Remove orverload `seq(Pattern)` | ||
- API: Add overload `pattern(string)` | ||
- API: Remove orverload `pattern(RegExp[])` | ||
- API: Improve error messages. | ||
- other: rename library filenames. | ||
|
||
## 0.1.0 | ||
|
||
Initial Release. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,40 @@ | ||
## Regex pattern | ||
```js | ||
C.pattern(/[a-z]/); | ||
C.pattern('[a-z]'); | ||
# API | ||
|
||
## function: carol | ||
```ts | ||
function carol(source: string | RegExp): Pattern; | ||
``` | ||
|
||
## function: seq | ||
```ts | ||
function seq(patterns: Pattern[]): Pattern; | ||
``` | ||
|
||
## class: Pattern | ||
```ts | ||
class Pattern { | ||
constructor(source: string); | ||
} | ||
``` | ||
|
||
## Convert to a Regex | ||
```js | ||
C.pattern(/[a-z]/).toRegex(); | ||
### method: Pattern.many | ||
```ts | ||
function many(min?: number, greedy?: boolean): Pattern; | ||
function many(min: number, max: number, greedy?: boolean): Pattern; | ||
function many(opts: { min?: number, max?: number, greedy?: boolean, length?: number }): Pattern; | ||
``` | ||
|
||
## Pattern sequence | ||
```js | ||
C.seq([ | ||
C.pattern(/[a-z]/), | ||
C.pattern(/[0-9]/), | ||
]); | ||
### method: Pattern.option | ||
```ts | ||
function option(greedy?: boolean): Pattern; | ||
``` | ||
|
||
## Repeat pattern | ||
```js | ||
C.pattern(/[a-z]/).many0(); | ||
C.pattern(/[a-z]/).many1(); | ||
C.pattern(/[a-z]/).many(2); | ||
C.pattern(/[a-z]/).many(2, 4); | ||
C.pattern(/[a-z]/).manyJust(2); | ||
### method: Pattern.capture | ||
```ts | ||
function capture(): Pattern; | ||
``` | ||
|
||
## Capture input string | ||
```js | ||
C.seq([ | ||
C.pattern(/[a-z]+/), | ||
C.pattern(/-/), | ||
C.pattern(/[0-9]+/).capture(), | ||
]); | ||
### method: Pattern.toRegex | ||
```ts | ||
function toRegex(flags?: Flag | Flag[]): RegExp; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Usage | ||
|
||
## New carol pattern | ||
```js | ||
carol(/[a-z]/); | ||
carol('[a-z]'); | ||
``` | ||
|
||
## Convert to a Regex | ||
```js | ||
carol(/[a-z]/).toRegex(); | ||
``` | ||
|
||
## Pattern sequence | ||
```js | ||
carol.seq([ | ||
carol(/[a-z]/), | ||
carol(/[0-9]/), | ||
]); | ||
``` | ||
|
||
## Repeat pattern | ||
```js | ||
carol(/[a-z]/).many(0); // * | ||
carol(/[a-z]/).many(1); // + | ||
carol(/[a-z]/).many(2); // {2,} | ||
carol(/[a-z]/).many(2, 4); // {2,4} | ||
carol(/[a-z]/).many({ length: 2 }); // {2} | ||
carol(/[a-z]/).many(2, 2); // {2} | ||
``` | ||
|
||
## Optional pattern | ||
```js | ||
carol(/[a-z]/).option(); | ||
``` | ||
|
||
## Capture input string | ||
```js | ||
carol.seq([ | ||
carol(/[a-z]+/), | ||
carol(/-/), | ||
carol(/[0-9]+/).capture(), | ||
]); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.