Skip to content

Commit 4ea5a2d

Browse files
Merge branch 'release/1.1.0'
2 parents 26609a7 + 673319b commit 4ea5a2d

28 files changed

+754
-6055
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ end_of_line = lf
99
insert_final_newline = true
1010
indent_style = tab
1111

12-
[{package.json,yarn.lock}]
12+
[package.json]
1313
indent_style = space
1414
indent_size = 2

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/coverage/
2+
/demo/lib/
3+
/demo/webpack.config.js
4+
/lib/

.eslintrc.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"extends": [
4+
"airbnb-base",
5+
"plugin:jest/recommended",
6+
"plugin:@typescript-eslint/eslint-recommended",
7+
"plugin:@typescript-eslint/recommended",
8+
"prettier",
9+
"prettier/@typescript-eslint"
10+
],
11+
"parserOptions": {
12+
"ecmaVersion": 2018
13+
},
14+
"rules": {
15+
"import/no-extraneous-dependencies": [
16+
"error",
17+
{
18+
"devDependencies": ["**/*.spec.{js,ts}"]
19+
}
20+
],
21+
"import/prefer-default-export": "off"
22+
},
23+
"settings": {
24+
"import/parsers": {
25+
"@typescript-eslint/parser": [".ts"]
26+
},
27+
"import/resolver": {
28+
"typescript": {}
29+
}
30+
}
31+
}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
package-lock.json
2+
13
coverage/
4+
demo/lib/
25
lib/
36
node_modules/
4-
demo/demo.js

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

.publishrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"validations": {
3+
"vulnerableDependencies": false,
4+
"uncommittedChanges": true,
5+
"untrackedFiles": true,
6+
"sensitiveData": true,
7+
"branch": "master",
8+
"gitTag": true
9+
},
10+
"confirm": true,
11+
"publishCommand": "npm publish",
12+
"publishTag": "latest",
13+
"prePublishScript": "npm run publish-please-prereqs",
14+
"postPublishScript": false
15+
}

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: node_js
2+
node_js:
3+
- 'node'
4+
- '8'
5+
script:
6+
- npm run travisci
7+
cache:
8+
directories:
9+
- node_modules

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# strings-to-regex
2+
3+
[![npm package](https://badge.fury.io/js/strings-to-regex.svg)](https://badge.fury.io/js/strings-to-regex)
4+
![node version](https://img.shields.io/node/v/strings-to-regex.svg)
5+
![npm type definitions](https://img.shields.io/npm/types/strings-to-regex)
6+
[![Build Status](https://travis-ci.org/wimpyprogrammer/strings-to-regex.svg?branch=master)](https://travis-ci.org/wimpyprogrammer/strings-to-regex)
7+
[![codecov](https://codecov.io/gh/wimpyprogrammer/strings-to-regex/branch/master/graph/badge.svg)](https://codecov.io/gh/wimpyprogrammer/strings-to-regex)
8+
[![Known Vulnerabilities](https://snyk.io/test/github/wimpyprogrammer/strings-to-regex/badge.svg)](https://snyk.io/test/github/wimpyprogrammer/strings-to-regex)
9+
10+
Generate a compact Regular Expression that matches a finite set.
11+
12+
Have you ever seen a dense Regular Expression like this one to match the 50 US state abbreviations?
13+
14+
```regexp
15+
/(A(L|K|Z|R)|C(A|O|T)|DE|FL|GA|HI|I(D|L|N|A)|K(S|Y)|LA|M(E|D|A|I|N|S|O|T)|N(E|V|H|J|M|Y|C|D)|O(H|K|R)|PA|RI|S(C|D)|T(N|X)|UT|V(T|A)|W(A|V|I|Y))/
16+
```
17+
18+
This library generates patterns like that to match a list of strings you provide.
19+
20+
_To reverse this process and list which strings a Regular Expression would match, try [`regex-to-strings`](https://www.npmjs.com/package/regex-to-strings)._
21+
22+
## <a href="https://www.wimpyprogrammer.com/strings-to-regex/">Demo</a>
23+
24+
## API
25+
26+
### `condense(arrayOfStrings)`
27+
28+
Generate a Regular Expression to match all strings in `arrayOfStrings`. Respects the casing of the strings. Returns a [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) object.
29+
30+
```js
31+
import { condense } from 'strings-to-regex';
32+
33+
const stringsToMatch = ['foo', 'foobar', 'Foo', 'fooBarBaz'];
34+
const matcher = condense(stringsToMatch);
35+
console.log(matcher); // /(foo(|bar|BarBaz)|Foo)/
36+
```
37+
38+
---
39+
40+
### `condenseIgnoreCase(arrayOfStrings)`
41+
42+
A variation of `condense()` that ignores the casing of the strings. Returns a [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) object.
43+
44+
```js
45+
import { condenseIgnoreCase } from 'strings-to-regex';
46+
47+
const stringsToMatch = ['foo', 'foobar', 'Foo', 'fooBarBaz'];
48+
const matcher = condenseIgnoreCase(stringsToMatch);
49+
console.log(matcher); // /foo(|bar(|baz))/i
50+
```

0 commit comments

Comments
 (0)