string-filters
Advanced tools
| export default function _default(): void; |
+72
-40
| /*! | ||
| * String Filters v0.3.6 | ||
| * String Filters v0.3.7 | ||
| * Homepage (https://github.com/tarkhov/js-string-filters) | ||
@@ -7,57 +7,89 @@ * Copyright 2026 Tarkhov | ||
| */ | ||
| function l(n, t = !1) { | ||
| let r = n.charAt(0).toUpperCase(), e = n.slice(1); | ||
| return t && (e = e.toLowerCase()), `${r}${e}`; | ||
| function l(t, n = !1) { | ||
| if (!t) return null; | ||
| let r = t.charAt(0).toUpperCase(), e = t.slice(1); | ||
| return n && (e = e.toLowerCase()), `${r}${e}`; | ||
| } | ||
| function o(n, t = { numbers: !1, lower: !1 }) { | ||
| const r = t?.numbers ? /[\p{L}\p{N}]+/gu : new RegExp("\\p{L}+", "gu"); | ||
| let e = n.match(r); | ||
| if (e.length <= 1) return null; | ||
| let a = e.shift(); | ||
| const u = t?.lower; | ||
| return u && (a = a.toLowerCase()), e = e.map((s) => l(s, u)), e.unshift(a), e.join(""); | ||
| function i(t, n = { numbers: !1, lower: !1 }) { | ||
| if (!t) return null; | ||
| const r = n?.numbers ? /[\p{L}\p{N}]+/gu : new RegExp("\\p{L}+", "gu"); | ||
| let e = t.match(r); | ||
| if (!e || e.length <= 1) return null; | ||
| let u = e.shift(); | ||
| const a = n?.lower; | ||
| return a && (u = u.toLowerCase()), e = e.map((o) => l(o, a)), e.unshift(u), e.join(""); | ||
| } | ||
| function p(n, t = !1) { | ||
| let r = t ? /[\p{L}\p{N}]+/gu : new RegExp("\\p{L}+", "gu"), e = n.match(r); | ||
| return e.length <= 1 ? null : e.map((a) => a.toLowerCase()).join(""); | ||
| function p(t, n = !1) { | ||
| if (!t) return null; | ||
| let r = n ? /[\p{L}\p{N}]+/gu : new RegExp("\\p{L}+", "gu"), e = t.match(r); | ||
| return !e || e.length <= 1 ? null : e.map((u) => u.toLowerCase()).join(""); | ||
| } | ||
| function f(n, t = !1) { | ||
| let r = t ? /[\p{L}\p{N}-]+/gu : /[\p{L}-]+/gu, e = n.match(r); | ||
| return e.length <= 1 ? null : e.map((a) => a.toLowerCase()).join("-"); | ||
| function f(t, n = !1) { | ||
| if (!t) return null; | ||
| let r = n ? /[\p{L}\p{N}-]+/gu : /[\p{L}-]+/gu, e = t.match(r); | ||
| return !e || e.length <= 1 ? null : e.map((u) => u.toLowerCase()).join("-"); | ||
| } | ||
| function i(n, t, r = " ") { | ||
| const e = Math.floor((t - n.length) / 2) + n.length; | ||
| return n.padStart(e, r).padEnd(t, r); | ||
| function s(t, n, r = " ") { | ||
| if (!t) return null; | ||
| const e = Math.floor((n - t.length) / 2) + t.length; | ||
| return t.padStart(e, r).padEnd(n, r); | ||
| } | ||
| function c(n, t = { numbers: !1, lower: !1 }) { | ||
| const r = t?.numbers ? /[\p{L}\p{N}]+/gu : new RegExp("\\p{L}+", "gu"); | ||
| let e = n.match(r); | ||
| return e.length <= 1 ? null : e.map((a) => l(a, t?.lower)).join(""); | ||
| function c(t, n = { numbers: !1, lower: !1 }) { | ||
| if (!t) return null; | ||
| const r = n?.numbers ? /[\p{L}\p{N}]+/gu : new RegExp("\\p{L}+", "gu"); | ||
| let e = t.match(r); | ||
| return !e || e.length <= 1 ? null : e.map((u) => l(u, n?.lower)).join(""); | ||
| } | ||
| function g(n, t = !1) { | ||
| let r = t ? /[\p{L}\p{N}_]+/gu : /[\p{L}_]+/gu, e = n.match(r); | ||
| return e.length <= 1 ? null : e.map((a) => a.toLowerCase()).join("_"); | ||
| function h(t, n = !1) { | ||
| if (!t) return null; | ||
| let r = n ? /[\p{L}\p{N}_]+/gu : /[\p{L}_]+/gu, e = t.match(r); | ||
| return !e || e.length <= 1 ? null : e.map((u) => u.toLowerCase()).join("_"); | ||
| } | ||
| function m(n, t = !1) { | ||
| return n.replace(new RegExp("\\p{L}+", "gu"), (r) => l(r, t)); | ||
| function m(t, n = !1) { | ||
| return t ? t.replace(new RegExp("\\p{L}+", "gu"), (r) => l(r, n)) : null; | ||
| } | ||
| function L(n, t = { numbers: !1, lower: !1 }) { | ||
| const r = t?.numbers ? /[\p{L}\p{N}-]+/gu : /[\p{L}-]+/gu; | ||
| let e = n.match(r); | ||
| return e.length <= 1 ? null : e.map((a) => l(a, t?.lower)).join("-"); | ||
| function C(t, n = { numbers: !1, lower: !1 }) { | ||
| if (!t) return null; | ||
| const r = n?.numbers ? /[\p{L}\p{N}-]+/gu : /[\p{L}-]+/gu; | ||
| let e = t.match(r); | ||
| return !e || e.length <= 1 ? null : e.map((u) => l(u, n?.lower)).join("-"); | ||
| } | ||
| function w(n, t = 32, r = "...") { | ||
| return n.substring(0, t) + r; | ||
| function g(t, n = 32, r = "...") { | ||
| return t ? t.substring(0, n) + r : null; | ||
| } | ||
| function L() { | ||
| String.prototype.camelCase = function(t) { | ||
| return i(this, t); | ||
| }, String.prototype.capitalize = function(t) { | ||
| return l(this, t); | ||
| }, String.prototype.flatCase = function(t) { | ||
| return p(this, t); | ||
| }, String.prototype.kebabCase = function(t) { | ||
| return f(this, t); | ||
| }, String.prototype.pad = function(t, n) { | ||
| return s(this, t, n); | ||
| }, String.prototype.pascalCase = function(t) { | ||
| return c(this, t); | ||
| }, String.prototype.snakeCase = function(t) { | ||
| return h(this, t); | ||
| }, String.prototype.titleCase = function(t) { | ||
| return m(this, t); | ||
| }, String.prototype.trainCase = function(t) { | ||
| return C(this, t); | ||
| }, String.prototype.truncate = function(t, n) { | ||
| return g(this, t, n); | ||
| }; | ||
| } | ||
| export { | ||
| o as camelCase, | ||
| i as camelCase, | ||
| l as capitalize, | ||
| p as flatCase, | ||
| f as kebabCase, | ||
| i as pad, | ||
| s as pad, | ||
| c as pascalCase, | ||
| g as snakeCase, | ||
| h as snakeCase, | ||
| m as titleCase, | ||
| L as trainCase, | ||
| w as truncate | ||
| C as trainCase, | ||
| g as truncate, | ||
| L as useProto | ||
| }; |
| /*! | ||
| * String Filters v0.3.6 | ||
| * String Filters v0.3.7 | ||
| * Homepage (https://github.com/tarkhov/js-string-filters) | ||
@@ -7,2 +7,2 @@ * Copyright 2026 Tarkhov | ||
| */ | ||
| (function(l,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(l=typeof globalThis<"u"?globalThis:l||self,u(l.StringFilters={}))})(this,(function(l){"use strict";function u(n,t=!1){let a=n.charAt(0).toUpperCase(),e=n.slice(1);return t&&(e=e.toLowerCase()),`${a}${e}`}function f(n,t={numbers:!1,lower:!1}){const a=t?.numbers?/[\p{L}\p{N}]+/gu:new RegExp("\\p{L}+","gu");let e=n.match(a);if(e.length<=1)return null;let r=e.shift();const s=t?.lower;return s&&(r=r.toLowerCase()),e=e.map(C=>u(C,s)),e.unshift(r),e.join("")}function i(n,t=!1){let a=t?/[\p{L}\p{N}]+/gu:new RegExp("\\p{L}+","gu"),e=n.match(a);return e.length<=1?null:e.map(r=>r.toLowerCase()).join("")}function o(n,t=!1){let a=t?/[\p{L}\p{N}-]+/gu:/[\p{L}-]+/gu,e=n.match(a);return e.length<=1?null:e.map(r=>r.toLowerCase()).join("-")}function p(n,t,a=" "){const e=Math.floor((t-n.length)/2)+n.length;return n.padStart(e,a).padEnd(t,a)}function c(n,t={numbers:!1,lower:!1}){const a=t?.numbers?/[\p{L}\p{N}]+/gu:new RegExp("\\p{L}+","gu");let e=n.match(a);return e.length<=1?null:e.map(r=>u(r,t?.lower)).join("")}function m(n,t=!1){let a=t?/[\p{L}\p{N}_]+/gu:/[\p{L}_]+/gu,e=n.match(a);return e.length<=1?null:e.map(r=>r.toLowerCase()).join("_")}function d(n,t=!1){return n.replace(new RegExp("\\p{L}+","gu"),a=>u(a,t))}function g(n,t={numbers:!1,lower:!1}){const a=t?.numbers?/[\p{L}\p{N}-]+/gu:/[\p{L}-]+/gu;let e=n.match(a);return e.length<=1?null:e.map(r=>u(r,t?.lower)).join("-")}function h(n,t=32,a="..."){return n.substring(0,t)+a}l.camelCase=f,l.capitalize=u,l.flatCase=i,l.kebabCase=o,l.pad=p,l.pascalCase=c,l.snakeCase=m,l.titleCase=d,l.trainCase=g,l.truncate=h,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})})); | ||
| (function(u,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(u=typeof globalThis<"u"?globalThis:u||self,l(u.StringFilters={}))})(this,(function(u){"use strict";function l(t,n=!1){if(!t)return null;let r=t.charAt(0).toUpperCase(),e=t.slice(1);return n&&(e=e.toLowerCase()),`${r}${e}`}function i(t,n={numbers:!1,lower:!1}){if(!t)return null;const r=n?.numbers?/[\p{L}\p{N}]+/gu:new RegExp("\\p{L}+","gu");let e=t.match(r);if(!e||e.length<=1)return null;let a=e.shift();const d=n?.lower;return d&&(a=a.toLowerCase()),e=e.map(L=>l(L,d)),e.unshift(a),e.join("")}function o(t,n=!1){if(!t)return null;let r=n?/[\p{L}\p{N}]+/gu:new RegExp("\\p{L}+","gu"),e=t.match(r);return!e||e.length<=1?null:e.map(a=>a.toLowerCase()).join("")}function f(t,n=!1){if(!t)return null;let r=n?/[\p{L}\p{N}-]+/gu:/[\p{L}-]+/gu,e=t.match(r);return!e||e.length<=1?null:e.map(a=>a.toLowerCase()).join("-")}function s(t,n,r=" "){if(!t)return null;const e=Math.floor((n-t.length)/2)+t.length;return t.padStart(e,r).padEnd(n,r)}function p(t,n={numbers:!1,lower:!1}){if(!t)return null;const r=n?.numbers?/[\p{L}\p{N}]+/gu:new RegExp("\\p{L}+","gu");let e=t.match(r);return!e||e.length<=1?null:e.map(a=>l(a,n?.lower)).join("")}function c(t,n=!1){if(!t)return null;let r=n?/[\p{L}\p{N}_]+/gu:/[\p{L}_]+/gu,e=t.match(r);return!e||e.length<=1?null:e.map(a=>a.toLowerCase()).join("_")}function h(t,n=!1){return t?t.replace(new RegExp("\\p{L}+","gu"),r=>l(r,n)):null}function C(t,n={numbers:!1,lower:!1}){if(!t)return null;const r=n?.numbers?/[\p{L}\p{N}-]+/gu:/[\p{L}-]+/gu;let e=t.match(r);return!e||e.length<=1?null:e.map(a=>l(a,n?.lower)).join("-")}function m(t,n=32,r="..."){return t?t.substring(0,n)+r:null}function g(){String.prototype.camelCase=function(t){return i(this,t)},String.prototype.capitalize=function(t){return l(this,t)},String.prototype.flatCase=function(t){return o(this,t)},String.prototype.kebabCase=function(t){return f(this,t)},String.prototype.pad=function(t,n){return s(this,t,n)},String.prototype.pascalCase=function(t){return p(this,t)},String.prototype.snakeCase=function(t){return c(this,t)},String.prototype.titleCase=function(t){return h(this,t)},String.prototype.trainCase=function(t){return C(this,t)},String.prototype.truncate=function(t,n){return m(this,t,n)}}u.camelCase=i,u.capitalize=l,u.flatCase=o,u.kebabCase=f,u.pad=s,u.pascalCase=p,u.snakeCase=c,u.titleCase=h,u.trainCase=C,u.truncate=m,u.useProto=g,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})})); |
@@ -11,2 +11,3 @@ import camelCase from './camelCase'; | ||
| import truncate from './truncate'; | ||
| export { camelCase, capitalize, flatCase, kebabCase, pad, pascalCase, snakeCase, titleCase, trainCase, truncate }; | ||
| import useProto from './useProto'; | ||
| export { camelCase, capitalize, flatCase, kebabCase, pad, pascalCase, snakeCase, titleCase, trainCase, truncate, useProto }; |
+1
-1
| { | ||
| "name": "string-filters", | ||
| "version": "0.3.6", | ||
| "version": "0.3.7", | ||
| "description": "Fast native javascript string filters library.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
+0
-10
@@ -10,3 +10,2 @@ # Javascript String Filters | ||
| 1. [NPM](#npm) | ||
| 2. [Manually](#manually) | ||
| 3. [Usage](#usage) | ||
@@ -43,11 +42,2 @@ 1. [Camel case](#camel-case) | ||
| ### Manually | ||
| [Download](https://github.com/tarkhov/js-string-filters/releases/download/v0.3.6/js-string-filters.zip) package and unpack it or use following commands: | ||
| ```bash | ||
| wget https://github.com/tarkhov/js-string-filters/releases/download/v0.3.6/js-string-filters.zip | ||
| unzip js-string-filters.zip | ||
| ``` | ||
| ## Usage | ||
@@ -54,0 +44,0 @@ |
13511
12.69%17
6.25%142
35.24%223
-4.29%