28 lines
830 B
TypeScript
28 lines
830 B
TypeScript
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));
|
|
}
|
|
};
|