Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvbrdn committed Aug 8, 2024
1 parent ac4456e commit b75f085
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,15 @@ In order to use the library you need to generate an API Token on our [Developer
```javascript
import { RegexSolver, Term } from 'regexsolver';

async function main() {
RegexSolver.initialize("YOUR TOKEN HERE");
RegexSolver.initialize("YOUR TOKEN HERE");

const term1 = Term.regex("(abc|de|fg){2,}");
const term2 = Term.regex("de.*");
const term3 = Term.regex(".*abc");
const term1 = Term.regex("(abc|de|fg){2,}");
const term2 = Term.regex("de.*");
const term3 = Term.regex(".*abc");

const term4 = Term.regex(".+(abc|de).+");
const term4 = Term.regex(".+(abc|de).+");

let result = await term1.intersection(term2, term3);
result = await result.subtraction(term4);

console.log(result.toString());
}
term1.intersection(term2, term3)
.then(result => result.subtraction(term4))
.then(result => console.log(result.toString()));
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "regexsolver",
"version": "1.0.0",
"version": "1.0.1",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"types": "lib/index.d.ts",
Expand Down
11 changes: 8 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export class RegexSolver {
instance.apiClient = axios.create({
baseURL: baseURL,
headers: {
'Authorization': `Bearer ${apiToken}`
'Authorization': `Bearer ${apiToken}`,
'User-Agent': 'RegexSolver Node.js / 1.0.1',
}
});
}
Expand Down Expand Up @@ -82,7 +83,7 @@ export class Term {

private details?: Details;
constructor(
private type: string,
private type: 'regex' | 'fair',
private value: string
) {
}
Expand All @@ -95,6 +96,10 @@ export class Term {
return new Term(Term.FAIR_PREFIX, fair);
}

getType(): 'regex' | 'fair' {
return this.type;
}

getFair(): string | void {
if (this.type == Term.FAIR_PREFIX) {
return this.value;
Expand Down Expand Up @@ -166,7 +171,7 @@ export class Term {
}

interface TermTransient {
type: string;
type: 'regex' | 'fair';
value: string;
}

Expand Down

0 comments on commit b75f085

Please sign in to comment.