🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

string-filters

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-filters - npm Package Compare versions

Comparing version
0.2.0
to
0.3.0
+55
-37
dist/string-filters.js

@@ -1,54 +0,72 @@

function l(e) {
let n = e.charAt(0).toUpperCase(), r = e.slice(1).toLowerCase();
return `${n}${r}`;
function a(r, e = !1) {
let n = r.charAt(0).toUpperCase(), t = r.slice(1);
return e && (t = t.toLowerCase()), `${n}${t}`;
}
function p(e, n = !1) {
let r = n ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu, t = e.match(r);
function s(r, e = { numbers: !1, lower: !1 }) {
let n = /[\p{L}]+/gu;
typeof e.numbers < "u" && e.numbers && (n = /[\p{L}\p{N}]+/gu);
let t = r.match(n);
if (t.length <= 1)
return null;
let a = t.shift();
return a = a.toLowerCase(), t = t.map((u) => l(u)), t.unshift(a), t.join("");
let l = t.shift();
const u = typeof e.lower < "u" ? e.lower : !1;
return u && (l = l.toLowerCase()), t = t.map((f) => a(f, u)), t.unshift(l), t.join("");
}
function o(e, n = !1) {
let r = n ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu, t = e.match(r);
return t.length <= 1 ? null : t.map((a) => a.toLowerCase()).join("");
function o(r, e = !1) {
let n = e ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu, t = r.match(n);
return t.length <= 1 ? null : t.map((l) => l.toLowerCase()).join("");
}
function s(e, n = !1) {
let r = n ? /[\p{L}\p{N}-]+/gu : /[\p{L}-]+/gu, t = e.match(r);
return t.length <= 1 ? null : t.map((a) => a.toLowerCase()).join("-");
function p(r, e = !1) {
let n = e ? /[\p{L}\p{N}-]+/gu : /[\p{L}-]+/gu, t = r.match(n);
return t.length <= 1 ? null : t.map((l) => l.toLowerCase()).join("-");
}
function i(e, n, r = " ") {
const t = Math.floor((n - e.length) / 2) + e.length;
return e.padStart(t, r).padEnd(n, r);
function i(r, e, n = " ") {
const t = Math.floor((e - r.length) / 2) + r.length;
return r.padStart(t, n).padEnd(e, n);
}
function f(e, n = !1) {
let r = n ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu, t = e.match(r);
return t.length <= 1 ? null : t.map((a) => l(a)).join("");
function w(r, e = { numbers: !1, lower: !1 }) {
let n = /[\p{L}]+/gu;
typeof e.numbers < "u" && e.numbers && (n = /[\p{L}\p{N}]+/gu);
let t = r.match(n);
if (t.length <= 1)
return null;
const l = typeof e.lower < "u" ? e.lower : !1;
return t.map((u) => a(u, l)).join("");
}
function c(e, n = !1) {
let r = n ? /[\p{L}\p{N}_]+/gu : /[\p{L}_]+/gu, t = e.match(r);
return t.length <= 1 ? null : t.map((a) => a.toLowerCase()).join("_");
function c(r, e = !1) {
let n = e ? /[\p{L}\p{N}_]+/gu : /[\p{L}_]+/gu, t = r.match(n);
return t.length <= 1 ? null : t.map((l) => l.toLowerCase()).join("_");
}
function g(e, n = !1) {
let r = n ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu, t = e.match(r);
return t.length <= 1 ? null : t.map((a) => l(a)).join(" ");
function d(r, e = { numbers: !1, lower: !1 }) {
let n = /[\p{L}]+/gu;
typeof e.numbers < "u" && e.numbers && (n = /[\p{L}\p{N}]+/gu);
let t = r.match(n);
if (t.length <= 1)
return null;
const l = typeof e.lower < "u" ? e.lower : !1;
return t.map((u) => a(u, l)).join(" ");
}
function L(e, n = !1) {
let r = n ? /[\p{L}\p{N}-]+/gu : /[\p{L}-]+/gu, t = e.match(r);
return t.length <= 1 ? null : t.map((a) => l(a)).join("-");
function m(r, e = { numbers: !1, lower: !1 }) {
let n = /[\p{L}-]+/gu;
typeof e.numbers < "u" && e.numbers && (n = /[\p{L}\p{N}-]+/gu);
let t = r.match(n);
if (t.length <= 1)
return null;
const l = typeof e.lower < "u" ? e.lower : !1;
return t.map((u) => a(u, l)).join("-");
}
function h(e, n = 32, r = "...") {
return e.substring(0, n) + r;
function g(r, e = 32, n = "...") {
return r.substring(0, e) + n;
}
export {
p as camelCase,
l as capitalize,
s as camelCase,
a as capitalize,
o as flatCase,
s as kebabCase,
p as kebabCase,
i as pad,
f as pascalCase,
w as pascalCase,
c as snakeCase,
g as titleCase,
L as trainCase,
h as truncate
d as titleCase,
m as trainCase,
g as truncate
};

@@ -1,1 +0,1 @@

(function(l,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(l=typeof globalThis<"u"?globalThis:l||self,r(l.StringFilters={}))})(this,(function(l){"use strict";function r(t){let n=t.charAt(0).toUpperCase(),a=t.slice(1).toLowerCase();return`${n}${a}`}function i(t,n=!1){let a=n?/[\p{L}\p{N}]+/gu:/[\p{L}]+/gu,e=t.match(a);if(e.length<=1)return null;let u=e.shift();return u=u.toLowerCase(),e=e.map(C=>r(C)),e.unshift(u),e.join("")}function f(t,n=!1){let a=n?/[\p{L}\p{N}]+/gu:/[\p{L}]+/gu,e=t.match(a);return e.length<=1?null:e.map(u=>u.toLowerCase()).join("")}function p(t,n=!1){let a=n?/[\p{L}\p{N}-]+/gu:/[\p{L}-]+/gu,e=t.match(a);return e.length<=1?null:e.map(u=>u.toLowerCase()).join("-")}function s(t,n,a=" "){const e=Math.floor((n-t.length)/2)+t.length;return t.padStart(e,a).padEnd(n,a)}function o(t,n=!1){let a=n?/[\p{L}\p{N}]+/gu:/[\p{L}]+/gu,e=t.match(a);return e.length<=1?null:e.map(u=>r(u)).join("")}function c(t,n=!1){let a=n?/[\p{L}\p{N}_]+/gu:/[\p{L}_]+/gu,e=t.match(a);return e.length<=1?null:e.map(u=>u.toLowerCase()).join("_")}function g(t,n=!1){let a=n?/[\p{L}\p{N}]+/gu:/[\p{L}]+/gu,e=t.match(a);return e.length<=1?null:e.map(u=>r(u)).join(" ")}function d(t,n=!1){let a=n?/[\p{L}\p{N}-]+/gu:/[\p{L}-]+/gu,e=t.match(a);return e.length<=1?null:e.map(u=>r(u)).join("-")}function h(t,n=32,a="..."){return t.substring(0,n)+a}l.camelCase=i,l.capitalize=r,l.flatCase=f,l.kebabCase=p,l.pad=s,l.pascalCase=o,l.snakeCase=c,l.titleCase=g,l.trainCase=d,l.truncate=h,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
(function(r,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(r=typeof globalThis<"u"?globalThis:r||self,u(r.StringFilters={}))})(this,(function(r){"use strict";function u(l,e=!1){let n=l.charAt(0).toUpperCase(),t=l.slice(1);return e&&(t=t.toLowerCase()),`${n}${t}`}function s(l,e={numbers:!1,lower:!1}){let n=/[\p{L}]+/gu;typeof e.numbers<"u"&&e.numbers&&(n=/[\p{L}\p{N}]+/gu);let t=l.match(n);if(t.length<=1)return null;let a=t.shift();const f=typeof e.lower<"u"?e.lower:!1;return f&&(a=a.toLowerCase()),t=t.map(h=>u(h,f)),t.unshift(a),t.join("")}function i(l,e=!1){let n=e?/[\p{L}\p{N}]+/gu:/[\p{L}]+/gu,t=l.match(n);return t.length<=1?null:t.map(a=>a.toLowerCase()).join("")}function o(l,e=!1){let n=e?/[\p{L}\p{N}-]+/gu:/[\p{L}-]+/gu,t=l.match(n);return t.length<=1?null:t.map(a=>a.toLowerCase()).join("-")}function d(l,e,n=" "){const t=Math.floor((e-l.length)/2)+l.length;return l.padStart(t,n).padEnd(e,n)}function p(l,e={numbers:!1,lower:!1}){let n=/[\p{L}]+/gu;typeof e.numbers<"u"&&e.numbers&&(n=/[\p{L}\p{N}]+/gu);let t=l.match(n);if(t.length<=1)return null;const a=typeof e.lower<"u"?e.lower:!1;return t.map(f=>u(f,a)).join("")}function c(l,e=!1){let n=e?/[\p{L}\p{N}_]+/gu:/[\p{L}_]+/gu,t=l.match(n);return t.length<=1?null:t.map(a=>a.toLowerCase()).join("_")}function m(l,e={numbers:!1,lower:!1}){let n=/[\p{L}]+/gu;typeof e.numbers<"u"&&e.numbers&&(n=/[\p{L}\p{N}]+/gu);let t=l.match(n);if(t.length<=1)return null;const a=typeof e.lower<"u"?e.lower:!1;return t.map(f=>u(f,a)).join(" ")}function w(l,e={numbers:!1,lower:!1}){let n=/[\p{L}-]+/gu;typeof e.numbers<"u"&&e.numbers&&(n=/[\p{L}\p{N}-]+/gu);let t=l.match(n);if(t.length<=1)return null;const a=typeof e.lower<"u"?e.lower:!1;return t.map(f=>u(f,a)).join("-")}function g(l,e=32,n="..."){return l.substring(0,e)+n}r.camelCase=s,r.capitalize=u,r.flatCase=i,r.kebabCase=o,r.pad=d,r.pascalCase=p,r.snakeCase=c,r.titleCase=m,r.trainCase=w,r.truncate=g,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
{
"name": "string-filters",
"version": "0.2.0",
"version": "0.3.0",
"description": "Fast native javascript string filters library.",

@@ -5,0 +5,0 @@ "type": "module",

@@ -59,9 +59,17 @@ # Javascript String Filters

let result = ''
result = camelCase('camel 123 casE')
result = camelCase('camel 123 case')
// Output: camelCase
console.log(result)
result = camelCase('camel 123 casE', true)
result = camelCase('camel 123 case', { numbers: true })
// Output: camel123Case
console.log(result)
result = camelCase('cameL 123 casE', { lower: true })
// Output: camelCase
console.log(result)
result = camelCase('cameL 123 casE', { numbers: true, lower: true })
// Output: camel123Case
console.log(result)
```

@@ -74,5 +82,10 @@

let result = capitalize('capitalizE')
let result = ''
result = capitalize('capitalize')
// Output: Capitalize
console.log(result)
result = capitalize('cApitalizE', true)
// Output: Capitalize
console.log(result)
```

@@ -127,9 +140,17 @@

let result = ''
result = pascalCase('pascal 123 casE')
result = pascalCase('pascal 123 case')
// Output: PascalCase
console.log(result)
result = pascalCase('pascal 123 casE', true)
result = pascalCase('pascal 123 case', { numbers: true })
// Output: Pascal123Case
console.log(result)
result = pascalCase('pascaL 123 casE', { lower: true })
// Output: PascalCase
console.log(result)
result = pascalCase('pascaL 123 casE', { numbers: true, lower: true })
// Output: Pascal123Case
console.log(result)
```

@@ -158,9 +179,17 @@

let result = ''
result = titleCase('title 123 casE')
result = titleCase('title 123 case')
// Output: Title Case
console.log(result)
result = titleCase('title 123 casE', true)
result = titleCase('title 123 case', { numbers: true })
// Output: Title 123 Case
console.log(result)
result = titleCase('titlE 123 casE', { lower: true })
// Output: Title Case
console.log(result)
result = titleCase('titlE 123 casE', { numbers: true, lower: true })
// Output: Title 123 Case
console.log(result)
```

@@ -174,9 +203,17 @@

let result = ''
result = trainCase('train 123 casE')
result = trainCase('train 123 case')
// Output: Train-Case
console.log(result)
result = trainCase('train 123 casE', true)
result = trainCase('train 123 case', { numbers: true })
// Output: Train-123-Case
console.log(result)
result = trainCase('traiN 123 casE', { lower: true })
// Output: Train-Case
console.log(result)
result = trainCase('traiN 123 casE', { numbers: true, lower: true })
// Output: Train-123-Case
console.log(result)
```

@@ -183,0 +220,0 @@