File tree Expand file tree Collapse file tree 3 files changed +17
-15
lines changed
Expand file tree Collapse file tree 3 files changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -20,18 +20,15 @@ In order to use the library you need to generate an API Token on our [Developer
2020``` javascript
2121import { RegexSolver , Term } from ' regexsolver' ;
2222
23- async function main () {
24- RegexSolver .initialize (" YOUR TOKEN HERE" );
23+ RegexSolver .initialize (" YOUR TOKEN HERE" );
2524
26- const term1 = Term .regex (" (abc|de|fg){2,}" );
27- const term2 = Term .regex (" de.*" );
28- const term3 = Term .regex (" .*abc" );
25+ const term1 = Term .regex (" (abc|de|fg){2,}" );
26+ const term2 = Term .regex (" de.*" );
27+ const term3 = Term .regex (" .*abc" );
2928
30- const term4 = Term .regex (" .+(abc|de).+" );
29+ const term4 = Term .regex (" .+(abc|de).+" );
3130
32- let result = await term1 .intersection (term2, term3);
33- result = await result .subtraction (term4);
34-
35- console .log (result .toString ());
36- }
31+ term1 .intersection (term2, term3)
32+ .then (result => result .subtraction (term4))
33+ .then (result => console .log (result .toString ()));
3734```
Original file line number Diff line number Diff line change 11{
22 "name" : " regexsolver" ,
3- "version" : " 1.0.0 " ,
3+ "version" : " 1.0.1 " ,
44 "main" : " lib/index.js" ,
55 "typings" : " lib/index.d.ts" ,
66 "types" : " lib/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ export class RegexSolver {
2727 instance . apiClient = axios . create ( {
2828 baseURL : baseURL ,
2929 headers : {
30- 'Authorization' : `Bearer ${ apiToken } `
30+ 'Authorization' : `Bearer ${ apiToken } ` ,
31+ 'User-Agent' : 'RegexSolver Node.js / 1.0.1' ,
3132 }
3233 } ) ;
3334 }
@@ -82,7 +83,7 @@ export class Term {
8283
8384 private details ?: Details ;
8485 constructor (
85- private type : string ,
86+ private type : 'regex' | 'fair' ,
8687 private value : string
8788 ) {
8889 }
@@ -95,6 +96,10 @@ export class Term {
9596 return new Term ( Term . FAIR_PREFIX , fair ) ;
9697 }
9798
99+ getType ( ) : 'regex' | 'fair' {
100+ return this . type ;
101+ }
102+
98103 getFair ( ) : string | void {
99104 if ( this . type == Term . FAIR_PREFIX ) {
100105 return this . value ;
@@ -166,7 +171,7 @@ export class Term {
166171}
167172
168173interface TermTransient {
169- type : string ;
174+ type : 'regex' | 'fair' ;
170175 value : string ;
171176}
172177
You can’t perform that action at this time.
0 commit comments