@@ -9,7 +9,7 @@ const T = (...args: any) => true;
99const isOrToken = ( token : Token ) : boolean =>
1010 Boolean ( token && token [ 0 ] === "or" ) ;
1111const isNegated = ( token : Token ) : boolean =>
12- Boolean ( token && tokenValue ( token ) [ 0 ] === '-' )
12+ Boolean ( token && tokenValue ( token ) [ 0 ] === "-" ) ;
1313const isWhitespaceToken = ( [ token ] : Token ) : boolean => / ^ \s / . test ( token ) ;
1414const isTextToken = complement ( isWhitespaceToken ) as ( token : Token ) => boolean ;
1515const isLeftOfOr = ( [ , index ] : Token , tokens : Tokens ) : boolean =>
@@ -22,13 +22,10 @@ const tokenIndex = ([, index]: Token) => index;
2222const tokenValue = ( [ value ] : Token ) => value ;
2323
2424const withoutNegation = ( token : Token ) : Token => {
25- const without = tokenValue ( token ) . slice ( 1 )
25+ const without = tokenValue ( token ) . slice ( 1 ) ;
2626
27- return [
28- without ,
29- tokenIndex ( token ) + 1
30- ]
31- }
27+ return [ without , tokenIndex ( token ) + 1 ] ;
28+ } ;
3229
3330function parse ( input : string ) : Tokens {
3431 // Regular expression to match:
@@ -123,7 +120,7 @@ const or = (before: Predicate, token: Predicate) => (issue: string) =>
123120const and = ( before : Predicate , token : Predicate ) => ( issue : string ) =>
124121 before ( issue ) && token ( issue ) ;
125122const not = ( before : Predicate , token : Predicate ) => ( issue : string ) =>
126- ! token ( issue )
123+ ! token ( issue ) ;
127124
128125const predicate =
129126 < T > ( matcher : ( token : Token , value : T ) => boolean ) =>
@@ -139,15 +136,13 @@ const predicate =
139136
140137 const [ token , ...rest ] = tokens ;
141138
142- if ( isOrToken ( token ) || isWhitespaceToken ( token ) ) return passes ( rest , predicate )
139+ if ( isOrToken ( token ) || isWhitespaceToken ( token ) )
140+ return passes ( rest , predicate ) ;
143141
144142 if ( isNegated ( token ) ) {
145- const without = withoutNegation ( token )
143+ const without = withoutNegation ( token ) ;
146144
147- return passes ( rest , and (
148- predicate ,
149- complement ( matches ( without ) )
150- ) )
145+ return passes ( rest , and ( predicate , complement ( matches ( without ) ) ) ) ;
151146 }
152147
153148 // TODO: Consider writing this simpler by deconstructing to get left of or, the or token and the right of or in one go.
0 commit comments