2023-01-09 19:02:19 -05:00
import { BooleanData , ExpressionData } from "../data" ;
import { toUpperSpecial } from "../result" ;
import { FunctionDefinition } from "./info" ;
2023-01-06 15:54:31 -08:00
export const endswith : FunctionDefinition = {
name : "endsWith" ,
description :
"`endsWith( searchString, searchValue )`\n\nReturns `true` if `searchString` ends with `searchValue`. This function is not case sensitive. Casts values to a string." ,
minArgs : 2 ,
maxArgs : 2 ,
call : (... args : ExpressionData []) : ExpressionData => {
const left = args [ 0 ];
if ( ! left . primitive ) {
return new BooleanData ( false );
}
const right = args [ 1 ];
if ( ! right . primitive ) {
return new BooleanData ( false );
}
const ls = toUpperSpecial ( left . coerceString ());
const rs = toUpperSpecial ( right . coerceString ());
return new BooleanData ( ls . endsWith ( rs ));
2023-01-09 19:02:19 -05:00
}
2023-01-06 15:54:31 -08:00
};