@@ -4,7 +4,7 @@ import { FunctionExpressionType } from "./functions/function";
44import { JSONPathNodeList } from "./node" ;
55import { JSONPathQuery } from "./path" ;
66import { Token } from "./token" ;
7- import { FilterContext , Nothing } from "./types" ;
7+ import { FilterContext , Nothing , SerializationOptions } from "./types" ;
88import { isNumber , isString } from "../types" ;
99
1010/**
@@ -22,7 +22,7 @@ export abstract class FilterExpression {
2222 /**
2323 * Return a string representation of the expression.
2424 */
25- public abstract toString ( ) : string ;
25+ public abstract toString ( options ?: SerializationOptions ) : string ;
2626}
2727
2828/**
@@ -112,8 +112,8 @@ export class PrefixExpression extends FilterExpression {
112112 ) ;
113113 }
114114
115- public toString ( ) : string {
116- return `${ this . operator } ${ this . right . toString ( ) } ` ;
115+ public toString ( options ?: SerializationOptions ) : string {
116+ return `${ this . operator } ${ this . right . toString ( options ) } ` ;
117117 }
118118}
119119
@@ -158,13 +158,13 @@ export class InfixExpression extends FilterExpression {
158158 return compare ( left , this . operator , right ) ;
159159 }
160160
161- public toString ( ) : string {
161+ public toString ( options ?: SerializationOptions ) : string {
162162 if ( this . logical ) {
163- return `(${ this . left . toString ( ) } ${
163+ return `(${ this . left . toString ( options ) } ${
164164 this . operator
165- } ${ this . right . toString ( ) } )`;
165+ } ${ this . right . toString ( options ) } )`;
166166 }
167- return `${ this . left . toString ( ) } ${ this . operator } ${ this . right . toString ( ) } ` ;
167+ return `${ this . left . toString ( options ) } ${ this . operator } ${ this . right . toString ( options ) } ` ;
168168 }
169169}
170170
@@ -182,8 +182,8 @@ export class LogicalExpression extends FilterExpression {
182182 return isTruthy ( value ) ;
183183 }
184184
185- public toString ( ) : string {
186- return this . expression . toString ( ) ;
185+ public toString ( options ?: SerializationOptions ) : string {
186+ return this . expression . toString ( options ) ;
187187 }
188188}
189189
@@ -208,8 +208,8 @@ export class RelativeQuery extends FilterQuery {
208208 : this . path . query ( context . currentValue ) ;
209209 }
210210
211- public toString ( ) : string {
212- return `@${ this . path . toString ( ) . slice ( 1 ) } ` ;
211+ public toString ( options ?: SerializationOptions ) : string {
212+ return `@${ this . path . toString ( options ) . slice ( 1 ) } ` ;
213213 }
214214}
215215
@@ -220,8 +220,8 @@ export class RootQuery extends FilterQuery {
220220 : this . path . query ( context . rootValue ) ;
221221 }
222222
223- public toString ( ) : string {
224- return this . path . toString ( ) ;
223+ public toString ( options ?: SerializationOptions ) : string {
224+ return this . path . toString ( options ) ;
225225 }
226226}
227227
@@ -254,8 +254,8 @@ export class FunctionExtension extends FilterExpression {
254254 return func . call ( ...args ) ;
255255 }
256256
257- public toString ( ) : string {
258- return `${ this . name } (${ this . args . map ( ( e ) => e . toString ( ) ) . join ( ", " ) } )` ;
257+ public toString ( options ?: SerializationOptions ) : string {
258+ return `${ this . name } (${ this . args . map ( ( e ) => e . toString ( options ) ) . join ( ", " ) } )` ;
259259 }
260260
261261 private unpack_node_list ( arg : JSONPathNodeList ) : unknown {
0 commit comments