@@ -163,13 +163,16 @@ export function toUpper(original: Expr): CypherFunction {
163163 return new CypherFunction ( "toUpper" , [ original ] ) ;
164164}
165165
166+ /** @inline */
167+ type TrimOption = "BOTH" | "LEADING" | "TRAILING" ;
168+
166169/** Implements a trim function with a trim expression `trim(BOTH 'x' FROM 'xxxhelloxxx')` */
167170class TrimFunction extends CypherFunction {
168- private readonly typeOrInput : "BOTH" | "LEADING" | "TRAILING" ;
171+ private readonly typeOrInput : TrimOption ;
169172 private readonly trimChar : Expr ;
170173 private readonly input : Expr ;
171174
172- constructor ( typeOrInput : "BOTH" | "LEADING" | "TRAILING" , trimChar : Expr , input : Expr ) {
175+ constructor ( typeOrInput : TrimOption , trimChar : Expr , input : Expr ) {
173176 super ( "trim" ) ;
174177 this . typeOrInput = typeOrInput ;
175178 this . trimChar = trimChar ;
@@ -189,13 +192,9 @@ class TrimFunction extends CypherFunction {
189192 * @group Functions
190193 * @category String
191194 */
192- export function trim ( type : "BOTH" | "LEADING" | "TRAILING" , trimChar : Expr , input : Expr ) : CypherFunction ;
195+ export function trim ( type : TrimOption , trimChar : Expr , input : Expr ) : CypherFunction ;
193196export function trim ( input : Expr ) : CypherFunction ;
194- export function trim (
195- typeOrInput : "BOTH" | "LEADING" | "TRAILING" | Expr ,
196- trimChar ?: Expr ,
197- input ?: Expr
198- ) : CypherFunction {
197+ export function trim ( typeOrInput : TrimOption | Expr , trimChar ?: Expr , input ?: Expr ) : CypherFunction {
199198 if ( typeof typeOrInput === "string" ) {
200199 if ( ! trimChar || ! input ) {
201200 throw new Error ( "Invalid parameters in trim. trimChar and input must be valid Expr" ) ;
0 commit comments