diff --git a/src/__snapshots__/index.spec.ts.snap b/src/__snapshots__/index.spec.ts.snap index b56c420..3c0aa46 100644 --- a/src/__snapshots__/index.spec.ts.snap +++ b/src/__snapshots__/index.spec.ts.snap @@ -74,6 +74,7 @@ Array [ "$pipe", "$string", "$stringConcat", + "$stringEndsWith", "$stringInterpolate", "$stringLength", "$stringPadEnd", diff --git a/src/expressions/string.spec.ts b/src/expressions/string.spec.ts index 7ea3264..7b947d7 100644 --- a/src/expressions/string.spec.ts +++ b/src/expressions/string.spec.ts @@ -49,6 +49,13 @@ describe('$stringStartsWith', () => { ]) }) +describe('$stringEndsWith', () => { + _evTestCases([ + ['some_string', ['$stringEndsWith', '_string'], true], + ['some_string', ['$stringEndsWith', 'somethingelse'], false], + ]) +}) + describe('$stringLength', () => { _evTestCases([ ['some_string', ['$stringLength'], 11], diff --git a/src/expressions/string.ts b/src/expressions/string.ts index 9866fec..fef1dbd 100644 --- a/src/expressions/string.ts +++ b/src/expressions/string.ts @@ -62,6 +62,17 @@ export const $stringStartsWith: InterpreterSpec = [ ['string', 'string'], ] +/** + * @function $stringEndsWith + * @param {String} query + * @param {string} [str=$$VALUE] + * @returns {Boolean} + */ +export const $stringEndsWith: InterpreterSpec = [ + (query: string, str: string): boolean => str.endsWith(query), + ['string', 'string'], +] + /** * @function $stringLength * @param {String} [str=$$VALUE] @@ -200,6 +211,7 @@ export const $stringInterpolate: InterpreterSpec = [ export const STRING_EXPRESSIONS = { $string, $stringStartsWith, + $stringEndsWith, $stringLength, $stringSubstr, $stringConcat,