@@ -70,9 +70,9 @@ function selectQuote(
70
70
}
71
71
}
72
72
73
- function escapeValue ( value : string , opts : EmitOptions ) {
73
+ function escapeValue ( value : string , options : EmitOptions ) {
74
74
if ( value === "" || ReservedChars . some ( ( reservedChar ) => value . includes ( reservedChar ) ) ) {
75
- const quote = selectQuote ( value , opts ) ;
75
+ const quote = selectQuote ( value , options ) ;
76
76
return `${ quote } ${ escapeQuotes ( value , quote ) } ${ quote } ` ;
77
77
}
78
78
@@ -83,19 +83,19 @@ function emitSelector(node: SelectorNode) {
83
83
return node . selector ;
84
84
}
85
85
86
- function emitValue ( node : ValueNode , opts : EmitOptions ) {
86
+ function emitValue ( node : ValueNode , options : EmitOptions ) {
87
87
return Array . isArray ( node . value )
88
- ? `(${ node . value . map ( ( value ) => escapeValue ( value , opts ) ) . join ( "," ) } )`
89
- : escapeValue ( node . value , opts ) ;
88
+ ? `(${ node . value . map ( ( value ) => escapeValue ( value , options ) ) . join ( "," ) } )`
89
+ : escapeValue ( node . value , options ) ;
90
90
}
91
91
92
- function emitComparison ( node : ComparisonNode , opts : EmitOptions ) {
93
- return `${ emitSelector ( node . left ) } ${ node . operator } ${ emitValue ( node . right , opts ) } ` ;
92
+ function emitComparison ( node : ComparisonNode , options : EmitOptions ) {
93
+ return `${ emitSelector ( node . left ) } ${ node . operator } ${ emitValue ( node . right , options ) } ` ;
94
94
}
95
95
96
- function emitLogic ( node : LogicNode , opts : EmitOptions ) {
97
- let left = emitWithoutOptsValidation ( node . left , opts ) ;
98
- let right = emitWithoutOptsValidation ( node . right , opts ) ;
96
+ function emitLogic ( node : LogicNode , options : EmitOptions ) {
97
+ let left = emitWithoutOptionsValidation ( node . left , options ) ;
98
+ let right = emitWithoutOptionsValidation ( node . right , options ) ;
99
99
100
100
// handle operator precedence - as it's only the case for AND operator, we don't need a generic logic for that
101
101
if ( isLogicOperator ( node . operator , AND ) ) {
@@ -113,23 +113,23 @@ function emitLogic(node: LogicNode, opts: EmitOptions) {
113
113
return `${ left } ${ operator } ${ right } ` ;
114
114
}
115
115
116
- function emitWithoutOptsValidation ( expression : ExpressionNode , opts : EmitOptions ) : string {
116
+ function emitWithoutOptionsValidation ( expression : ExpressionNode , options : EmitOptions ) : string {
117
117
if ( isComparisonNode ( expression ) ) {
118
- return emitComparison ( expression , opts ) ;
118
+ return emitComparison ( expression , options ) ;
119
119
} else if ( isLogicNode ( expression ) ) {
120
- return emitLogic ( expression , opts ) ;
120
+ return emitLogic ( expression , options ) ;
121
121
}
122
122
123
123
throw new TypeError ( `The "expression" has to be a valid "ExpressionNode", ${ String ( expression ) } passed.` ) ;
124
124
}
125
125
126
- function emit ( expression : ExpressionNode , opts : EmitOptions = { } ) {
127
- if ( opts . preferredQuote !== undefined && opts . preferredQuote !== '"' && opts . preferredQuote !== "'" ) {
126
+ function emit ( expression : ExpressionNode , options : EmitOptions = { } ) {
127
+ if ( options . preferredQuote !== undefined && options . preferredQuote !== '"' && options . preferredQuote !== "'" ) {
128
128
throw new TypeError (
129
- `Invalid "preferredQuote" option: ${ opts . preferredQuote } . Must be either " (the ASCII double quote character) or ' (the ASCII single quote character).`
129
+ `Invalid "preferredQuote" option: ${ options . preferredQuote } . Must be either " (the ASCII double quote character) or ' (the ASCII single quote character).`
130
130
) ;
131
131
}
132
- return emitWithoutOptsValidation ( expression , opts ) ;
132
+ return emitWithoutOptionsValidation ( expression , options ) ;
133
133
}
134
134
135
135
export { emit , EmitOptions , Quote } ;
0 commit comments