31 lines
901 B
TypeScript
31 lines
901 B
TypeScript
export const StringExtensions = () => {
|
|
if ("".isEmpty === undefined) {
|
|
// eslint-disable-next-line no-extend-native
|
|
String.prototype.isEmpty = function () {
|
|
return this.length === 0;
|
|
};
|
|
}
|
|
if ("".isNotEmpty === undefined) {
|
|
// eslint-disable-next-line no-extend-native
|
|
String.prototype.isNotEmpty = function () {
|
|
return this.length !== 0;
|
|
};
|
|
}
|
|
if ("".lastElement === undefined) {
|
|
String.prototype.lastElement = function () {
|
|
return this[this.length - 1];
|
|
};
|
|
}
|
|
if ("".fixToPath === undefined) {
|
|
// eslint-disable-next-line no-extend-native
|
|
String.prototype.fixToPath = function () {
|
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
let result = this;
|
|
const symbolPath = "/";
|
|
if (this.lastElement != symbolPath) {
|
|
result = result.slice(0, -1);
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
};
|