ampache_react/app/utils/common/string.js

17 lines
392 B
JavaScript
Raw Normal View History

2016-07-07 23:23:18 +02:00
/**
* Capitalize function on strings.
*/
2016-07-30 22:54:19 +02:00
String.prototype.capitalize = function () {
2016-07-07 23:23:18 +02:00
return this.charAt(0).toUpperCase() + this.slice(1);
};
/**
* Strip characters at the end of a string.
*
* @param chars A regex-like element to strip from the end.
*/
String.prototype.rstrip = function (chars) {
let regex = new RegExp(chars + "$");
2016-07-07 23:23:18 +02:00
return this.replace(regex, "");
};