typedash
Version:
modern, type-safe collection of utility functions
20 lines (19 loc) • 571 B
JavaScript
//#region src/functions/ensureSuffix/ensureSuffix.ts
/**
* Ensures that the string ends with the given suffix.
* @param string The string to ensure the suffix of.
* @param suffix The suffix to ensure.
* @returns The string with the given suffix.
* @example
* ```ts
* ensureSuffix('foo', 'bar'); // 'foobar'
* ensureSuffix('foobar', 'bar'); // 'foobar'
* ```
*/
function ensureSuffix(string, suffix) {
if (string.endsWith(suffix)) return string;
return `${string}${suffix}`;
}
//#endregion
export { ensureSuffix as t };
//# sourceMappingURL=ensureSuffix-DF-ITzzV.js.map