Skip to content

Commit 235c911

Browse files
author
Alexandre van Beurden
committed
Initial commit
0 parents  commit 235c911

17 files changed

+595
-0
lines changed

.gitignore

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
node_modules/
2+
.node_modules/
3+
built/*
4+
tests/cases/rwc/*
5+
tests/cases/perf/*
6+
!tests/cases/webharness/compilerToString.js
7+
test-args.txt
8+
~*.docx
9+
\#*\#
10+
.\#*
11+
tests/baselines/local/*
12+
tests/baselines/local.old/*
13+
tests/services/baselines/local/*
14+
tests/baselines/prototyping/local/*
15+
tests/baselines/rwc/*
16+
tests/baselines/reference/projectOutput/*
17+
tests/baselines/local/projectOutput/*
18+
tests/baselines/reference/testresults.tap
19+
tests/baselines/symlinks/*
20+
tests/services/baselines/prototyping/local/*
21+
tests/services/browser/typescriptServices.js
22+
src/harness/*.js
23+
src/compiler/diagnosticInformationMap.generated.ts
24+
src/compiler/diagnosticMessages.generated.json
25+
src/parser/diagnosticInformationMap.generated.ts
26+
src/parser/diagnosticMessages.generated.json
27+
rwc-report.html
28+
*.swp
29+
build.json
30+
*.actual
31+
tests/webTestServer.js
32+
tests/webTestServer.js.map
33+
tests/webhost/*.d.ts
34+
tests/webhost/webtsc.js
35+
tests/cases/**/*.js
36+
tests/cases/**/*.js.map
37+
*.config
38+
scripts/eslint/built/
39+
scripts/debug.bat
40+
scripts/run.bat
41+
scripts/**/*.js
42+
scripts/**/*.js.map
43+
coverage/
44+
internal/
45+
**/.DS_Store
46+
.settings
47+
**/.vs
48+
**/.vscode/*
49+
!**/.vscode/tasks.json
50+
!**/.vscode/settings.template.json
51+
!**/.vscode/launch.template.json
52+
!**/.vscode/extensions.json
53+
!tests/cases/projects/projectOption/**/node_modules
54+
!tests/cases/projects/NodeModulesSearch/**/*
55+
!tests/baselines/reference/project/nodeModules*/**/*
56+
.idea
57+
yarn.lock
58+
yarn-error.log
59+
.parallelperf.*
60+
tests/baselines/reference/dt
61+
.failed-tests
62+
TEST-results.xml
63+
package-lock.json
64+
.eslintcache
65+
*v8.log
66+
/lib/

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# RegexSolver JavaScript/TypeScript API Client
2+
3+
[Homepage](https://regexsolver.com) | [Documentation](https://docs.regexsolver.com) | [Developer Console](https://console.regexsolver.com)
4+
5+
This repository contains the source code of the JavaScript/TypeScript library for [RegexSolver](https://regexsolver.com) API.
6+
7+
RegexSolver is a powerful regular expression manipulation toolkit, that gives you the power to manipulate regex as if
8+
they were sets.
9+
10+
## Installation
11+
12+
```sh
13+
npm install regexsolver
14+
```
15+
16+
## Usage
17+
18+
In order to use the library you need to generate an API Token on our [Developer Console](https://console.regexsolver.com/).
19+
20+
```javascript
21+
import { RegexSolver } from 'regexsolver';
22+
import { Term } from 'regexsolver';
23+
24+
async function main() {
25+
RegexSolver.initialize("YOUR TOKEN HERE");
26+
27+
const term1 = Term.regex("(abc|de|fg){2,}");
28+
const term2 = Term.regex("de.*");
29+
const term3 = Term.regex(".*abc");
30+
31+
const term4 = Term.regex(".+(abc|de).+");
32+
33+
let result = await term1.intersection(term2, term3);
34+
result = await result.subtraction(term4);
35+
36+
console.log(result.toString());
37+
}
38+
39+
```

jest.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
};

package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "regexsolver",
3+
"version": "1.0.0",
4+
"main": "lib/index.js",
5+
"typings": "lib/index.d.ts",
6+
"files": [
7+
"src/"
8+
],
9+
"scripts": {
10+
"test": "jest",
11+
"build": "tsc"
12+
},
13+
"keywords": [
14+
"Regular Expression",
15+
"regex",
16+
"regexp",
17+
"set",
18+
"intersection",
19+
"union",
20+
"subtraction",
21+
"difference",
22+
"equivalence",
23+
"subset",
24+
"nfa",
25+
"dfa"
26+
],
27+
"author": "RegexSolver",
28+
"license": "MIT",
29+
"description": "RegexSolver allows you to manipulate regular expressions as sets, enabling operations such as intersection, union, and subtraction.",
30+
"dependencies": {
31+
"axios": "^1.7.3"
32+
},
33+
"devDependencies": {
34+
"@types/jest": "^29.5.12",
35+
"jest": "^29.7.0",
36+
"nock": "^13.5.4"
37+
}
38+
}

src/details.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
export class Cardinality {
2+
constructor(
3+
public type: 'Infinite' | 'BigInteger' | 'Integer',
4+
public value?: number
5+
) { }
6+
7+
isInfinite(): boolean {
8+
return this.type == 'Infinite';
9+
}
10+
11+
toString(): string {
12+
if (this.type == 'Integer') {
13+
return this.type + '(' + this.value + ')';
14+
} else {
15+
return this.type;
16+
}
17+
}
18+
}
19+
20+
export class Length {
21+
constructor(
22+
public minimum: number,
23+
public maximum?: number
24+
) { }
25+
26+
toString(): string {
27+
return "Length[minimum=" + this.minimum + ", maximum=" + this.maximum + "]";
28+
}
29+
}
30+
31+
export class Details {
32+
constructor(
33+
public cardinality: Cardinality,
34+
public length: Length,
35+
public empty: boolean,
36+
public total: boolean
37+
) { }
38+
39+
toString(): string {
40+
return "Details[cardinality=" + this.cardinality + ", length=" + this.length + ", empty=" + this.empty + ", total=" + this.total + "]";
41+
}
42+
}

0 commit comments

Comments
 (0)