2016-07-07 23:23:18 +02:00
|
|
|
/**
|
2016-08-10 21:36:11 +02:00
|
|
|
* String prototype extension.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Capitalize a string.
|
|
|
|
*
|
|
|
|
* @return Capitalized string.
|
2016-07-07 23:23:18 +02:00
|
|
|
*/
|
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);
|
|
|
|
};
|
|
|
|
|
2016-08-10 21:36:11 +02:00
|
|
|
|
2016-07-07 23:23:18 +02:00
|
|
|
/**
|
|
|
|
* Strip characters at the end of a string.
|
|
|
|
*
|
|
|
|
* @param chars A regex-like element to strip from the end.
|
2016-08-10 21:36:11 +02:00
|
|
|
* @return Stripped string.
|
2016-07-07 23:23:18 +02:00
|
|
|
*/
|
|
|
|
String.prototype.rstrip = function (chars) {
|
2016-08-05 00:00:25 +02:00
|
|
|
let regex = new RegExp(chars + "$");
|
2016-07-07 23:23:18 +02:00
|
|
|
return this.replace(regex, "");
|
|
|
|
};
|