typedash
Version:
modern, type-safe collection of utility functions
26 lines (24 loc) • 666 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
Object.defineProperty(exports, 'ensureSuffix', {
enumerable: true,
get: function () {
return ensureSuffix;
}
});
//# sourceMappingURL=ensureSuffix-D2sbFKA6.cjs.map