@upfrontjs/framework
Version:
Data handling framework complementary to backend model systems.
8 lines (7 loc) • 3.8 kB
JavaScript
/*! ================================
@upfrontjs/framework v0.19.0
(c) 2020-present Nandor Kraszlan
Released under MIT License
================================== */
import t from"lodash.snakecase";import{validate as e,v4 as r}from"uuid";import n from"pluralize";function i(t){return t.charAt(0).toUpperCase()+t.slice(1)}function o(e){return t(e)}function u(t){return i(o(t)).split("_").reduce((t,e)=>t+" "+i(e))}function p(t){const e=u(t).replace(/ /g,"");return e.charAt(0).toLowerCase()+e.slice(1)}function c(t){return"string"==typeof t&&e(t)}"ucFirst"in String.prototype||Object.defineProperty(String.prototype,"ucFirst",{value:function(){return i(this)}}),"isUuid"in String.prototype||Object.defineProperty(String.prototype,"isUuid",{value:function(){return c(this)}}),"isUuid"in String||Object.defineProperty(String,"isUuid",{value:function(t){return c(t)}}),"uuid"in String||Object.defineProperty(String,"uuid",{value:function(){return r()}}),"finish"in String.prototype||Object.defineProperty(String.prototype,"finish",{value:function(t){return function(t,e){return t.endsWith(e)?t:t+e}(this,t)}}),"start"in String.prototype||Object.defineProperty(String.prototype,"start",{value:function(t){return function(t,e){return t.startsWith(e)?t:e+t}(this,t)}}),"before"in String.prototype||Object.defineProperty(String.prototype,"before",{value:function(t){return function(t,e){return""===e?"":t.includes(e)?t.substring(0,t.indexOf(e)):""}(this,t)}}),"beforeLast"in String.prototype||Object.defineProperty(String.prototype,"beforeLast",{value:function(t){return function(t,e){return""===e?"":t.includes(e)?t.substring(0,t.lastIndexOf(e)):""}(this,t)}}),"after"in String.prototype||Object.defineProperty(String.prototype,"after",{value:function(t){return function(t,e){return""===e?"":t.includes(e)?t.substring(t.indexOf(e)+e.length,t.length):""}(this,t)}}),"afterLast"in String.prototype||Object.defineProperty(String.prototype,"afterLast",{value:function(t){return function(t,e){return""===e?"":t.includes(e)?t.substring(t.lastIndexOf(e)+e.length,t.length):""}(this,t)}}),"pascal"in String.prototype||Object.defineProperty(String.prototype,"pascal",{value:function(){return i(p(this))}}),"title"in String.prototype||Object.defineProperty(String.prototype,"title",{value:function(){return u(this)}}),"snake"in String.prototype||Object.defineProperty(String.prototype,"snake",{value:function(){return o(this)}}),"kebab"in String.prototype||Object.defineProperty(String.prototype,"kebab",{value:function(){return o(this).replace(/_/g,"-")}}),"camel"in String.prototype||Object.defineProperty(String.prototype,"camel",{value:function(){return p(this)}}),"limit"in String.prototype||Object.defineProperty(String.prototype,"limit",{value:function(t,e="..."){return function(t,e,r="..."){const n=t.substring(0,e);return t.length>n.length?n+r:n}(this,t,e)}}),"words"in String.prototype||Object.defineProperty(String.prototype,"words",{value:function(t,e="..."){return function(t,e,r="..."){const n=t.split(" ").slice(0,e).join(" ");return n.length===t.length?t:n+r}(this,t,e)}}),"plural"in String.prototype||Object.defineProperty(String.prototype,"plural",{value:function(){return t=this,n.plural(t);var t}}),"singular"in String.prototype||Object.defineProperty(String.prototype,"singular",{value:function(){return t=this,n.singular(t);var t}}),"is"in String.prototype||Object.defineProperty(String.prototype,"is",{value:function(t,e=!1){return function(t,e,r=!1){"string"==typeof e&&(e=new RegExp(e.replace(/\*/g,".*"),r?"i":""));const n=e.exec(t);return!!n&&!!n.length&&n[0]===t}(this,t,e)}}),"includesAll"in String.prototype||Object.defineProperty(String.prototype,"includesAll",{value:function(t){return function(t,e){return e.every(e=>t.includes(e))}(this,t)}});
//# sourceMappingURL=string.es.min.js.map