string-filters 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,8 +16,9 @@ Fast native javascript string filters library.
16
16
  5. [Pad](#pad)
17
17
  6. [Pascal case](#pascal-case)
18
18
  7. [Snake case](#snake-case)
19
- 8. [Train case](#train-case)
20
- 9. [Truncate](#truncate)
19
+ 8. [Title case](#title-case)
20
+ 9. [Train case](#train-case)
21
+ 10. [Truncate](#truncate)
21
22
  4. [Author](#author)
22
23
  5. [License](#license)
23
24
 
@@ -56,18 +57,10 @@ import { camelCase } from 'string-filters'
56
57
 
57
58
  let result = ''
58
59
  result = camelCase('camel 123 casE')
59
- // Output: camelCasE
60
- console.log(result)
61
-
62
- result = camelCase('camel 123 casE', { numbers: true })
63
- // Output: camel123CasE
64
- console.log(result)
65
-
66
- result = camelCase('cameL 123 casE', { lower: true })
67
60
  // Output: camelCase
68
61
  console.log(result)
69
62
 
70
- result = camelCase('cameL 123 casE', { numbers: true, lower: true })
63
+ result = camelCase('camel 123 casE', true)
71
64
  // Output: camel123Case
72
65
  console.log(result)
73
66
  ```
@@ -77,12 +70,7 @@ console.log(result)
77
70
  ```js
78
71
  import { capitalize } from 'string-filters'
79
72
 
80
- let result = ''
81
- result = capitalize('capitalizE')
82
- // Output: CapitalizE
83
- console.log(result)
84
-
85
- result = capitalize('cApitalizE', true)
73
+ let result = capitalize('capitalizE')
86
74
  // Output: Capitalize
87
75
  console.log(result)
88
76
  ```
@@ -135,18 +123,10 @@ import { pascalCase } from 'string-filters'
135
123
 
136
124
  let result = ''
137
125
  result = pascalCase('pascal 123 casE')
138
- // Output: PascalCasE
139
- console.log(result)
140
-
141
- result = pascalCase('pascal 123 casE', { numbers: true })
142
- // Output: Pascal123CasE
143
- console.log(result)
144
-
145
- result = pascalCase('pascaL 123 casE', { lower: true })
146
126
  // Output: PascalCase
147
127
  console.log(result)
148
128
 
149
- result = pascalCase('pascaL 123 casE', { numbers: true, lower: true })
129
+ result = pascalCase('pascal 123 casE', true)
150
130
  // Output: Pascal123Case
151
131
  console.log(result)
152
132
  ```
@@ -166,25 +146,32 @@ result = snakeCase('Snake 123 Case', true)
166
146
  console.log(result)
167
147
  ```
168
148
 
169
- ### Train case
149
+ ### Title case
170
150
 
171
151
  ```js
172
- import { trainCase } from 'string-filters'
152
+ import { titleCase } from 'string-filters'
173
153
 
174
154
  let result = ''
175
- result = trainCase('train 123 casE')
176
- // Output: Train-CasE
155
+ result = titleCase('title 123 casE')
156
+ // Output: Title Case
177
157
  console.log(result)
178
158
 
179
- result = trainCase('train 123 casE', { numbers: true })
180
- // Output: Train-123-CasE
159
+ result = titleCase('title 123 casE', true)
160
+ // Output: Title 123 Case
181
161
  console.log(result)
162
+ ```
163
+
164
+ ### Train case
182
165
 
183
- result = trainCase('traiN 123 casE', { lower: true })
166
+ ```js
167
+ import { trainCase } from 'string-filters'
168
+
169
+ let result = ''
170
+ result = trainCase('train 123 casE')
184
171
  // Output: Train-Case
185
172
  console.log(result)
186
173
 
187
- result = trainCase('traiN 123 casE', { numbers: true, lower: true })
174
+ result = trainCase('train 123 casE', true)
188
175
  // Output: Train-123-Case
189
176
  console.log(result)
190
177
  ```
@@ -1,49 +1,54 @@
1
- function a(r, t = !1) {
2
- let n = r.charAt(0).toUpperCase(), e = r.slice(1);
3
- return t && (e = e.toLowerCase()), `${n}${e}`;
1
+ function l(e) {
2
+ let n = e.charAt(0).toUpperCase(), r = e.slice(1).toLowerCase();
3
+ return `${n}${r}`;
4
4
  }
5
- function s(r, t = { numbers: !1, lower: !1 }) {
6
- let n = t.numbers ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu, e = r.match(n);
7
- if (e.length <= 1)
5
+ function p(e, n = !1) {
6
+ let r = n ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu, t = e.match(r);
7
+ if (t.length <= 1)
8
8
  return null;
9
- let l = e.shift();
10
- return t.lower && (l = l.toLowerCase()), e = e.map((u) => a(u, t.lower)), e.unshift(l), e.join("");
9
+ let a = t.shift();
10
+ return a = a.toLowerCase(), t = t.map((u) => l(u)), t.unshift(a), t.join("");
11
11
  }
12
- function o(r, t = !1) {
13
- let n = t ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu, e = r.match(n);
14
- return e.length <= 1 ? null : e.map((l) => l.toLowerCase()).join("");
12
+ function o(e, n = !1) {
13
+ let r = n ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu, t = e.match(r);
14
+ return t.length <= 1 ? null : t.map((a) => a.toLowerCase()).join("");
15
15
  }
16
- function p(r, t = !1) {
17
- let n = t ? /[\p{L}\p{N}-]+/gu : /[\p{L}-]+/gu, e = r.match(n);
18
- return e.length <= 1 ? null : e.map((l) => l.toLowerCase()).join("-");
16
+ function s(e, n = !1) {
17
+ let r = n ? /[\p{L}\p{N}-]+/gu : /[\p{L}-]+/gu, t = e.match(r);
18
+ return t.length <= 1 ? null : t.map((a) => a.toLowerCase()).join("-");
19
19
  }
20
- function f(r, t, n = " ") {
21
- const e = Math.floor((t - r.length) / 2) + r.length;
22
- return r.padStart(e, n).padEnd(t, n);
20
+ function i(e, n, r = " ") {
21
+ const t = Math.floor((n - e.length) / 2) + e.length;
22
+ return e.padStart(t, r).padEnd(n, r);
23
23
  }
24
- function i(r, t = { numbers: !1, lower: !1 }) {
25
- let n = t.numbers ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu, e = r.match(n);
26
- return e.length <= 1 ? null : e.map((l) => a(l, t.lower)).join("");
24
+ function f(e, n = !1) {
25
+ let r = n ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu, t = e.match(r);
26
+ return t.length <= 1 ? null : t.map((a) => l(a)).join("");
27
27
  }
28
- function c(r, t = !1) {
29
- let n = t ? /[\p{L}\p{N}_]+/gu : /[\p{L}_]+/gu, e = r.match(n);
30
- return e.length <= 1 ? null : e.map((l) => l.toLowerCase()).join("_");
28
+ function c(e, n = !1) {
29
+ let r = n ? /[\p{L}\p{N}_]+/gu : /[\p{L}_]+/gu, t = e.match(r);
30
+ return t.length <= 1 ? null : t.map((a) => a.toLowerCase()).join("_");
31
31
  }
32
- function m(r, t = { numbers: !1, lower: !1 }) {
33
- let n = t.numbers ? /[\p{L}\p{N}-]+/gu : /[\p{L}-]+/gu, e = r.match(n);
34
- return e.length <= 1 ? null : e.map((l) => a(l, t.lower)).join("-");
32
+ function g(e, n = !1) {
33
+ let r = n ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu, t = e.match(r);
34
+ return t.length <= 1 ? null : t.map((a) => l(a)).join(" ");
35
35
  }
36
- function g(r, t = 32, n = "...") {
37
- return r.substring(0, t) + n;
36
+ function L(e, n = !1) {
37
+ let r = n ? /[\p{L}\p{N}-]+/gu : /[\p{L}-]+/gu, t = e.match(r);
38
+ return t.length <= 1 ? null : t.map((a) => l(a)).join("-");
39
+ }
40
+ function h(e, n = 32, r = "...") {
41
+ return e.substring(0, n) + r;
38
42
  }
39
43
  export {
40
- s as camelCase,
41
- a as capitalize,
44
+ p as camelCase,
45
+ l as capitalize,
42
46
  o as flatCase,
43
- p as kebabCase,
44
- f as pad,
45
- i as pascalCase,
47
+ s as kebabCase,
48
+ i as pad,
49
+ f as pascalCase,
46
50
  c as snakeCase,
47
- m as trainCase,
48
- g as truncate
51
+ g as titleCase,
52
+ L as trainCase,
53
+ h as truncate
49
54
  };
@@ -1 +1 @@
1
- (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}){let a=t.numbers?/[\p{L}\p{N}]+/gu:/[\p{L}]+/gu,e=n.match(a);if(e.length<=1)return null;let r=e.shift();return t.lower&&(r=r.toLowerCase()),e=e.map(g=>u(g,t.lower)),e.unshift(r),e.join("")}function s(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 i(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 o(n,t,a=" "){const e=Math.floor((t-n.length)/2)+n.length;return n.padStart(e,a).padEnd(t,a)}function p(n,t={numbers:!1,lower:!1}){let a=t.numbers?/[\p{L}\p{N}]+/gu:/[\p{L}]+/gu,e=n.match(a);return e.length<=1?null:e.map(r=>u(r,t.lower)).join("")}function c(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 m(n,t={numbers:!1,lower:!1}){let a=t.numbers?/[\p{L}\p{N}-]+/gu:/[\p{L}-]+/gu,e=n.match(a);return e.length<=1?null:e.map(r=>u(r,t.lower)).join("-")}function d(n,t=32,a="..."){return n.substring(0,t)+a}l.camelCase=f,l.capitalize=u,l.flatCase=s,l.kebabCase=i,l.pad=o,l.pascalCase=p,l.snakeCase=c,l.trainCase=m,l.truncate=d,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
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"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "string-filters",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Fast native javascript string filters library.",
5
5
  "type": "module",
6
6
  "files": [