Files
languageservices/expressions/src/funcs/endswith.ts
T

28 lines
830 B
TypeScript
Raw Normal View History

2023-01-09 19:02:19 -05:00
import {BooleanData, ExpressionData} from "../data";
import {toUpperSpecial} from "../result";
import {FunctionDefinition} from "./info";
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
}
};