UNPKG

@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.66 kB
'use strict';function n(t){return !!(t&&typeof t=="string")}var 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(t)||!n(r)?this.toString():this.toString().split(t).join(r)};var g=t=>n(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())};var p=t=>n(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())};var 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())};var 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;