jsshort
Version:
It will make your codes much short and easiar
95 lines (94 loc) • 2.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.locCmp = exports.chCdAt = exports.at = exports.rpcA = exports.rpc = exports.trE = exports.trS = exports.lwr = exports.upr = exports.end = exports.start = exports.inString = exports.lstInd = exports.ind = exports.sb = exports.add = exports.str = exports.len = void 0;
function len() {
return this.length;
}
exports.len = len;
function str() {
return this.toString();
}
exports.str = str;
function add(...strings) {
return this.concat(...strings);
}
exports.add = add;
function sb(start, end) {
return this.substring(start, end);
}
exports.sb = sb;
function ind(substring) {
return this.indexOf(substring);
}
exports.ind = ind;
function lstInd(substring) {
return this.lastIndexOf(substring);
}
exports.lstInd = lstInd;
function inString(substring) {
return this.includes(substring);
}
exports.inString = inString;
function start(substring) {
return this.startsWith(substring);
}
exports.start = start;
function end(substring) {
return this.endsWith(substring);
}
exports.end = end;
function upr() {
return this.toUpperCase();
}
exports.upr = upr;
function lwr() {
return this.toLowerCase();
}
exports.lwr = lwr;
function trS() {
return this.trimStart();
}
exports.trS = trS;
function trE() {
return this.trimEnd();
}
exports.trE = trE;
function rpc(stringOrRegex, newSubstring) {
return this.replace(stringOrRegex, newSubstring);
}
exports.rpc = rpc;
function rpcA(stringOrRegex, newSubstring) {
return this.replace(stringOrRegex, newSubstring);
}
exports.rpcA = rpcA;
function at(index) {
return this.charAt(index);
}
exports.at = at;
function chCdAt(index) {
return this.charCodeAt(index);
}
exports.chCdAt = chCdAt;
function locCmp(compareString) {
return this.localeCompare(compareString);
}
exports.locCmp = locCmp;
// Add the methods to String.prototype
String.prototype.len = len;
String.prototype.str = str;
String.prototype.add = add;
String.prototype.sb = sb;
String.prototype.ind = ind;
String.prototype.lstInd = lstInd;
String.prototype.inString = inString;
String.prototype.start = start;
String.prototype.end = end;
String.prototype.upr = upr;
String.prototype.lwr = lwr;
String.prototype.trS = trS;
String.prototype.trE = trE;
String.prototype.rpc = rpc;
String.prototype.rpcA = rpcA;
String.prototype.at = at;
String.prototype.chCdAt = chCdAt;
String.prototype.locCmp = locCmp;