Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional Rewrite (2.0.0) #198

Open
wants to merge 134 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
c4d1946
Add empty Typescript base
jehna Jul 19, 2019
0c22c21
Add Jest
jehna Jul 19, 2019
8e6b16b
Add startOfLine and endOfLine constants
jehna Jul 19, 2019
bcbee70
Add "maybe" function
jehna Jul 19, 2019
681a413
Add or function
jehna Jul 19, 2019
5b92a93
Add "anything" constant
jehna Jul 19, 2019
e4e38d1
Add "something" constant
jehna Jul 19, 2019
f7afdd6
Add anythingBut and somethingBut
jehna Jul 19, 2019
ac3bcd0
Add oneOrMore
jehna Jul 19, 2019
63ecd43
Add anyOf
jehna Jul 19, 2019
7142f93
Add multiple
jehna Jul 19, 2019
bd3c82e
Add some complex test cases
jehna Jul 19, 2019
c7e5459
Add proper sanitizion for inputs
jehna Jul 19, 2019
f67b826
Add capture groups
jehna Jul 20, 2019
678cad0
Move tests to their own directory
shreyasminocha Sep 21, 2019
2889c86
Move utils and types to their own directories
shreyasminocha Sep 21, 2019
c020a70
Improve constructs and overall structure
shreyasminocha Sep 21, 2019
aaa86a9
Use the `Expression` type alias
shreyasminocha Sep 22, 2019
0daf8ea
Make `multiple` pass tests
shreyasminocha Sep 22, 2019
f0206eb
Remove eslint config and outdated `dist`
shreyasminocha Sep 22, 2019
d67b770
Make `multiple` support 'exactly n times'
shreyasminocha Sep 22, 2019
c36446e
Add `group.capturing` and `group.nonCapturing`
shreyasminocha Sep 22, 2019
64a5d7a
Fix `sanitize` return type
shreyasminocha Sep 22, 2019
332e5ff
Add tslint
shreyasminocha Sep 22, 2019
99c3783
Fix tslint errors
shreyasminocha Sep 22, 2019
f8c881f
Update gitignore
shreyasminocha Sep 22, 2019
e994b3d
Remove mdlint, bower config files
shreyasminocha Sep 22, 2019
52919f5
Fix editorconfig errors
shreyasminocha Sep 22, 2019
4deab48
Reduce the readme to an outline
shreyasminocha Sep 22, 2019
355b56e
Convert filenames to kebab case
shreyasminocha Sep 22, 2019
5563f99
Add lookaround
shreyasminocha Sep 22, 2019
7227806
Add `concat`
shreyasminocha Sep 23, 2019
a813c5e
Use group.nonCapturing where relevant
shreyasminocha Sep 23, 2019
a990507
Rename and modify anyOf and anythingBut
shreyasminocha Sep 23, 2019
643c5eb
Add more constants
shreyasminocha Sep 23, 2019
8645594
Fix tslint errors
shreyasminocha Sep 23, 2019
a0db811
Make `npm test` run tslint too
shreyasminocha Sep 23, 2019
4405471
Improve parameter names
shreyasminocha Sep 24, 2019
6da5c94
Improve, add, and edit tests
shreyasminocha Sep 24, 2019
6944cb7
Fix negative lookbehinds
shreyasminocha Sep 24, 2019
b3a65f8
Move `VerEx` tests to a different file
shreyasminocha Sep 25, 2019
2db6475
Make tests independent of constants
shreyasminocha Sep 25, 2019
83a848c
Fix a typo
shreyasminocha Sep 25, 2019
3a95c21
Allow character class methods to accept ranges
shreyasminocha Sep 25, 2019
769ae29
Remove `somethingBut`
shreyasminocha Sep 25, 2019
e899ced
Make some tests more meaningful
shreyasminocha Sep 25, 2019
2cff175
Remove accidentally committed `Flags`
shreyasminocha Sep 25, 2019
fa46fe7
Create some test stubs
shreyasminocha Sep 25, 2019
1b173aa
Add IP address example as a test
shreyasminocha Sep 25, 2019
b91ded9
Fix escaping bug in `concat`
shreyasminocha Sep 25, 2019
264c7af
Add hex colour code example to tests
shreyasminocha Sep 25, 2019
c977490
Fix tslint errors
shreyasminocha Sep 25, 2019
35d0b77
Fix error TS2339
shreyasminocha Sep 25, 2019
8c1be6c
Split `multiple` into two functions
shreyasminocha Sep 26, 2019
a0f4817
Create aliases for `maybe` and `VerEx`
shreyasminocha Sep 26, 2019
39aba67
Add an alias for multiple
shreyasminocha Sep 26, 2019
d880e56
Write all `todo` tests
shreyasminocha Sep 26, 2019
44f8e68
Make `whitespaceCharacter` test independent
shreyasminocha Sep 26, 2019
eb0a0d7
Fix a vulnerability
shreyasminocha Sep 26, 2019
117f1b1
Configure jest to show coverage
shreyasminocha Sep 26, 2019
ccfa052
Prepare package for publishing
shreyasminocha Sep 26, 2019
d7c974b
Rename a file
shreyasminocha Oct 7, 2019
1de7ce5
Add date validation test
shreyasminocha Oct 8, 2019
54f2862
Rename several tests
shreyasminocha Oct 9, 2019
00ae6b1
Add and improve tests
shreyasminocha Oct 10, 2019
e0428ab
Configure jest to be verbose in a CI env
shreyasminocha Oct 10, 2019
cbb618c
Allow lookaround methods to accept multiple args
shreyasminocha Oct 10, 2019
2bf3113
Rename params for consistency
shreyasminocha Oct 10, 2019
c3f9df5
Rename test for consistency
shreyasminocha Oct 10, 2019
57cc7af
Add and improve tests
shreyasminocha Oct 15, 2019
73f0d94
Add lazy versions of quantifiers
shreyasminocha Oct 16, 2019
5eb74ec
Restructure tests using describe nesting
shreyasminocha Oct 16, 2019
2b40db4
Fix `maybe.lazy` test
shreyasminocha Oct 16, 2019
c4eafa5
Add support for named groups
shreyasminocha Oct 16, 2019
74dfe9f
Add support for back references
shreyasminocha Oct 17, 2019
8527371
Make backReference's return type explicit
shreyasminocha Oct 17, 2019
532ca2a
Add .greedy aliases to quantifiers
shreyasminocha Oct 17, 2019
b62f2c3
Update tsc `lib` to fix a failing test
shreyasminocha Oct 18, 2019
2fc32ae
Add and use a jest custom matcher
shreyasminocha Oct 20, 2019
6805f94
Make character class methods versatile
shreyasminocha Oct 23, 2019
3bb47ab
Make character class tests independent
shreyasminocha Oct 23, 2019
05feb1b
Add negated versions of character classes
shreyasminocha Oct 23, 2019
0ba4cf9
Split constants.test.ts into multiple suites
shreyasminocha Oct 23, 2019
90db0fc
Add several incomplete tests
shreyasminocha Oct 25, 2019
2571d86
Remove a failing assertion
shreyasminocha Oct 25, 2019
538f8d9
Fix a regex that is almost incorrect
shreyasminocha Oct 25, 2019
87bdd7c
Move some utils into RawExpression class
shreyasminocha Oct 26, 2019
03a4f98
Rename some parameters for clarity
shreyasminocha Oct 26, 2019
96d3c08
Rename RawExpression type
shreyasminocha Nov 3, 2019
19fd47c
Fix inaccurate variable name
shreyasminocha Nov 4, 2019
1fa47bd
Implement flag customization
shreyasminocha Nov 4, 2019
9ae3cd0
Fix VerEx zero args bug
shreyasminocha Nov 4, 2019
1492f86
Create flags test stubs
shreyasminocha Nov 5, 2019
72d8d59
Fix flags bug
shreyasminocha Nov 9, 2019
f0a6c3d
Add flags tests
shreyasminocha Nov 9, 2019
454908e
Add VerEx.extend
shreyasminocha Nov 9, 2019
fd777db
Rename flags to match "official" names
shreyasminocha Nov 9, 2019
f3f070d
Set up bundling with rollup
shreyasminocha Nov 9, 2019
cd412c7
Test flag defaults
shreyasminocha Nov 11, 2019
e768b16
Move flag tests into verex.test.ts
shreyasminocha Nov 11, 2019
0d379dd
Simplify flag default testing
shreyasminocha Nov 11, 2019
a9c7e98
Add replacement helpers
shreyasminocha Nov 11, 2019
aeb11c9
Remove replacement helpers
shreyasminocha Nov 11, 2019
83e9d49
Fix buggy default flags
shreyasminocha Nov 11, 2019
97f5d7a
Fix jest config
shreyasminocha Nov 11, 2019
673cf16
Switch from tslint to xo
shreyasminocha Nov 10, 2019
97906d5
Fix lint errors
shreyasminocha Nov 12, 2019
c53cfda
Remove unnecessary if condition
shreyasminocha Nov 12, 2019
4888d94
Replace default exports with named ones
shreyasminocha Nov 14, 2019
b79079b
Configure minified builds
shreyasminocha Nov 14, 2019
552bc41
Partially re-structure library
shreyasminocha Nov 14, 2019
1b19877
Strip comments from all bundles
shreyasminocha Nov 14, 2019
b70f9ff
Configure declaration generation
shreyasminocha Nov 14, 2019
d3c2266
Add more tests for the unicode flag
shreyasminocha Nov 25, 2019
0c3400c
Add several examples as tests
shreyasminocha Nov 26, 2019
4aaad9d
Rename some tests
shreyasminocha Nov 26, 2019
7a23106
Split examples into multiple files
shreyasminocha Nov 26, 2019
3696cf9
Configure indent for generated files
shreyasminocha Nov 26, 2019
ff2ba91
Add stricter type-checking to repeat
shreyasminocha Nov 26, 2019
c0f7088
Rename some parameters for brevity
shreyasminocha Nov 26, 2019
e104da3
Fix false negatives in certain tests
shreyasminocha Nov 27, 2019
439ed2e
Remove params from test names
shreyasminocha Nov 27, 2019
d8631ac
Add more unicode flag tests
shreyasminocha Nov 27, 2019
ad9ebc9
Add inline docs to utils and types
shreyasminocha Nov 28, 2019
74a4eec
Fix sanitization regex
shreyasminocha Nov 28, 2019
5eb4049
Move set type into a file of its own
shreyasminocha Nov 28, 2019
d362332
Move fragment util out of the class
shreyasminocha Nov 28, 2019
aec10d0
Fix hyphens in character classes
shreyasminocha Nov 28, 2019
bf22365
Move default flags into flags.ts
shreyasminocha Dec 11, 2019
edfdaf4
Abstract fragment concat into a function
shreyasminocha Dec 11, 2019
0bc4f77
Simplify concat code
shreyasminocha Feb 9, 2020
cd0ca23
Improve example tests
shreyasminocha Feb 10, 2020
8b791c3
Add @types/jest dev dependency
shreyasminocha Feb 10, 2020
c78b6c0
Scaffold docs site
shreyasminocha Feb 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
root = true

[*]
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
charset = utf8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
charset = utf8

[{package.json, package-lock.json}]
indent_size = 2
[dist/index.d.ts]
indent_size = 4
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs
23 changes: 0 additions & 23 deletions .eslintrc

This file was deleted.

9 changes: 2 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
node_modules
.DS_Store
.idea/
.vscode/
.nyc_output
docs/_site
docs/.sass-cache
docs/.jekyll-metadata
coverage
dist
39 changes: 0 additions & 39 deletions .mdlintrc.json

This file was deleted.

9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: node_js

node_js:
- "9"
- "10"
- "11"
- "12"
- "10"
- "11"
- "12"

script: npm run test:verbose
script: npm run test
104 changes: 0 additions & 104 deletions Gruntfile.js

This file was deleted.

127 changes: 9 additions & 118 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,141 +9,32 @@

VerbalExpressions is a JavaScript library that helps construct difficult regular expressions.

## How to get started

### In the browser
## Examples

```html
<script src="VerbalExpressions.js"></script>
```
## Getting started

Or use the [jsDelivr CDN](https://www.jsdelivr.com/package/npm/verbal-expressions).
### In the browser

### On the server (node.js)

Install:

```sh
npm install verbal-expressions
```

Require:

```js
const VerEx = require('verbal-expressions');
```

Or use ES6's `import`:

```js
import VerEx from 'verbal-expressions';
```

## Running tests
#### Install

```sh
npm test
```
#### Import

(or)
## Development

```sh
npm run test:verbose
```
### Running tests

## Creating a minified version

```sh
npm run build
```

This will run [Babel](https://babeljs.io) on `VerbalExpressions.js` and output the result to `dist/verbalexpressions.js`. A minified version of the same will also be written to `dist/verbalexpressions.min.js`.

A source map will also be created in `dist`, so you can use the original "un-babelified", unminified source file for debugging purposes.
### Building

## API documentation

You can find the API documentation at [verbalexpressions.github.io/JSVerbalExpressions](https://verbalexpressions.github.io/JSVerbalExpressions). You can find the source code for the docs in [`docs`](docs/).

## Examples

Here are some simple examples to give an idea of how VerbalExpressions works:

### Testing if we have a valid URL

```js
// Create an example of how to test for correctly formed URLs
const tester = VerEx()
.startOfLine()
.then('http')
.maybe('s')
.then('://')
.maybe('www.')
.anythingBut(' ')
.endOfLine();

// Create an example URL
const testMe = 'https://www.google.com';

// Use RegExp object's native test() function
if (tester.test(testMe)) {
alert('We have a correct URL'); // This output will fire
} else {
alert('The URL is incorrect');
}

console.log(tester); // Outputs the actual expression used: /^(http)(s)?(\:\/\/)(www\.)?([^\ ]*)$/
```

### Replacing strings

```js
// Create a test string
const replaceMe = 'Replace bird with a duck';

// Create an expression that seeks for word "bird"
const expression = VerEx().find('bird');

// Execute the expression like a normal RegExp object
const result = expression.replace(replaceMe, 'duck');

// Outputs "Replace duck with a duck"
alert(result);
```

### Shorthand for string replace

```js
const result = VerEx().find('red').replace('We have a red house', 'blue');

// Outputs "We have a blue house"
alert(result);
```

## Contributions

Pull requests are warmly welcome!

Clone the repo and fork:

```sh
git clone https://github.com/VerbalExpressions/JSVerbalExpressions.git
```
## Contributing

### Style guide

The [Airbnb](https://github.com/airbnb/javascript) style guide is loosely used as a basis for creating clean and readable JavaScript code. Check [`.eslintrc`](.eslintrc).

Check out these slide decks for handy Github & git tips:

- [Git and Github Secrets](https://zachholman.com/talk/git-github-secrets/)
- [More Git and Github Secrets](https://zachholman.com/talk/more-git-and-github-secrets/)

## Tools

- https://verbalregex.com - it's a wrapper of JSVerbalExpressions; users can write down the code and compile to regex
- https://jsbin.com/metukuzowi/edit?js,console - JSBin Playground

## Other Implementations

You can see an up to date list of all ports on [VerbalExpressions.github.io](https://VerbalExpressions.github.io).
Expand Down
Loading