@newdash/newdash
Version:
javascript/typescript utility library
32 lines (31 loc) • 609 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.trimPrefix = void 0;
/**
* remove prefix from string
*
* @since 5.5.0
* @category String
* @param str to be processed string
* @param prefix prefix string
*
* @see [[trimSuffix]]
*
*
* ```js
* trimPrefix("123456", "123")
* // => '456'
* ```
*
*/
function trimPrefix(str, prefix) {
if (prefix.length > str.length) {
return str;
}
if (str.startsWith(prefix)) {
return str.substr(prefix.length);
}
return str;
}
exports.trimPrefix = trimPrefix;
exports.default = trimPrefix;