diff --git a/README.md b/README.md index fb24f9c..e7f9dee 100644 --- a/README.md +++ b/README.md @@ -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())); ``` diff --git a/package.json b/package.json index 7506b26..c3f96dd 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.ts b/src/index.ts index 7a3b18f..b3b9270 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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', } }); } @@ -82,7 +83,7 @@ export class Term { private details?: Details; constructor( - private type: string, + private type: 'regex' | 'fair', private value: string ) { } @@ -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; @@ -166,7 +171,7 @@ export class Term { } interface TermTransient { - type: string; + type: 'regex' | 'fair'; value: string; }