@resk/core
Version:
An innovative TypeScript framework that empowers developers to build applications with a fully decorator-based architecture for efficient resource management. By combining the power of decorators with a resource-oriented design, DecorRes enhances code cla
1 lines • 1.84 kB
JavaScript
;var n=require('./isNonNullString');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var n__default=/*#__PURE__*/_interopDefault(n);const e=function(t,r=""){if(!t||typeof t!="string")return "";if(!r||typeof r!="string")return t.trim();let i=t.length;for(;t.startsWith(r)&&i>=0;)t=t.slice(r.length),--i;return t.toString()},o=function(t,r=""){if(!t||typeof t!="string")return "";if(!r||typeof r!="string")return t.trim();let i=t.length;for(;t.endsWith(r)&&i>=0;)t=t.slice(0,-r.length),--i;return t.toString()},s=(t,r=true)=>typeof t!="string"?false:r!==false?/^\d*\.?\d+$/.test(t):/^\d+$/.test(t);String.prototype.ltrim=function(t){return e(this.toString(),t)},String.prototype.rtrim=function(t){return o(this.toString(),t)},String.prototype.isNumber=function(t=true){return s(this.toString(),t)},String.prototype.replaceAll=function(t,r){return !n__default.default(t)||!n__default.default(r)?this.toString():this.toString().split(t).join(r)};const g=t=>n__default.default(t)?(t=t.trim(),t.replace(/(.)([A-Z][a-z]+)/,"$1_$2").replace(/([a-z0-9])([A-Z])/,"$1_$2").toUpperCase()):"";String.prototype.toSnakeCase=function(){return g(this.toString())};const p=t=>n__default.default(t)?(t=t.trim(),t.charAt(0)+t.replace(/(_\w)/g,r=>r[1].toUpperCase()).substring(1)):"";String.prototype.toCamelCase=function(){return p(this.toString())};const l=function(t){return !t||typeof t!="string"?"":(t=t.trim(),t.charAt(0).toUpperCase()+t.slice(1))};String.prototype.upperFirst=function(){return l(this.toString())};const a=function(t){return !t||typeof t!="string"?"":(t=t.trim(),t.charAt(0).toLowerCase()+t.slice(1))};String.prototype.lowerFirst=function(){return a(this.toString())};exports.isStringNumber=s;exports.lowerFirst=a;exports.ltrim=e;exports.rtrim=o;exports.toCamelCase=p;exports.toSnakeCase=g;exports.upperFirst=l;