UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

31 lines (30 loc) 619 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.trimSuffix = void 0; /** * remove suffix from string * * @since 5.5.0 * @category String * @param str to be processed string * @param suffix string * * @see [[trimPrefix]] * * ```js * trimSuffix("123456789", "789") * // => '123456' * ``` * */ function trimSuffix(str, suffix) { if (suffix.length > str.length) { return str; } if (str.endsWith(suffix)) { return str.substr(0, str.length - suffix.length); } return str; } exports.trimSuffix = trimSuffix; exports.default = trimSuffix;