@newdash/newdash
Version:
javascript/typescript utility library
37 lines (36 loc) • 691 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.appendSuffix = exports.addSuffix = void 0;
/**
* add suffix to string
*
* @since 5.14.0
* @category String
* @param str to be processed string
* @param suffix prefix string
*
* @see [[addPrefix]]
*
*
* ```js
* addSuffix("123456", "456")
* // => '123456'
* addSuffix("123", "123")
* // => '123456'
* ```
*
*/
function addSuffix(str = "", suffix = "") {
if (!str.endsWith(suffix)) {
return str + suffix;
}
return str;
}
exports.addSuffix = addSuffix;
/**
* @since 5.14.0
* @category String
* @ignore
*/
exports.appendSuffix = addSuffix;
exports.default = addSuffix;