Skip to content

WIP: Functional rewrite #197

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

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 1 addition & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@ root = true
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
charset = utf8

[{package.json, package-lock.json}]
indent_size = 2
charset = utf8
13 changes: 0 additions & 13 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
{
"extends": "airbnb",
"rules": {
"indent": [2, 4],
"no-underscore-dangle": [2, { "allowAfterThis": true }],
"no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"],
"newline-per-chained-call": "off",
"max-len": [2, 255, 4],
"no-param-reassign": 0,
"spaced-comment": [2, "always", { "markers": ["/", "!"] }],
"no-plusplus": 0
},
"env": {
"amd": true,
"node": true,
"commonjs": true,
"es6": true,
"browser": true
},
"globals": {
"VerEx": true
}
}
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ node_modules
.DS_Store
.idea/
.vscode/
.nyc_output
docs/_site
docs/.sass-cache
docs/.jekyll-metadata
.nyc_output
30 changes: 22 additions & 8 deletions .mdlintrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
{
"heading-increment": true,
"first-heading-h1": { "level": 1 },
"heading-style": { "style": "atx" },
"ul-style": { "style": "dash" },
"first-heading-h1": {
"level": 1
},
"heading-style": {
"style": "atx"
},
"ul-style": {
"style": "dash"
},
"list-indent": true,
"ul-start-left": true,
"ul-indent": { "indent": 4 },
"ul-indent": {
"indent": 4
},
"no-trailing-spaces": true,
"no-hard-tabs": true,
"no-reversed-links": true,
"no-multiple-blanks": { "maximum": 1 },
"no-multiple-blanks": {
"maximum": 1
},
"line-length": false,
"commands-show-output": true,
"no-missing-space-atx": true,
Expand All @@ -21,13 +31,17 @@
"no-duplicate-heading": true,
"single-h1": true,
"no-trailing-punctuation": true,
"ol-prefix": { "style": "ordered" },
"ol-prefix": {
"style": "ordered"
},
"list-marker-space": 1,
"blanks-around-fences": true,
"blanks-around-lists": true,
"no-inline-html": false,
"no-bare-urls": true,
"hr-style": { "style": "___" },
"hr-style": {
"style": "___"
},
"no-emphasis-as-heading": true,
"no-space-in-emphasis": true,
"no-space-in-code": false,
Expand All @@ -36,4 +50,4 @@
"first-line-h1": true,
"no-empty-links": true,
"no-alt-text": true
}
}
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: node_js

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

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

This file was deleted.

40 changes: 18 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ npm install verbal-expressions
Require:

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

Or use ES6's `import`:

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

## Running tests
Expand All @@ -45,12 +45,6 @@ import VerEx from 'verbal-expressions';
npm test
```

(or)

```sh
npm run test:verbose
```

## Creating a minified version

```sh
Expand All @@ -74,22 +68,22 @@ Here are some simple examples to give an idea of how VerbalExpressions works:
```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();
.startOfLine()
.then("http")
.maybe("s")
.then("://")
.maybe("www.")
.anythingBut(" ")
.endOfLine();

// Create an example URL
const testMe = 'https://www.google.com';
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
alert("We have a correct URL"); // This output will fire
} else {
alert('The URL is incorrect');
alert("The URL is incorrect");
}

console.log(tester); // Outputs the actual expression used: /^(http)(s)?(\:\/\/)(www\.)?([^\ ]*)$/
Expand All @@ -99,13 +93,13 @@ console.log(tester); // Outputs the actual expression used: /^(http)(s)?(\:\/\/)

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

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

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

// Outputs "Replace duck with a duck"
alert(result);
Expand All @@ -114,7 +108,9 @@ alert(result);
### Shorthand for string replace

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

// Outputs "We have a blue house"
alert(result);
Expand Down
Loading