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