stringzy 2.2.1 → 4.0.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.
Files changed (190) hide show
  1. package/.github/workflows/publish.yml +29 -0
  2. package/.github/workflows/test-on-pr.yml +23 -0
  3. package/.prettierignore +4 -0
  4. package/.prettierrc +7 -0
  5. package/CONTRIBUTING.md +99 -0
  6. package/LICENSE +21 -21
  7. package/README.md +1189 -723
  8. package/changelog.txt +110 -110
  9. package/dist/analyzing/characterCount.d.ts +20 -0
  10. package/dist/analyzing/characterCount.js +28 -0
  11. package/dist/analyzing/characterFrequency.d.ts +20 -0
  12. package/dist/analyzing/characterFrequency.js +35 -0
  13. package/dist/analyzing/complexity.d.ts +39 -0
  14. package/dist/analyzing/complexity.js +63 -0
  15. package/dist/analyzing/index.d.ts +26 -0
  16. package/dist/analyzing/index.js +37 -0
  17. package/dist/analyzing/patternCount.d.ts +10 -0
  18. package/dist/analyzing/patternCount.js +52 -0
  19. package/dist/analyzing/readingDuration.d.ts +10 -0
  20. package/dist/analyzing/readingDuration.js +17 -0
  21. package/dist/analyzing/stringSimilarity.d.ts +8 -0
  22. package/dist/analyzing/stringSimilarity.js +145 -0
  23. package/dist/analyzing/vowelConsonantCount.d.ts +22 -0
  24. package/dist/analyzing/vowelConsonantCount.js +38 -0
  25. package/dist/analyzing/wordCount.d.ts +23 -0
  26. package/dist/analyzing/wordCount.js +33 -0
  27. package/dist/formatting/capitalize.d.ts +22 -0
  28. package/dist/formatting/capitalize.js +33 -0
  29. package/dist/formatting/index.d.ts +11 -0
  30. package/dist/formatting/index.js +17 -0
  31. package/dist/formatting/number.d.ts +24 -0
  32. package/dist/formatting/number.js +30 -0
  33. package/dist/formatting/phone.d.ts +25 -0
  34. package/dist/formatting/phone.js +48 -0
  35. package/dist/index.d.ts +52 -0
  36. package/dist/index.js +30 -0
  37. package/dist/tests/analyzing/characterCount.test.d.ts +1 -0
  38. package/dist/tests/analyzing/characterCount.test.js +19 -0
  39. package/dist/tests/analyzing/characterFrequency.test.d.ts +1 -0
  40. package/dist/tests/analyzing/characterFrequency.test.js +22 -0
  41. package/dist/tests/analyzing/complexity.test.d.ts +1 -0
  42. package/dist/tests/analyzing/complexity.test.js +28 -0
  43. package/dist/tests/analyzing/patternCount.test.d.ts +1 -0
  44. package/dist/tests/analyzing/patternCount.test.js +34 -0
  45. package/dist/tests/analyzing/readingDuration.test.d.ts +1 -0
  46. package/dist/tests/analyzing/readingDuration.test.js +45 -0
  47. package/dist/tests/analyzing/stringSimilarity.test.d.ts +1 -0
  48. package/dist/tests/analyzing/stringSimilarity.test.js +61 -0
  49. package/dist/tests/analyzing/vowelConsonantCount.test.d.ts +1 -0
  50. package/dist/tests/analyzing/vowelConsonantCount.test.js +25 -0
  51. package/dist/tests/analyzing/wordCount.test.d.ts +1 -0
  52. package/dist/tests/analyzing/wordCount.test.js +22 -0
  53. package/dist/tests/formatting/capitalize.test.d.ts +1 -0
  54. package/dist/tests/formatting/capitalize.test.js +22 -0
  55. package/dist/tests/formatting/number.test.d.ts +1 -0
  56. package/dist/tests/formatting/number.test.js +19 -0
  57. package/dist/tests/formatting/phone.test.d.ts +1 -0
  58. package/dist/tests/formatting/phone.test.js +25 -0
  59. package/dist/tests/transformations/camelCase.test.d.ts +1 -0
  60. package/dist/tests/transformations/camelCase.test.js +19 -0
  61. package/dist/tests/transformations/capitalizeWords.test.d.ts +1 -0
  62. package/dist/tests/transformations/capitalizeWords.test.js +19 -0
  63. package/dist/tests/transformations/constantCase.test.d.ts +1 -0
  64. package/dist/tests/transformations/constantCase.test.js +19 -0
  65. package/dist/tests/transformations/deburr.test.d.ts +1 -0
  66. package/dist/tests/transformations/deburr.test.js +27 -0
  67. package/dist/tests/transformations/escapeHTML.test.d.ts +1 -0
  68. package/dist/tests/transformations/escapeHTML.test.js +46 -0
  69. package/dist/tests/transformations/initials.test.d.ts +1 -0
  70. package/dist/tests/transformations/initials.test.js +25 -0
  71. package/dist/tests/transformations/kebabCase.test.d.ts +1 -0
  72. package/dist/tests/transformations/kebabCase.test.js +19 -0
  73. package/dist/tests/transformations/maskSegment.test.d.ts +1 -0
  74. package/dist/tests/transformations/maskSegment.test.js +30 -0
  75. package/dist/tests/transformations/numberToText.test.d.ts +1 -0
  76. package/dist/tests/transformations/numberToText.test.js +60 -0
  77. package/dist/tests/transformations/pascalCase.test.d.ts +1 -0
  78. package/dist/tests/transformations/pascalCase.test.js +19 -0
  79. package/dist/tests/transformations/removeDuplicates.test.d.ts +1 -0
  80. package/dist/tests/transformations/removeDuplicates.test.js +19 -0
  81. package/dist/tests/transformations/removeSpecialChars.test.d.ts +1 -0
  82. package/dist/tests/transformations/removeSpecialChars.test.js +22 -0
  83. package/dist/tests/transformations/removeWords.test.d.ts +1 -0
  84. package/dist/tests/transformations/removeWords.test.js +25 -0
  85. package/dist/tests/transformations/snakeCase.test.d.ts +1 -0
  86. package/dist/tests/transformations/snakeCase.test.js +19 -0
  87. package/dist/tests/transformations/splitChunks.test.d.ts +1 -0
  88. package/dist/tests/transformations/splitChunks.test.js +31 -0
  89. package/dist/tests/transformations/titleCase.test.d.ts +1 -0
  90. package/dist/tests/transformations/titleCase.test.js +19 -0
  91. package/dist/tests/transformations/toSlug.test.d.ts +1 -0
  92. package/dist/tests/transformations/toSlug.test.js +22 -0
  93. package/dist/tests/transformations/truncateText.test.d.ts +1 -0
  94. package/dist/tests/transformations/truncateText.test.js +31 -0
  95. package/dist/tests/validations/isCoordinates.test.d.ts +1 -0
  96. package/dist/tests/validations/isCoordinates.test.js +18 -0
  97. package/dist/tests/validations/isDate.test.d.ts +1 -0
  98. package/dist/tests/validations/isDate.test.js +55 -0
  99. package/dist/tests/validations/isEmail.smtpUTF8.test.d.ts +1 -0
  100. package/dist/tests/validations/isEmail.smtpUTF8.test.js +16 -0
  101. package/dist/tests/validations/isEmail.test.d.ts +1 -0
  102. package/dist/tests/validations/isEmail.test.js +67 -0
  103. package/dist/tests/validations/isEmpty.test.d.ts +1 -0
  104. package/dist/tests/validations/isEmpty.test.js +19 -0
  105. package/dist/tests/validations/isHexColor.test.d.ts +1 -0
  106. package/dist/tests/validations/isHexColor.test.js +32 -0
  107. package/dist/tests/validations/isIPv4.test.d.ts +1 -0
  108. package/dist/tests/validations/isIPv4.test.js +59 -0
  109. package/dist/tests/validations/isPalindrome.test.d.ts +1 -0
  110. package/dist/tests/validations/isPalindrome.test.js +39 -0
  111. package/dist/tests/validations/isSlug.test.d.ts +1 -0
  112. package/dist/tests/validations/isSlug.test.js +22 -0
  113. package/dist/tests/validations/isTypeOf.test.d.ts +1 -0
  114. package/dist/tests/validations/isTypeOf.test.js +28 -0
  115. package/dist/tests/validations/isURL.test.d.ts +1 -0
  116. package/dist/tests/validations/isURL.test.js +18 -0
  117. package/dist/transformations/camelCase.d.ts +25 -0
  118. package/dist/transformations/camelCase.js +39 -0
  119. package/dist/transformations/capitalizeWords.d.ts +22 -0
  120. package/dist/transformations/capitalizeWords.js +30 -0
  121. package/dist/transformations/constantCase.d.ts +27 -0
  122. package/dist/transformations/constantCase.js +41 -0
  123. package/dist/transformations/deburr.d.ts +7 -0
  124. package/dist/transformations/deburr.js +16 -0
  125. package/dist/transformations/escapeHTML.d.ts +24 -0
  126. package/dist/transformations/escapeHTML.js +36 -0
  127. package/dist/transformations/index.d.ts +52 -0
  128. package/dist/transformations/index.js +71 -0
  129. package/dist/transformations/initials.d.ts +28 -0
  130. package/dist/transformations/initials.js +49 -0
  131. package/dist/transformations/kebabCase.d.ts +27 -0
  132. package/dist/transformations/kebabCase.js +41 -0
  133. package/dist/transformations/maskSegment.d.ts +9 -0
  134. package/dist/transformations/maskSegment.js +23 -0
  135. package/dist/transformations/numberToText/helpers.d.ts +10 -0
  136. package/dist/transformations/numberToText/helpers.js +31 -0
  137. package/dist/transformations/numberToText/implementation_EN.d.ts +10 -0
  138. package/dist/transformations/numberToText/implementation_EN.js +45 -0
  139. package/dist/transformations/numberToText/implementation_PL.d.ts +10 -0
  140. package/dist/transformations/numberToText/implementation_PL.js +79 -0
  141. package/dist/transformations/numberToText/main.d.ts +19 -0
  142. package/dist/transformations/numberToText/main.js +67 -0
  143. package/dist/transformations/numberToText/types.d.ts +3 -0
  144. package/dist/transformations/numberToText/types.js +82 -0
  145. package/dist/transformations/pascalCase.d.ts +26 -0
  146. package/dist/transformations/pascalCase.js +40 -0
  147. package/dist/transformations/removeDuplicates.d.ts +22 -0
  148. package/dist/transformations/removeDuplicates.js +34 -0
  149. package/dist/transformations/removeSpecialChars.d.ts +23 -0
  150. package/dist/transformations/removeSpecialChars.js +34 -0
  151. package/dist/transformations/removeWords.d.ts +28 -0
  152. package/dist/transformations/removeWords.js +50 -0
  153. package/dist/transformations/snakeCase.d.ts +27 -0
  154. package/dist/transformations/snakeCase.js +41 -0
  155. package/dist/transformations/splitChunks.d.ts +8 -0
  156. package/dist/transformations/splitChunks.js +24 -0
  157. package/dist/transformations/titleCase.d.ts +26 -0
  158. package/dist/transformations/titleCase.js +39 -0
  159. package/dist/transformations/toSlug.d.ts +25 -0
  160. package/dist/transformations/toSlug.js +37 -0
  161. package/dist/transformations/truncateText.d.ts +26 -0
  162. package/dist/transformations/truncateText.js +44 -0
  163. package/dist/validations/index.d.ts +29 -0
  164. package/dist/validations/index.js +41 -0
  165. package/dist/validations/isCoordinates.d.ts +8 -0
  166. package/dist/validations/isCoordinates.js +19 -0
  167. package/dist/validations/isDate.d.ts +18 -0
  168. package/dist/validations/isDate.js +61 -0
  169. package/dist/validations/isEmail.d.ts +13 -0
  170. package/dist/validations/isEmail.js +180 -0
  171. package/dist/validations/isEmpty.d.ts +10 -0
  172. package/dist/validations/isEmpty.js +15 -0
  173. package/dist/validations/isHexColor.d.ts +7 -0
  174. package/dist/validations/isHexColor.js +15 -0
  175. package/dist/validations/isIPv4.d.ts +22 -0
  176. package/dist/validations/isIPv4.js +33 -0
  177. package/dist/validations/isPalindrome.d.ts +10 -0
  178. package/dist/validations/isPalindrome.js +21 -0
  179. package/dist/validations/isSlug.d.ts +28 -0
  180. package/dist/validations/isSlug.js +37 -0
  181. package/dist/validations/isTypeOf.d.ts +9 -0
  182. package/dist/validations/isTypeOf.js +30 -0
  183. package/dist/validations/isURL.d.ts +22 -0
  184. package/dist/validations/isURL.js +33 -0
  185. package/package.json +12 -4
  186. package/analysis.js +0 -21
  187. package/formatting.js +0 -37
  188. package/index.js +0 -75
  189. package/transformations.js +0 -190
  190. package/validations.js +0 -80
package/README.md CHANGED
@@ -1,723 +1,1189 @@
1
-
2
- <div align="center">
3
-
4
-
5
- ![Stringzy banner](./assets/stringzy-banner2.jpg)
6
-
7
-
8
- ![NPM Version](https://img.shields.io/npm/v/stringzy)
9
- ![Downloads](https://img.shields.io/npm/dt/stringzy)
10
- ![License](https://img.shields.io/npm/l/stringzy)
11
- ![Bundle Size](https://img.shields.io/bundlephobia/min/stringzy)
12
- [![Open Source Love svg1](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)
13
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
14
-
15
- **A lightweight, zero-dependency NPM Package for elegant string manipulations. It provides a comprehensive range of text utilities for JavaScript and Node.js applications including transformations, validations, analysis, and formatting.**
16
-
17
- [Checkout our Contributors!](#contri)
18
-
19
-
20
- </div>
21
-
22
-
23
- ## Features
24
-
25
- - 💪 **Powerful** - Transform, validate, analyze, and format strings with minimal code
26
- - 🪶 **Lightweight** - Zero dependencies, tiny footprint
27
- - 🧩 **Modular** - Import only what you need with organized namespaces
28
- - 🚀 **Fast** - Optimized for performance
29
- - ✅ **Tested** - Reliable and robust
30
- - 🎯 **Comprehensive** - 4 specialized modules for all string needs
31
-
32
- ## 📦 Installation
33
-
34
- ```bash
35
- # Using npm
36
- npm install stringzy
37
-
38
- # Using yarn
39
- yarn add stringzy
40
-
41
- # Using pnpm
42
- pnpm add stringzy
43
- ```
44
-
45
- ## 🚀 Quick Start
46
-
47
- ```javascript
48
- // Import the entire library
49
- import stringzy from 'stringzy';
50
-
51
- // Or import specific functions
52
- import { toUpperCase, isEmail, wordCount, formatPhone } from 'stringzy';
53
-
54
- // Or import by namespace
55
- import { transform, validate, analyze, format } from 'stringzy';
56
-
57
- // Transform your strings
58
- const slug = stringzy.toSlug('Hello World!'); // 'hello-world'
59
- const isValid = stringzy.validate.isEmail('user@example.com'); // true
60
- const count = stringzy.analyze.wordCount('Hello world'); // 2
61
- ```
62
-
63
- ## 📋 Table of Contents
64
-
65
- ### Transformations
66
- - [truncateText](#truncatetext) - Truncates text to a specified maximum length
67
- - [toSlug](#toslug) - Converts a string to a URL-friendly slug
68
- - [capitalizeWords](#capitalizewords) - Capitalizes the first letter of each word
69
- - [removeSpecialChars](#removespecialchars) - Removes special characters from a string
70
- - [removeWords](#removewords) - Removes specified words from a string
71
- - [removeDuplicates](#removeduplicates) - Removes specified words from a string
72
- - [initials](#initials) - Extracts initials from a text string
73
- - [camelCase](#camelcase) - Converts the given string to Camel Case
74
- - [pascaslCase](#pascalcase) - Converts the given string to Pascal Case
75
- - [snakeCase](#snakecase) - Converts the given string to Snake Case
76
- - [kebabCase](#kebabcase) - Converts the given string to Kebab Case
77
- - [titleCase](#titlecase) - Converts the given string to Title Case
78
- - [constantCase](#constantcase) - Converts the given string to Constant Case
79
-
80
- ### Validations
81
- - [isURL](#isurl) - Checks if a string is a valid URL
82
- - [isEmail](#isemail) - Checks if a string is a valid email address
83
- - [isDate](#isdate) - Checks if a string is a valid date
84
- - [isEmpty](#isempty) - Checks if a string is empty or contains only whitespace
85
-
86
- ### Analysis
87
- - [wordCount](#wordcount) - Counts the number of words in a string
88
- - [characterCount](#charactercount) - Counts the number of characters in a string
89
- - [characterFrequency](#characterfrequency) - Analyzes character frequency in a string
90
-
91
- ### Formatting
92
- - [capitalize](#capitalize) - Capitalizes the first letter of each word
93
- - [formatNumber](#formatnumber) - Formats a number string with thousand separators
94
- - [formatPhone](#formatphone) - Formats a phone number string to standard format
95
-
96
- ## 📋 API Reference
97
-
98
- ### 🔄 Transformations
99
-
100
- Functions for transforming and manipulating strings.
101
-
102
- #### <a id="truncatetext"></a>`truncateText(text, maxLength, suffix = '...')`
103
-
104
- Truncates text to a specified maximum length, adding a suffix if truncated.
105
-
106
- ```javascript
107
- import { truncateText } from 'stringzy';
108
-
109
- truncateText('This is a long sentence that needs truncating', 10);
110
- // Returns: 'This is a...'
111
-
112
- truncateText('This is a long sentence', 10, ' →');
113
- // Returns: 'This is a →'
114
-
115
- truncateText('Short', 10);
116
- // Returns: 'Short' (no truncation needed)
117
- ```
118
-
119
- | Parameter | Type | Default | Description |
120
- |-----------|------|---------|-------------|
121
- | text | string | required | The input string to truncate |
122
- | maxLength | number | required | Maximum length of the output string (excluding suffix) |
123
- | suffix | string | '...' | String to append if truncation occurs |
124
-
125
- #### <a id="toslug"></a>`toSlug(text)`
126
-
127
- Converts a string to a URL-friendly slug.
128
-
129
- ```javascript
130
- import { toSlug } from 'stringzy';
131
-
132
- toSlug('Hello World!');
133
- // Returns: 'hello-world'
134
-
135
- toSlug('This is a TEST string 123');
136
- // Returns: 'this-is-a-test-string-123'
137
-
138
- toSlug('Special $#@! characters');
139
- // Returns: 'special-characters'
140
- ```
141
-
142
- | Parameter | Type | Default | Description |
143
- |-----------|------|---------|-------------|
144
- | text | string | required | The input string to convert to a slug |
145
-
146
- #### <a id="capitalizewords"></a>`capitalizeWords(text)`
147
-
148
- Capitalizes the first letter of each word in a string.
149
-
150
- ```javascript
151
- import { capitalizeWords } from 'stringzy';
152
-
153
- capitalizeWords('hello world');
154
- // Returns: 'Hello World'
155
-
156
- capitalizeWords('javascript string manipulation');
157
- // Returns: 'Javascript String Manipulation'
158
-
159
- capitalizeWords('already Capitalized');
160
- // Returns: 'Already Capitalized'
161
- ```
162
-
163
- | Parameter | Type | Default | Description |
164
- |-----------|------|---------|-------------|
165
- | text | string | required | The input string to capitalize |
166
-
167
- #### <a id="removespecialchars"></a>`removeSpecialChars(text, replacement = '')`
168
-
169
- Removes special characters from a string, optionally replacing them.
170
-
171
- ```javascript
172
- import { removeSpecialChars } from 'stringzy';
173
-
174
- removeSpecialChars('Hello, world!');
175
- // Returns: 'Hello world'
176
-
177
- removeSpecialChars('email@example.com');
178
- // Returns: 'emailexamplecom'
179
-
180
- removeSpecialChars('Phone: (123) 456-7890', '-');
181
- // Returns: 'Phone-123-456-7890'
182
- ```
183
-
184
- | Parameter | Type | Default | Description |
185
- |-----------|------|---------|-------------|
186
- | text | string | required | The input string to process |
187
- | replacement | string | '' | String to replace special characters with |
188
-
189
- #### <a id="removewords"></a>`removeWords(text, wordsToRemove)`
190
-
191
- Removes specified words from a string
192
-
193
- ```javascript
194
- import { removeWords } from 'stringzy';
195
-
196
- removeWords('Hello world this is a test', ['this', 'is']);
197
- // Returns: 'Hello world a test'
198
-
199
- removeWords('Remove The Quick BROWN fox', ['the', 'brown']);
200
- // Returns: 'Remove Quick fox'
201
-
202
- removeWords('JavaScript is awesome and JavaScript rocks', ['JavaScript']);
203
- // Returns: 'is awesome and rocks'
204
- ```
205
-
206
- | Parameter | Type | Default | Description |
207
- |-----------|------|---------|-------------|
208
- | text | string | required | The input string to process |
209
- | wordsToRemove | string[] | required | Array of words to remove from the string |
210
-
211
- #### <a id="removeduplicates"></a>`removeDuplicates(text)`
212
-
213
- Removes duplicate case-sensitive words from a given text.
214
-
215
- ```javascript
216
- import { removeDuplicates } from 'stringzy';
217
-
218
- removeDuplicates('Hello world this is a is a test');
219
- // Returns: 'Hello world this is a test'
220
-
221
- removeDuplicates('Remove me me me me or Me');
222
- // Returns: 'Remove me or Me''
223
-
224
- removeDuplicates('JavaScript is not bad and not awesome');
225
- // Returns: 'JavaScript is not bad and awesome'
226
- ```
227
-
228
- | Parameter | Type | Default | Description |
229
- |-----------|------|---------|-------------|
230
- | text | string | required | The input string to process |
231
-
232
- #### <a id="initials"></a>`initials(text, limit)`
233
-
234
- Extracts initials from a text string.
235
-
236
- ```javascript
237
- import { initials } from 'stringzy';
238
-
239
- initials('John Doe');
240
- // Returns: 'JD'
241
-
242
- initials('Alice Bob Charlie', 2);
243
- // Returns: 'AB'
244
-
245
- initials('Hello World Test Case');
246
- // Returns: 'HWTC'
247
-
248
- initials('single');
249
- // Returns: 's'
250
-
251
- initials(' Multiple Spaces Between ');
252
- // Returns: 'MSB'
253
- ```
254
-
255
- | Parameter | Type | Default | Description |
256
- |-----------|------|---------|-------------|
257
- | text | string | required | The input string to extract initials from |
258
- | limit | number | undefined | Maximum number of initials to return (optional) |
259
-
260
- #### <a id="camelcase"></a>`camelCase(text)`
261
-
262
- Converts the given string to Camel Case.
263
-
264
- ```javascript
265
- import { camelCase } from 'stringzy';
266
-
267
- camelCase('hello world'); // 'helloWorld'
268
- camelCase('this is a test'); // 'thisIsATest'
269
- ```
270
- | Parameter | Type | Default | Description |
271
- |-----------|------|---------|-------------|
272
- | text | string | required | The input string to convert to Camel Case |
273
-
274
-
275
- #### <a id="pascalcase"></a>`pascalCase(text)`
276
- Converts the given string to Pascal Case.
277
-
278
- ```javascript
279
- import { pascalCase } from 'stringzy';
280
-
281
-
282
- pascalCase('hello world'); // 'HelloWorld'
283
- pascalCase('this is a test'); // 'ThisIsATest'
284
- ```
285
- | Parameter | Type | Default | Description |
286
- |-----------|------|---------|-------------|
287
- | text | string | required | The input string to convert to Pascal Case |
288
-
289
- #### <a id="snakecase"></a>`snakeCase(text)`
290
-
291
- Converts the given string to Snake Case.
292
-
293
- ```javascript
294
- import { snakeCase } from 'stringzy';
295
- snakeCase('hello world'); // 'hello_world'
296
- snakeCase('this is a test'); // 'this_is_a_test'
297
- ```
298
-
299
- | Parameter | Type | Default | Description |
300
- |-----------|------|---------|-------------|
301
- | text | string | required | The input string to convert to Snake Case |
302
-
303
-
304
-
305
-
306
- #### <a id="kebabcase"></a>`kebabCase(text)`
307
-
308
- Converts the given string to Kebab Case.
309
-
310
- ```javascript
311
- import { kebabCase } from 'stringzy';
312
-
313
-
314
- kebabCase('hello world'); // 'hello-world'
315
- kebabCase('this is a test'); // 'this-is-a-test'
316
- ```
317
- | Parameter | Type | Default | Description |
318
- |-----------|------|---------|-------------|
319
- | text | string | required | The input string to convert to Kebab Case |
320
-
321
-
322
-
323
- #### <a id="titlecase"></a>`titleCase(text)`
324
-
325
- Converts the given string to Title Case.
326
-
327
- ```javascript
328
- import { titleCase } from 'stringzy';
329
-
330
-
331
- titleCase('hello world'); // 'Hello World'
332
- titleCase('this is a test'); // 'This Is A Test'
333
- ```
334
- | Parameter | Type | Default | Description |
335
- |-----------|------|---------|-------------|
336
- | text | string | required | The input string to convert to Title Case |
337
-
338
- #### <a id="constantcase"></a>`constantCase(text)`
339
- Converts the given string to Constant Case.
340
-
341
- ```javascript
342
- import { constantCase } from 'stringzy';
343
-
344
-
345
- constantCase('hello world'); // 'HELLO_WORLD'
346
- constantCase('this is a test'); // 'THIS_IS_A_TEST'
347
-
348
- ```
349
- | Parameter | Type | Default | Description |
350
- |-----------|------|---------|-------------|
351
- | text | string | required | The input string to convert to Constant Case |
352
-
353
- ---
354
-
355
- ### Validations
356
-
357
- Functions for validating string formats and content.
358
-
359
- #### <a id="isurl"></a>`isURL(text)`
360
-
361
- Checks if a string is a valid URL.
362
-
363
- ```javascript
364
- isURL('https://example.com'); // true
365
- isURL('not-a-url'); // false
366
- ```
367
-
368
- | Parameter | Type | Default | Description |
369
- |-----------|------|---------|-------------|
370
- | text | string | required | The input string to validate as URL |
371
-
372
- #### <a id="isemail"></a>`isEmail(text)`
373
-
374
- Checks if a string is a valid email address.
375
-
376
- ```javascript
377
- isEmail('user@example.com'); // true
378
- isEmail('invalid-email'); // false
379
- ```
380
-
381
- | Parameter | Type | Default | Description |
382
- |-----------|------|---------|-------------|
383
- | text | string | required | The input string to validate as email |
384
-
385
- #### <a id="isdate"></a>`isDate(text)`
386
-
387
- Checks if a string is a valid date.
388
-
389
- ```javascript
390
- import { isDate } from 'stringzy';
391
-
392
- isDate('2023-12-25'); // true
393
- isDate('12/25/2023'); // true
394
- isDate('invalid-date'); // false
395
- isDate('2023-13-45'); // false
396
- ```
397
-
398
- | Parameter | Type | Default | Description |
399
- |-----------|------|---------|-------------|
400
- | text | string | required | The input string to validate as date |
401
-
402
- #### <a id="isempty"></a>`isEmpty(text)`
403
-
404
- Checks if a string is empty or contains only whitespace.
405
-
406
- ```javascript
407
- isEmpty(' '); // true
408
- isEmpty('hello'); // false
409
- ```
410
-
411
- | Parameter | Type | Default | Description |
412
- |-----------|------|---------|-------------|
413
- | text | string | required | The input string to check for emptiness |
414
-
415
- ---
416
-
417
-
418
- ### 📊 Analysis
419
-
420
- Functions for analyzing string content and structure.
421
-
422
- #### <a id="wordcount"></a>`wordCount(text)`
423
-
424
- Counts the number of words in a string.
425
-
426
- ```javascript
427
- wordCount('Hello world'); // 2
428
- wordCount(''); // 0
429
- ```
430
-
431
- | Parameter | Type | Default | Description |
432
- |-----------|------|---------|-------------|
433
- | text | string | required | The input string to count words in |
434
-
435
- #### <a id="charactercount"></a>`characterCount(text)`
436
-
437
- Counts the number of characters in a string.
438
-
439
- ```javascript
440
- characterCount('Hello'); // 5
441
- ```
442
-
443
- | Parameter | Type | Default | Description |
444
- |-----------|------|---------|-------------|
445
- | text | string | required | The input string to count characters in |
446
-
447
- #### <a id="characterfrequency"></a>`characterFrequency(text)`
448
-
449
- Analyzes character frequency in a string (excluding spaces).
450
-
451
- ```javascript
452
- characterFrequency('hello'); // { h: 1, e: 1, l: 2, o: 1 }
453
- ```
454
-
455
- | Parameter | Type | Default | Description |
456
- |-----------|------|---------|-------------|
457
- | text | string | required | The input string to analyze character frequency |
458
-
459
- ---
460
-
461
- ### 🎨 Formatting
462
-
463
- Functions for formatting strings into specific patterns.
464
-
465
- #### <a id="capitalize"></a>`capitalize(text)`
466
-
467
- Capitalizes the first letter of each word.
468
-
469
- ```javascript
470
- capitalize('hello world'); // 'Hello World'
471
- capitalize('javaScript programming'); // 'Javascript Programming'
472
- ```
473
-
474
- | Parameter | Type | Default | Description |
475
- |-----------|------|---------|-------------|
476
- | text | string | required | The input string to capitalize |
477
-
478
- #### <a id="formatnumber"></a>`formatNumber(number, separator = ',')`
479
-
480
- Formats a number string with thousand separators.
481
-
482
- ```javascript
483
- formatNumber('1234567'); // '1,234,567'
484
- formatNumber('1234567', '.'); // '1.234.567'
485
- ```
486
-
487
- | Parameter | Type | Default | Description |
488
- |-----------|------|---------|-------------|
489
- | number | string\|number | required | The number to format |
490
- | separator | string | ',' | The separator to use for thousands |
491
-
492
- #### <a id="formatphone"></a>`formatPhone(phone, format = 'us')`
493
-
494
- Formats a phone number string to standard format.
495
-
496
- ```javascript
497
- formatPhone('1234567890'); // '(123) 456-7890'
498
- formatPhone('11234567890', 'international'); // '+1 (123) 456-7890'
499
- ```
500
-
501
- | Parameter | Type | Default | Description |
502
- |-----------|------|---------|-------------|
503
- | phone | string | required | The phone number string to format |
504
- | format | string | 'us' | Format type: 'us' or 'international' |
505
-
506
- ## 🔧 Usage Patterns
507
-
508
- ### Individual Function Imports
509
- ```javascript
510
- import { isEmail, wordCount, capitalize } from 'stringzy';
511
-
512
- const email = 'user@example.com';
513
- if (isEmail(email)) {
514
- console.log('Valid email!');
515
- }
516
- ```
517
-
518
- ### Namespace Imports
519
- ```javascript
520
- import { validate, analyze, format } from 'stringzy';
521
-
522
- // Organized by functionality
523
- const emailValid = validate.isEmail('test@example.com');
524
- const words = analyze.wordCount('Hello world');
525
- const formatted = format.capitalize('hello world');
526
- ```
527
-
528
- ### Default Import (All Functions)
529
- ```javascript
530
- import stringzy from 'stringzy';
531
-
532
- // Access any function
533
- stringzy.toUpperCase('hello');
534
- stringzy.validate.isEmail('test@example.com');
535
- stringzy.analyze.wordCount('Hello world');
536
- stringzy.format.capitalize('hello world');
537
- ```
538
-
539
- ## 🛠️ Usage Examples
540
-
541
- ### In a React component
542
-
543
- ```jsx
544
- import React from 'react';
545
- import { truncate, capitalize, wordCount, isEmpty } from 'stringzy';
546
-
547
- function ArticlePreview({ title, content }) {
548
- const displayTitle = isEmpty(title) ? 'Untitled' : capitalize(title);
549
- const previewText = truncate(content, 150);
550
- const readingTime = Math.ceil(wordCount(content) / 200);
551
-
552
- return (
553
- <div className="article-preview">
554
- <h2>{displayTitle}</h2>
555
- <p>{previewText}</p>
556
- <small>{readingTime} min read</small>
557
- </div>
558
- );
559
- }
560
- ```
561
-
562
- ### Form Validation
563
-
564
- ```javascript
565
- import { validate } from 'stringzy';
566
-
567
- function validateForm(formData) {
568
- const errors = {};
569
-
570
- if (!validate.isEmail(formData.email)) {
571
- errors.email = 'Please enter a valid email address';
572
- }
573
-
574
- if (!validate.isURL(formData.website)) {
575
- errors.website = 'Please enter a valid URL';
576
- }
577
-
578
- if (validate.isEmpty(formData.name)) {
579
- errors.name = 'Name is required';
580
- }
581
-
582
- return errors;
583
- }
584
- ```
585
-
586
- ### Content Analysis Dashboard
587
-
588
- ```javascript
589
- import { analyze } from 'stringzy';
590
-
591
- function getContentStats(text) {
592
- return {
593
- words: analyze.wordCount(text),
594
- characters: analyze.characterCount(text),
595
- frequency: analyze.characterFrequency(text),
596
- readingTime: Math.ceil(analyze.wordCount(text) / 200)
597
- };
598
- }
599
- ```
600
-
601
- ### Data Formatting
602
-
603
- ```javascript
604
- import { format } from 'stringzy';
605
-
606
- function formatUserData(userData) {
607
- return {
608
- name: format.capitalize(userData.name),
609
- phone: format.formatPhone(userData.phone),
610
- revenue: format.formatNumber(userData.revenue)
611
- };
612
- }
613
- ```
614
-
615
- ## 🔄 TypeScript Support
616
-
617
- The package includes TypeScript type definitions for all functions.
618
-
619
- ```typescript
620
- import { validate, analyze, format } from 'stringzy';
621
-
622
- // TypeScript will provide proper type checking
623
- const isValid: boolean = validate.isEmail('test@example.com');
624
- const count: number = analyze.wordCount('Hello world');
625
- const formatted: string = format.capitalize('hello world');
626
- ```
627
-
628
- ## 🏗️ Architecture
629
-
630
- stringzy is organized into four specialized modules:
631
-
632
- - **`transformations.js`** - Core string transformations
633
- - **`validations.js`** - String validation utilities
634
- - **`analysis.js`** - String analysis and metrics
635
- - **`formatting.js`** - String formatting functions
636
-
637
- Each module can be imported individually or accessed through the main entry point.
638
-
639
- ## 🤝 Contributing
640
-
641
- Contributions are welcome! Please feel free to submit a Pull Request.
642
-
643
- 1. Fork the repository
644
- 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
645
- 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
646
- 4. Push to the branch (`git push origin feature/amazing-feature`)
647
- 5. Open a Pull Request
648
-
649
-
650
- ## <a id="contri"></a>`Contributors`
651
-
652
- <table>
653
- <tbody>
654
- <tr>
655
- <td align="center">
656
- <a href="https://github.com/Samarth2190">
657
- <img src="https://avatars.githubusercontent.com/Samarth2190" width="100px;"
658
- alt="Samarth Ruia" />
659
- <br />
660
- <sub>
661
- <b>Samarth Ruia</b>
662
- </sub>
663
- </a>
664
- </td>
665
- <td align="center">
666
- <a href="https://github.com/JohnCervantes">
667
- <img src="https://avatars.githubusercontent.com/JohnCervantes" width="100px;"
668
- alt="John Cervantes" />
669
- <br />
670
- <sub>
671
- <b>John Cervantes</b>
672
- </sub>
673
- </a>
674
- </td>
675
- <td align="center">
676
- <a href="https://github.com/thehardiik">
677
- <img src="https://avatars.githubusercontent.com/thehardiik" width="100px;"
678
- alt="Hardik Srivastav" />
679
- <br />
680
- <sub>
681
- <b>Hardik Srivastav</b>
682
- </sub>
683
- </a>
684
- </td>
685
- <td align="center">
686
- <a href="https://github.com/ahmedsemih">
687
- <img src="https://avatars.githubusercontent.com/ahmedsemih" width="100px;"
688
- alt="Ahmed Semih Erkan" />
689
- <br />
690
- <sub>
691
- <b>Ahmed Semih Erkan</b>
692
- </sub>
693
- </a>
694
- </td>
695
- <td align="center">
696
- <a href="https://github.com/michaelvbend">
697
- <img src="https://avatars.githubusercontent.com/michaelvbend" width="100px;"
698
- alt="Michael van der Bend" />
699
- <br />
700
- <sub>
701
- <b>Michael van der Bend</b>
702
- </sub>
703
- </a>
704
- </td>
705
- </tr>
706
- </tbody>
707
- </table>
708
-
709
-
710
- ## 📝 License
711
-
712
- This project is licensed under the MIT License - see the LICENSE file for details.
713
-
714
- ## 🙏 Acknowledgments
715
-
716
- - Thank you to all contributors and users of this package!
717
- - Inspired by the need for comprehensive yet simple string manipulation utilities.
718
-
719
- If you have contributed to this project and your image is not here, please let us know, and we'll be happy to add it!
720
-
721
- ---
722
-
723
- Made with ❤️ by Samarth Ruia
1
+ <div align="center">
2
+
3
+
4
+ ![Stringzy banner](./assets/stringzy-banner2.jpg)
5
+
6
+ ![NPM Version](https://img.shields.io/npm/v/stringzy)
7
+ ![Typescript](https://img.shields.io/badge/TypeScript-3178C6?style=flat&logo=typescript&logoColor=white)
8
+ ![Downloads](https://img.shields.io/npm/dt/stringzy)
9
+ ![License](https://img.shields.io/npm/l/stringzy)
10
+ [![Open Source Love svg1](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)
11
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
12
+
13
+ **A lightweight, zero-dependency NPM Package for elegant string manipulations. It provides a comprehensive range of text utilities for JavaScript and Node.js applications including transformations, validations, analysis, and formatting.**
14
+
15
+ [Checkout our Contributors!](#contri)
16
+
17
+ [Join the Community!](#community)
18
+
19
+ </div>
20
+
21
+ ## ✨ Features
22
+
23
+ - 💪 **Powerful** - Transform, validate, analyze, and format strings with minimal code
24
+ - 🪶 **Lightweight** - Zero dependencies, tiny footprint
25
+ - 🧩 **Modular** - Import only what you need with organized namespaces
26
+ - 🚀 **Fast** - Optimized for performance
27
+ - **Tested** - Reliable and robust
28
+ - 🎯 **Comprehensive** - 4 specialized modules for all string needs
29
+
30
+ ## 📦 Installation
31
+
32
+ ```bash
33
+ # Using npm
34
+ npm install stringzy
35
+
36
+ # Using yarn
37
+ yarn add stringzy
38
+
39
+ # Using pnpm
40
+ pnpm add stringzy
41
+ ```
42
+
43
+ ## 🚀 Quick Start
44
+
45
+ ```javascript
46
+ // Import the entire library
47
+ import stringzy from 'stringzy';
48
+
49
+ // Or import specific functions
50
+ import { isEmail, wordCount, formatPhone } from 'stringzy';
51
+
52
+ // Or import by namespace
53
+ import { transform, validate, analyze, format } from 'stringzy';
54
+
55
+ // Transform your strings
56
+ const slug = stringzy.toSlug('Hello World!'); // 'hello-world'
57
+ const isValid = stringzy.validate.isEmail('user@example.com'); // true
58
+ const count = stringzy.analyze.wordCount('Hello world'); // 2
59
+ ```
60
+
61
+ ## 📋 Table of Contents
62
+
63
+ ### Transformations
64
+
65
+ - [truncateText](#truncatetext) - Truncates text to a specified maximum length
66
+ - [toSlug](#toslug) - Converts a string to a URL-friendly slug
67
+ - [capitalizeWords](#capitalizewords) - Capitalizes the first letter of each word
68
+ - [removeSpecialChars](#removespecialchars) - Removes special characters from a string
69
+ - [removeWords](#removewords) - Removes specified words from a string
70
+ - [removeDuplicates](#removeduplicates) - Removes duplicate words from a string
71
+ - [initials](#initials) - Extracts initials from a text string
72
+ - [camelCase](#camelcase) - Converts the given string to Camel Case
73
+ - [pascalCase](#pascalcase) - Converts the given string to Pascal Case
74
+ - [snakeCase](#snakecase) - Converts the given string to Snake Case
75
+ - [kebabCase](#kebabcase) - Converts the given string to Kebab Case
76
+ - [titleCase](#titlecase) - Converts the given string to Title Case
77
+ - [constantCase](#constantcase) - Converts the given string to Constant Case
78
+ - [escapeHTML](#escapehtml) - Escapes HTML special characters to prevent XSS attacks
79
+ - [maskSegment](#masksegment) - Masks a segment of a string by replacing characters between two indices with a specified character
80
+ - [deburr](#deburr) – Removes accents and diacritical marks from a string
81
+ - [splitChunks](#splitchunks) - Breaks a string down into chunks of specified length.
82
+ - [numberToText](#numbertotext) - Converts a number to its text representation in specified language
83
+
84
+ ### Validations
85
+
86
+ - [isURL](#isurl) - Checks if a string is a valid URL
87
+ - [isEmail](#isemail) - Checks if a string is a valid email address
88
+ - [isDate](#isdate) - Checks if a string is a valid date
89
+ - [isEmpty](#isempty) - Checks if a string is empty or contains only whitespace
90
+ - [isSlug](#isslug) - Checks if a string is a valid slug
91
+ - [isTypeOf](#istypeof) - Checks if a file or URL has a valid extension for a given type
92
+ - [isIPv4](#isipv4) - Checks if a string is a valid IPv4 address
93
+ - [isHexColor](#ishexcolor) - Checks if the input string is a valid hex color
94
+ - [isPalindrome](#ispalindrome) - Checks if the input string is a palindrome (ignores case, spaces, and punctuation)
95
+ - [isCoordinates](#iscoordinates) - Checks if given latitude and longitude are valid coordinates
96
+
97
+ ### Analysis
98
+
99
+ - [wordCount](#wordcount) - Counts the number of words in a string
100
+ - [readingDuration](#readingduration) - Calculates the reading duration of a given string
101
+ - [characterCount](#charactercount) - Counts the number of characters in a string
102
+ - [characterFrequency](#characterfrequency) - Analyzes character frequency in a string
103
+ - [stringSimilarity](#stringsimilarity) - Calculates the percentage similarity between two strings
104
+ - [complexity](#complexity) - Analyzes string complexity including score, uniqueness, and length
105
+ - [patternCount](#patterncount) - calculates the number of times a specific pattern occurs in a given text
106
+ - [vowelConsonantCount](#vowelconsonantcount) - Counts the number of vowels and consonants in a given string
107
+
108
+
109
+ ### Formatting
110
+
111
+ - [capitalize](#capitalize) - Capitalizes the first letter of each word
112
+ - [formatNumber](#formatnumber) - Formats a number string with thousand separators
113
+ - [formatPhone](#formatphone) - Formats a phone number string to standard format
114
+
115
+ ## 📋 API Reference
116
+
117
+ ### 🔄 Transformations
118
+
119
+ Functions for transforming and manipulating strings.
120
+
121
+ #### <a id="truncatetext"></a>`truncateText(text, maxLength, suffix = '...')`
122
+
123
+ Truncates text to a specified maximum length, adding a suffix if truncated.
124
+
125
+ ```javascript
126
+ import { truncateText } from 'stringzy';
127
+
128
+ truncateText('This is a long sentence that needs truncating', 10);
129
+ // Returns: 'This is a...'
130
+
131
+ truncateText('This is a long sentence', 10, ' →');
132
+ // Returns: 'This is a →'
133
+
134
+ truncateText('Short', 10);
135
+ // Returns: 'Short' (no truncation needed)
136
+ ```
137
+
138
+ | Parameter | Type | Default | Description |
139
+ | --------- | ------ | -------- | ------------------------------------------------------ |
140
+ | text | string | required | The input string to truncate |
141
+ | maxLength | number | required | Maximum length of the output string (excluding suffix) |
142
+ | suffix | string | '...' | String to append if truncation occurs |
143
+
144
+ #### <a id="toslug"></a>`toSlug(text)`
145
+
146
+ Converts a string to a URL-friendly slug.
147
+
148
+ ```javascript
149
+ import { toSlug } from 'stringzy';
150
+
151
+ toSlug('Hello World!');
152
+ // Returns: 'hello-world'
153
+
154
+ toSlug('This is a TEST string 123');
155
+ // Returns: 'this-is-a-test-string-123'
156
+
157
+ toSlug('Special $#@! characters');
158
+ // Returns: 'special-characters'
159
+ ```
160
+
161
+ | Parameter | Type | Default | Description |
162
+ | --------- | ------ | -------- | ------------------------------------- |
163
+ | text | string | required | The input string to convert to a slug |
164
+
165
+ #### <a id="capitalizewords"></a>`capitalizeWords(text)`
166
+
167
+ Capitalizes the first letter of each word in a string.
168
+
169
+ ```javascript
170
+ import { capitalizeWords } from 'stringzy';
171
+
172
+ capitalizeWords('hello world');
173
+ // Returns: 'Hello World'
174
+
175
+ capitalizeWords('javascript string manipulation');
176
+ // Returns: 'Javascript String Manipulation'
177
+
178
+ capitalizeWords('already Capitalized');
179
+ // Returns: 'Already Capitalized'
180
+ ```
181
+
182
+ | Parameter | Type | Default | Description |
183
+ | --------- | ------ | -------- | ------------------------------ |
184
+ | text | string | required | The input string to capitalize |
185
+
186
+ #### <a id="removespecialchars"></a>`removeSpecialChars(text, replacement = '')`
187
+
188
+ Removes special characters from a string, optionally replacing them.
189
+
190
+ ```javascript
191
+ import { removeSpecialChars } from 'stringzy';
192
+
193
+ removeSpecialChars('Hello, world!');
194
+ // Returns: 'Hello world'
195
+
196
+ removeSpecialChars('email@example.com');
197
+ // Returns: 'emailexamplecom'
198
+
199
+ removeSpecialChars('Phone: (123) 456-7890', '-');
200
+ // Returns: 'Phone-123-456-7890'
201
+ ```
202
+
203
+ | Parameter | Type | Default | Description |
204
+ | ----------- | ------ | -------- | ----------------------------------------- |
205
+ | text | string | required | The input string to process |
206
+ | replacement | string | '' | String to replace special characters with |
207
+
208
+ #### <a id="removewords"></a>`removeWords(text, wordsToRemove)`
209
+
210
+ Removes specified words from a string
211
+
212
+ ```javascript
213
+ import { removeWords } from 'stringzy';
214
+
215
+ removeWords('Hello world this is a test', ['this', 'is']);
216
+ // Returns: 'Hello world a test'
217
+
218
+ removeWords('Remove The Quick BROWN fox', ['the', 'brown']);
219
+ // Returns: 'Remove Quick fox'
220
+
221
+ removeWords('JavaScript is awesome and JavaScript rocks', ['JavaScript']);
222
+ // Returns: 'is awesome and rocks'
223
+ ```
224
+
225
+ | Parameter | Type | Default | Description |
226
+ | ------------- | -------- | -------- | ---------------------------------------- |
227
+ | text | string | required | The input string to process |
228
+ | wordsToRemove | string[] | required | Array of words to remove from the string |
229
+
230
+ #### <a id="removeduplicates"></a>`removeDuplicates(text)`
231
+
232
+ Removes duplicate case-sensitive words from a given text.
233
+
234
+ ```javascript
235
+ import { removeDuplicates } from 'stringzy';
236
+
237
+ removeDuplicates('Hello world this is a is a test');
238
+ // Returns: 'Hello world this is a test'
239
+
240
+ removeDuplicates('Remove me me me me or Me');
241
+ // Returns: 'Remove me or Me'
242
+
243
+ removeDuplicates('JavaScript is not bad and not awesome');
244
+ // Returns: 'JavaScript is not bad and awesome'
245
+ ```
246
+
247
+ | Parameter | Type | Default | Description |
248
+ | --------- | ------ | -------- | --------------------------- |
249
+ | text | string | required | The input string to process |
250
+
251
+ #### <a id="initials"></a>`initials(text, limit)`
252
+
253
+ Extracts initials from a text string.
254
+
255
+ ```javascript
256
+ import { initials } from 'stringzy';
257
+
258
+ initials('John Doe');
259
+ // Returns: 'JD'
260
+
261
+ initials('Alice Bob Charlie', 2);
262
+ // Returns: 'AB'
263
+
264
+ initials('Hello World Test Case');
265
+ // Returns: 'HWTC'
266
+
267
+ initials('single');
268
+ // Returns: 's'
269
+
270
+ initials(' Multiple Spaces Between ');
271
+ // Returns: 'MSB'
272
+ ```
273
+
274
+ | Parameter | Type | Default | Description |
275
+ | --------- | ------ | --------- | ----------------------------------------------- |
276
+ | text | string | required | The input string to extract initials from |
277
+ | limit | number | undefined | Maximum number of initials to return (optional) |
278
+
279
+ #### <a id="camelcase"></a>`camelCase(text)`
280
+
281
+ Converts the given string to Camel Case.
282
+
283
+ ```javascript
284
+ import { camelCase } from 'stringzy';
285
+
286
+ camelCase('hello world'); // 'helloWorld'
287
+ camelCase('this is a test'); // 'thisIsATest'
288
+ ```
289
+
290
+ | Parameter | Type | Default | Description |
291
+ | --------- | ------ | -------- | ----------------------------------------- |
292
+ | text | string | required | The input string to convert to Camel Case |
293
+
294
+ #### <a id="pascalcase"></a>`pascalCase(text)`
295
+
296
+ Converts the given string to Pascal Case.
297
+
298
+ ```javascript
299
+ import { pascalCase } from 'stringzy';
300
+
301
+ pascalCase('hello world'); // 'HelloWorld'
302
+ pascalCase('this is a test'); // 'ThisIsATest'
303
+ ```
304
+
305
+ | Parameter | Type | Default | Description |
306
+ | --------- | ------ | -------- | ------------------------------------------ |
307
+ | text | string | required | The input string to convert to Pascal Case |
308
+
309
+ #### <a id="snakecase"></a>`snakeCase(text)`
310
+
311
+ Converts the given string to Snake Case.
312
+
313
+ ```javascript
314
+ import { snakeCase } from 'stringzy';
315
+ snakeCase('hello world'); // 'hello_world'
316
+ snakeCase('this is a test'); // 'this_is_a_test'
317
+ ```
318
+
319
+ | Parameter | Type | Default | Description |
320
+ | --------- | ------ | -------- | ----------------------------------------- |
321
+ | text | string | required | The input string to convert to Snake Case |
322
+
323
+ #### <a id="kebabcase"></a>`kebabCase(text)`
324
+
325
+ Converts the given string to Kebab Case.
326
+
327
+ ```javascript
328
+ import { kebabCase } from 'stringzy';
329
+
330
+ kebabCase('hello world'); // 'hello-world'
331
+ kebabCase('this is a test'); // 'this-is-a-test'
332
+ ```
333
+
334
+ | Parameter | Type | Default | Description |
335
+ | --------- | ------ | -------- | ----------------------------------------- |
336
+ | text | string | required | The input string to convert to Kebab Case |
337
+
338
+ #### <a id="titlecase"></a>`titleCase(text)`
339
+
340
+ Converts the given string to Title Case.
341
+
342
+ ```javascript
343
+ import { titleCase } from 'stringzy';
344
+
345
+ titleCase('hello world'); // 'Hello World'
346
+ titleCase('this is a test'); // 'This Is A Test'
347
+ ```
348
+
349
+ | Parameter | Type | Default | Description |
350
+ | --------- | ------ | -------- | ----------------------------------------- |
351
+ | text | string | required | The input string to convert to Title Case |
352
+
353
+ #### <a id="constantcase"></a>`constantCase(text)`
354
+
355
+ Converts the given string to Constant Case.
356
+
357
+ ```javascript
358
+ import { constantCase } from 'stringzy';
359
+
360
+ constantCase('hello world'); // 'HELLO_WORLD'
361
+ constantCase('this is a test'); // 'THIS_IS_A_TEST'
362
+ ```
363
+
364
+ | Parameter | Type | Default | Description |
365
+ | --------- | ------ | -------- | -------------------------------------------- |
366
+ | text | string | required | The input string to convert to Constant Case |
367
+
368
+ #### <a id="escapehtml"></a>`escapeHTML(text)`
369
+
370
+ Escapes HTML special characters to prevent XSS attacks by converting them to their HTML entities.
371
+
372
+ ```javascript
373
+ import { escapeHTML } from 'stringzy';
374
+
375
+ escapeHTML('Tom & Jerry');
376
+ // Returns: 'Tom &amp; Jerry'
377
+
378
+ escapeHTML('<script>alert("XSS")</script>');
379
+ // Returns: '&lt;script&gt;alert(&quot;XSS&quot;)&lt;/script&gt;'
380
+
381
+ escapeHTML('<div class="test">content</div>');
382
+ // Returns: '&lt;div class=&quot;test&quot;&gt;content&lt;/div&gt;'
383
+
384
+ escapeHTML('Say "Hello" & it\'s < 5 > 2');
385
+ // Returns: 'Say &quot;Hello&quot; &amp; it&#39;s &lt; 5 &gt; 2'
386
+ ```
387
+
388
+ | Parameter | Type | Default | Description |
389
+ | --------- | ------ | -------- | ----------------------------------------------- |
390
+ | text | string | required | The input string to escape HTML characters from |
391
+
392
+ #### <a id="masksegment"></a>`maskSegment(text, maskStart, maskEnd, maskChar?)`
393
+
394
+ Masks a segment of a string by replacing characters between two indices with a specified character (default is '\*').
395
+
396
+ ```javascript
397
+ import { maskSegment } from 'stringzy';
398
+
399
+ maskSegment('1234567890', 2, 6);
400
+ // Returns: '12****7890'
401
+
402
+ maskSegment('abcdef', 1, 4, '#');
403
+ // Returns: 'a###ef'
404
+
405
+ maskSegment('token');
406
+ // Returns: '*****'
407
+ ```
408
+
409
+ | Parameter | Type | Default | Description |
410
+ | --------- | ------ | ------------- | -------------------------------------------------------- |
411
+ | text | string | required | The input string to apply the masking to |
412
+ | maskStart | number | `0` | The start index (inclusive) of the segment to mask |
413
+ | maskEnd | number | `text.length` | The end index (exclusive) of the segment to mask |
414
+ | maskChar | string | `'*'` | The character to use for masking (must be one character) |
415
+
416
+ #### <a id="deburr"></a>deburr(text)
417
+
418
+ Removes accents and diacritics from letters in a string (e.g. déjà vu → deja vu).
419
+
420
+ ```javascript
421
+ import { deburr } from 'stringzy';
422
+
423
+ deburr('déjà vu');
424
+ // Returns: 'deja vu'
425
+
426
+ deburr('Élève São Paulo');
427
+ // Returns: 'Eleve Sao Paulo'
428
+
429
+ deburr('über cool');
430
+ // Returns: 'uber cool'
431
+ ```
432
+
433
+ | Parameter | Type | Default | Description |
434
+ | --------- | ------ | -------- | ----------------------------------------- |
435
+ | text | string | required | The input string to strip diacritics from |
436
+
437
+ ---
438
+
439
+ #### <a id="splitchunks"></a>`splitChunks(text, chunkSize)`
440
+
441
+ Takes a string and chunk size as the argument and splits the string into chunks of given size.
442
+
443
+ ```javascript
444
+ import { splitChunks } from 'stringzy';
445
+
446
+ splitChunks('helloworld', 2);
447
+ // Returns: ['he', 'll', 'ow', 'or', 'ld']
448
+
449
+ splitChunks('helloworld', 3);
450
+ // Returns: ['hel', 'low', 'orl', 'd']
451
+
452
+ splitChunks('helloworld');
453
+ // Returns: ['h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd']
454
+ ```
455
+
456
+ | Parameter | Type | Default | Description |
457
+ | --------- | ------ | -------- | --------------------------------------------------------- |
458
+ | text | string | required | The input string that needs to be chunked |
459
+ | chunkSize | number | `1` | The size of each chunk in which the string is to be split |
460
+
461
+ ---
462
+ #### <a id="numbertotext"></a>`numberToText(num, lang)`
463
+ Converts a number to its text representation in the specified language.
464
+
465
+ ```javascript
466
+ import { numberToText } from 'stringzy';
467
+ numberToText(12345); // Returns: 'twelve thousand three hundred forty-five'
468
+ numberToText(12345, 'en'); // Returns: 'twelve thousand three hundred forty-five'
469
+ numberToText(12345, 'pl'); // Returns: 'dwanaście tysięcy trzysta czterdzieści pięć'
470
+ ```
471
+
472
+ | Parameter | Type | Default | Description |
473
+ |-----------|--------|---------|-------------|
474
+ | num | number | required | The number to convert to text |
475
+ | lang | string | 'en' | The language code for the text representation (e.g., 'en' for English, 'pl' for Polish) |
476
+
477
+ Available languages: en (English), pl (Polish).
478
+
479
+
480
+ ### Validations
481
+
482
+ Functions for validating string formats and content.
483
+
484
+ #### <a id="isurl"></a>`isURL(text)`
485
+
486
+ Checks if a string is a valid URL.
487
+
488
+ ```javascript
489
+ isURL('https://example.com'); // true
490
+ isURL('not-a-url'); // false
491
+ ```
492
+
493
+ | Parameter | Type | Default | Description |
494
+ | --------- | ------ | -------- | ----------------------------------- |
495
+ | text | string | required | The input string to validate as URL |
496
+
497
+ #### <a id="isemail"></a>`isEmail(text)`
498
+
499
+ Checks if a string is a valid email address.
500
+
501
+ ```javascript
502
+ isEmail('user@example.com'); // true
503
+ isEmail('invalid-email'); // false
504
+ ```
505
+
506
+ | Parameter | Type | Default | Description |
507
+ | --------- | ------ | -------- | ------------------------------------- |
508
+ | text | string | required | The input string to validate as email |
509
+
510
+ #### <a id="isdate"></a>`isDate(text)`
511
+
512
+ Checks if a string is a valid date.
513
+
514
+ ```javascript
515
+ import { isDate } from 'stringzy';
516
+
517
+ isDate('2023-12-25', DateFormat.YYYMMDD); // true
518
+ isDate('12/25/2023', DateFormat.MMDDYYY, '/'); // true
519
+ isDate('20-12-25', DateFormat.YYYMMDD); // false
520
+ isDate('2023-12-1', DateFormat.YYYMMDD); // false
521
+ isDate('invalid-date', DateFormat.YYYMMDD); // false
522
+ isDate('2023-13-45', DateFormat.YYYMMDD); // false
523
+ ```
524
+
525
+ | Parameter | Type | Default | Description |
526
+ | --------- | ----------- | -------- | ----------------------------------------- |
527
+ | input | string | required | The input string to validate as date |
528
+ | format | DateFormats | required | The date format to validate against |
529
+ | separator | string | optional | The separator to be used if it is not "-" |
530
+
531
+ #### <a id="isempty"></a>`isEmpty(text)`
532
+
533
+ Checks if a string is empty or contains only whitespace.
534
+
535
+ ```javascript
536
+ isEmpty(' '); // true
537
+ isEmpty('hello'); // false
538
+ ```
539
+
540
+ | Parameter | Type | Default | Description |
541
+ | --------- | ------ | -------- | --------------------------------------- |
542
+ | text | string | required | The input string to check for emptiness |
543
+
544
+ #### <a id="isslug"></a>`isSlug(text)`
545
+
546
+ Checks if a string is a valid slug.
547
+
548
+ ```javascript
549
+ isSlug('hello-world'); // true
550
+ isSlug('test-product-123'); // true
551
+ isSlug('Hello-World'); // false (uppercase letters)
552
+ isSlug('hello--world'); // false (consecutive hyphens)
553
+ isSlug('-hello-world'); // false (starts with hyphen)
554
+ isSlug('hello_world'); // false (underscore not allowed)
555
+ ```
556
+
557
+ | Parameter | Type | Default | Description |
558
+ | --------- | ------ | -------- | ------------------------------------ |
559
+ | text | string | required | The input string to validate as slug |
560
+
561
+ #### <a id="istypeof"></a>`isTypeOf(input, type)`
562
+
563
+ Checks if a file or URL has a valid extension for a given type
564
+
565
+ ```javascript
566
+ isType("photo.PNG", "image"); // true
567
+ isType("https://example.com/logo.svg", "image"); // true
568
+ isType({ name: "track.mp3" }, "audio"); // true
569
+ isType("filewithoutextension", "image"); // false
570
+ isType("document.zip", "document"); // false
571
+ isType("video.mp4", "document"); // false
572
+ ```
573
+
574
+ | Parameter | Type | Default | Description |
575
+ |-----------|------|---------|-------------|
576
+ | input | string | required | The file name, URL string, or object with .name |
577
+ | input | string | required | The file type category to validate (image, video, audio, document, archive) |
578
+
579
+
580
+ #### <a id="isipv4"></a>`isIPv4(text)`
581
+
582
+ Checks if a string is a valid IPv4 address.
583
+
584
+ ```javascript
585
+ import { isIPv4 } from 'stringzy';
586
+
587
+ isIPv4('192.168.1.1'); // true
588
+ isIPv4('0.0.0.0'); // true
589
+ isIPv4('256.1.1.1'); // false (out of range)
590
+ isIPv4('192.168.1'); // false (incomplete)
591
+ isIPv4('192.168.01.1'); // false (leading zeros)
592
+ isIPv4('192.168.1.a'); // false (non-numeric)
593
+ ```
594
+
595
+ | Parameter | Type | Default | Description |
596
+ | --------- | ------ | -------- | -------------------------------------------- |
597
+ | text | string | required | The input string to validate as IPv4 address |
598
+
599
+ #### <a id="ishexcolor"></a>`isHexColor(text)`
600
+
601
+ Checks if a string is a valid Hex color.
602
+
603
+ ```javascript
604
+ import { isHexColor } from 'stringzy';
605
+
606
+ isHexColor('#fff'); // true
607
+ isHexColor('fff'); // true
608
+ isHexColor('#a1b2c3'); // true
609
+ isHexColor('123abc'); // true
610
+ isHexColor('#1234'); // false
611
+ isHexColor('blue'); // false
612
+ ```
613
+
614
+ | Parameter | Type | Default | Description |
615
+ | --------- | ------ | -------- | ----------------------------------------- |
616
+ | text | string | required | The input string to validate as Hex color |
617
+
618
+ #### <a id="ispalindrome"></a>`isPalindrome(text)`
619
+
620
+ Checks if a string is a palindrome.
621
+ The check is case-insensitive and ignores spaces and punctuation.
622
+
623
+ ```javascript
624
+ import { isPalindrome } from 'stringzy';
625
+
626
+ isPalindrome('racecar'); // true
627
+ isPalindrome('A man, a plan, a canal: Panama'); // true
628
+ isPalindrome('No lemon, no melon'); // true
629
+ isPalindrome('hello'); // false
630
+ isPalindrome('Was it a car or a cat I saw?'); // true
631
+ ```
632
+
633
+ | Parameter | Type | Default | Description |
634
+ | --------- | ------ | -------- | ---------------------------------------- |
635
+ | text | string | required | The input string to check for palindrome |
636
+
637
+ #### <a id="iscoordinates"></a>`isCoordinates(latitude, longitude)`
638
+
639
+ Checks if given latitude and longitude are valid coordinates.
640
+
641
+ ```javascript
642
+ import { isCoordinates } from 'stringzy';
643
+
644
+ isCoordinates(48.8582, 2.2945); // true
645
+ isCoordinates(40.748817, -73.985428); // true
646
+ isCoordinates(9999, -9999); // false
647
+ ```
648
+
649
+ | Parameter | Type | Default | Description |
650
+ | --------- | ----------- | -------- | ----------------------------------------- |
651
+ | latitude | number | required | Latitude to validate |
652
+ | longitude | number | required | Longitude to validate |
653
+
654
+
655
+ ---
656
+
657
+ ### 📊 Analysis
658
+
659
+ Functions for analyzing string content and structure.
660
+
661
+ #### <a id="readingduration"></a>`readingDuration(text, readingSpeed = 230)`
662
+
663
+ Calculates the estimated reading duration for a given text based on an average reading speed.
664
+
665
+ ```javascript
666
+ import { readingDuration } from 'stringzy';
667
+
668
+ readingDuration(
669
+ 'This is a sample text with twenty-three words to test the reading duration function.'
670
+ );
671
+ // Returns: 0 (23 words / 230 words per minute ≈ 0 minutes)
672
+
673
+ readingDuration(
674
+ 'This text contains fifty words. It is designed to test the reading duration function with a larger input.',
675
+ 200
676
+ );
677
+ // Returns: 1 (50 words / 200 words per minute ≈ 1 minute)
678
+
679
+ readingDuration(Array(9999).fill('Word').join(' '));
680
+ // Returns: 43 (9999 words / 230 words per minute ≈ 43 minutes)
681
+ ```
682
+
683
+ | Parameter | Type | Default | Description |
684
+ | ------------ | ------ | -------- | ------------------------------------------------------------------------------ |
685
+ | text | string | required | The input text for which the reading duration is to be calculated |
686
+ | readingSpeed | number | 230 | The reading speed in words per minute. Defaults to 230 (average reading speed) |
687
+
688
+ #### <a id="wordcount"></a>`wordCount(text)`
689
+
690
+ Counts the number of words in a string.
691
+
692
+ ```javascript
693
+ wordCount('Hello world'); // 2
694
+ wordCount(''); // 0
695
+ ```
696
+
697
+ | Parameter | Type | Default | Description |
698
+ | --------- | ------ | -------- | ---------------------------------- |
699
+ | text | string | required | The input string to count words in |
700
+
701
+ #### <a id="charactercount"></a>`characterCount(text)`
702
+
703
+ Counts the number of characters in a string.
704
+
705
+ ```javascript
706
+ characterCount('Hello'); // 5
707
+ ```
708
+
709
+ | Parameter | Type | Default | Description |
710
+ | --------- | ------ | -------- | --------------------------------------- |
711
+ | text | string | required | The input string to count characters in |
712
+
713
+ #### <a id="characterfrequency"></a>`characterFrequency(text)`
714
+
715
+ Analyzes character frequency in a string (excluding spaces).
716
+
717
+ ```javascript
718
+ characterFrequency('hello'); // { h: 1, e: 1, l: 2, o: 1 }
719
+ ```
720
+
721
+ | Parameter | Type | Default | Description |
722
+ | --------- | ------ | -------- | ----------------------------------------------- |
723
+ | text | string | required | The input string to analyze character frequency |
724
+
725
+ #### <a id="stringsimilarity"></a>`stringSimilarity(textA, textB, algorithm = 'Levenshtein')`
726
+
727
+ Calculates the percentage similarity between two texts using the selected algorithm.
728
+ Method returns a percentage (0–100) value indicating how similar the two strings are.
729
+
730
+ ```javascript
731
+ stringSimilarity('kitten', 'sitting'); // Returns: 57.14
732
+
733
+ stringSimilarity('hello', 'hello'); // Returns: 100
734
+
735
+ stringSimilarity('flaw', 'lawn', 'Damerau-Levenshtein'); // Returns: 50
736
+ ```
737
+
738
+ | Parameter | Type | Default | Description |
739
+ | --------- | ------ | ------------- | ------------------------------------------------------------- |
740
+ | textA | string | required | The first text to compare. |
741
+ | textB | string | required | The second text to compare. |
742
+ | algorithm | string | 'Levenshtein' | The algorithm to use: 'Levenshtein' or 'Damerau-Levenshtein'. |
743
+
744
+
745
+
746
+ #### <a id="complexity"></a>`complexity(text)`
747
+
748
+ Analyzes the complexity of a string, returning an object with detailed metrics.
749
+
750
+ ```javascript
751
+ import { complexity } from 'stringzy';
752
+
753
+ complexity('abc');
754
+ // Returns: { score: [number], uniqueness: [number], length: 3 }
755
+
756
+ complexity('aA1!aA1!');
757
+ // Returns: { score: [number], uniqueness: [number], length: 8 }
758
+
759
+ complexity('');
760
+ // Returns: { score: 0, uniqueness: 0, length: 0 }
761
+ ```
762
+
763
+ | Parameter | Type | Default | Description |
764
+ | --------- | ------ | -------- | -------------------------------------- |
765
+ | text | string | required | The input string to analyze complexity |
766
+
767
+ **Returns:** An object containing:
768
+
769
+ - `score` (number): Overall complexity score
770
+ - `uniqueness` (number): Measure of character uniqueness
771
+ - `length` (number): Length of the input string
772
+
773
+
774
+
775
+ #### <a id="patterncount"></a>`patternCount(text, pattern)`
776
+
777
+ Counts the number of times a substring (pattern) occurs in a string, including overlapping occurrences.
778
+ This function uses the **Knuth–Morris–Pratt (KMP)** algorithm for efficient matching.
779
+
780
+ ```javascript
781
+ patternCount('aaaa', 'aa'); // 3
782
+ patternCount('abababa', 'aba'); // 3
783
+ patternCount('hello world', 'o'); // 2
784
+ patternCount('hello world', 'x'); // 0
785
+ ```
786
+
787
+ | Parameter | Type | Default | Description |
788
+ | --------- | ------ | -------- | ---------------------------------------------- |
789
+ | text | string | required | The input string to search in |
790
+ | pattern | string | required | The substring (pattern) to count (overlapping) |
791
+
792
+ #### <a id="vowelconsonantcount"></a>`vowelConsonantCount(str)`
793
+
794
+ Counts the number of vowels and consonants in a given string.
795
+ This function is case-insensitive and ignores non-alphabetic characters.
796
+
797
+ ```javascript
798
+ vowelConsonantCount('hello');
799
+ // { vowels: 2, consonants: 3 }
800
+
801
+ vowelConsonantCount('stringzy');
802
+ // { vowels: 1, consonants: 7 }
803
+
804
+ vowelConsonantCount('');
805
+ // { vowels: 0, consonants: 0 }
806
+ ```
807
+
808
+ | Parameter | Type | Default | Description |
809
+ | --------- | ------ | -------- | -------------------------------------------------- |
810
+ | str | string | required | The input string to count vowels and consonants in |
811
+
812
+ ---
813
+
814
+ ### 🎨 Formatting
815
+
816
+ Functions for formatting strings into specific patterns.
817
+
818
+ #### <a id="capitalize"></a>`capitalize(text)`
819
+
820
+ Capitalizes the first letter of each word.
821
+
822
+ ```javascript
823
+ capitalize('hello world'); // 'Hello World'
824
+ capitalize('javaScript programming'); // 'Javascript Programming'
825
+ ```
826
+
827
+ | Parameter | Type | Default | Description |
828
+ | --------- | ------ | -------- | ------------------------------ |
829
+ | text | string | required | The input string to capitalize |
830
+
831
+ #### <a id="formatnumber"></a>`formatNumber(number, separator = ',')`
832
+
833
+ Formats a number string with thousand separators.
834
+
835
+ ```javascript
836
+ formatNumber('1234567'); // '1,234,567'
837
+ formatNumber('1234567', '.'); // '1.234.567'
838
+ ```
839
+
840
+ | Parameter | Type | Default | Description |
841
+ | --------- | -------------- | -------- | ---------------------------------- |
842
+ | number | string\|number | required | The number to format |
843
+ | separator | string | ',' | The separator to use for thousands |
844
+
845
+ #### <a id="formatphone"></a>`formatPhone(phone, format = 'us')`
846
+
847
+ Formats a phone number string to standard format.
848
+
849
+ ```javascript
850
+ formatPhone('1234567890'); // '(123) 456-7890'
851
+ formatPhone('11234567890', 'international'); // '+1 (123) 456-7890'
852
+ ```
853
+
854
+ | Parameter | Type | Default | Description |
855
+ | --------- | ------ | -------- | ------------------------------------ |
856
+ | phone | string | required | The phone number string to format |
857
+ | format | string | 'us' | Format type: 'us' or 'international' |
858
+
859
+ ## 🔧 Usage Patterns
860
+
861
+ ### Individual Function Imports
862
+
863
+ ```javascript
864
+ import { isEmail, wordCount, capitalize } from 'stringzy';
865
+
866
+ const email = 'user@example.com';
867
+ if (isEmail(email)) {
868
+ console.log('Valid email!');
869
+ }
870
+ ```
871
+
872
+ ### Namespace Imports
873
+
874
+ ```javascript
875
+ import { validate, analyze, format } from 'stringzy';
876
+
877
+ // Organized by functionality
878
+ const emailValid = validate.isEmail('test@example.com');
879
+ const words = analyze.wordCount('Hello world');
880
+ const formatted = format.capitalize('hello world');
881
+ ```
882
+
883
+ ### Default Import (All Functions)
884
+
885
+ ```javascript
886
+ import stringzy from 'stringzy';
887
+
888
+ // Access any function
889
+ stringzy.toUpperCase('hello');
890
+ stringzy.validate.isEmail('test@example.com');
891
+ stringzy.analyze.wordCount('Hello world');
892
+ stringzy.format.capitalize('hello world');
893
+ ```
894
+
895
+ ## 🛠️ Usage Examples
896
+
897
+ ### In a React component
898
+
899
+ ```jsx
900
+ import React from 'react';
901
+ import { truncateText, capitalize, wordCount, isEmpty } from 'stringzy';
902
+
903
+ function ArticlePreview({ title, content }) {
904
+ const displayTitle = isEmpty(title) ? 'Untitled' : capitalize(title);
905
+ const previewText = truncateText(content, 150);
906
+ const readingTime = Math.ceil(wordCount(content) / 200);
907
+
908
+ return (
909
+ <div className="article-preview">
910
+ <h2>{displayTitle}</h2>
911
+ <p>{previewText}</p>
912
+ <small>{readingTime} min read</small>
913
+ </div>
914
+ );
915
+ }
916
+ ```
917
+
918
+ ### Form Validation
919
+
920
+ ```javascript
921
+ import { validate } from 'stringzy';
922
+
923
+ function validateForm(formData) {
924
+ const errors = {};
925
+
926
+ if (!validate.isEmail(formData.email)) {
927
+ errors.email = 'Please enter a valid email address';
928
+ }
929
+
930
+ if (!validate.isURL(formData.website)) {
931
+ errors.website = 'Please enter a valid URL';
932
+ }
933
+
934
+ if (validate.isEmpty(formData.name)) {
935
+ errors.name = 'Name is required';
936
+ }
937
+
938
+ return errors;
939
+ }
940
+ ```
941
+
942
+ ### Content Analysis Dashboard
943
+
944
+ ```javascript
945
+ import { analyze } from 'stringzy';
946
+
947
+ function getContentStats(text) {
948
+ return {
949
+ words: analyze.wordCount(text),
950
+ characters: analyze.characterCount(text),
951
+ frequency: analyze.characterFrequency(text),
952
+ readingTime: Math.ceil(analyze.wordCount(text) / 200),
953
+ };
954
+ }
955
+ ```
956
+
957
+ ### Data Formatting
958
+
959
+ ```javascript
960
+ import { format } from 'stringzy';
961
+
962
+ function formatUserData(userData) {
963
+ return {
964
+ name: format.capitalize(userData.name),
965
+ phone: format.formatPhone(userData.phone),
966
+ revenue: format.formatNumber(userData.revenue),
967
+ };
968
+ }
969
+ ```
970
+
971
+ ## 🔄 TypeScript Support
972
+
973
+ The package includes TypeScript type definitions for all functions.
974
+
975
+ ```typescript
976
+ import { validate, analyze, format } from 'stringzy';
977
+
978
+ // TypeScript will provide proper type checking
979
+ const isValid: boolean = validate.isEmail('test@example.com');
980
+ const count: number = analyze.wordCount('Hello world');
981
+ const formatted: string = format.capitalize('hello world');
982
+ ```
983
+
984
+ ## 🏗️ Architecture
985
+
986
+ stringzy is organized into four specialized modules:
987
+
988
+ - **`transformations.js`** - Core string transformations
989
+ - **`validations.js`** - String validation utilities
990
+ - **`analysis.js`** - String analysis and metrics
991
+ - **`formatting.js`** - String formatting functions
992
+
993
+ Each module can be imported individually or accessed through the main entry point.
994
+
995
+ ## 🤝 Contributing
996
+
997
+ Contributions are welcome! Please read our [contribution guidelines](CONTRIBUTING.md) before submitting a pull request.
998
+
999
+ ## <a id="contri"></a>`Contributors`
1000
+
1001
+ <table>
1002
+ <tbody>
1003
+ <tr>
1004
+ <td align="center">
1005
+ <a href="https://github.com/Samarth2190">
1006
+ <img src="https://avatars.githubusercontent.com/Samarth2190" width="100px;"
1007
+ alt="Samarth Ruia" />
1008
+ <br />
1009
+ <sub>
1010
+ <b>Samarth Ruia</b>
1011
+ </sub>
1012
+ </a>
1013
+ </td>
1014
+ <td align="center">
1015
+ <a href="https://github.com/JohnCervantes">
1016
+ <img src="https://avatars.githubusercontent.com/JohnCervantes" width="100px;"
1017
+ alt="John Cervantes" />
1018
+ <br />
1019
+ <sub>
1020
+ <b>John Cervantes</b>
1021
+ </sub>
1022
+ </a>
1023
+ </td>
1024
+ <td align="center">
1025
+ <a href="https://github.com/thehardiik">
1026
+ <img src="https://avatars.githubusercontent.com/thehardiik" width="100px;"
1027
+ alt="Hardik Srivastav" />
1028
+ <br />
1029
+ <sub>
1030
+ <b>Hardik Srivastav</b>
1031
+ </sub>
1032
+ </a>
1033
+ </td>
1034
+ <td align="center">
1035
+ <a href="https://github.com/ahmedsemih">
1036
+ <img src="https://avatars.githubusercontent.com/ahmedsemih" width="100px;"
1037
+ alt="Ahmed Semih Erkan" />
1038
+ <br />
1039
+ <sub>
1040
+ <b>Ahmed Semih Erkan</b>
1041
+ </sub>
1042
+ </a>
1043
+ </td>
1044
+ <td align="center">
1045
+ <a href="https://github.com/michaelvbend">
1046
+ <img src="https://avatars.githubusercontent.com/michaelvbend" width="100px;"
1047
+ alt="Michael van der Bend" />
1048
+ <br />
1049
+ <sub>
1050
+ <b>Michael van der Bend</b>
1051
+ </sub>
1052
+ </a>
1053
+ </td>
1054
+ <td align="center">
1055
+ <a href="https://github.com/mamphis">
1056
+ <img src="https://avatars.githubusercontent.com/mamphis" width="100px;"
1057
+ alt="mamphis" />
1058
+ <br />
1059
+ <sub>
1060
+ <b>mamphis</b>
1061
+ </sub>
1062
+ </a>
1063
+ </td>
1064
+ </tr>
1065
+ <tr>
1066
+ <td align="center">
1067
+ <a href="https://github.com/cokolwiekpl">
1068
+ <img src="https://avatars.githubusercontent.com/cokolwiekpl" width="100px;"
1069
+ alt="Stanisław Kumor" />
1070
+ <br />
1071
+ <sub>
1072
+ <b>Stanisław Kumor</b>
1073
+ </sub>
1074
+ </a>
1075
+ </td>
1076
+ <td align="center">
1077
+ <a href="https://github.com/Alimedhat000">
1078
+ <img src="https://avatars.githubusercontent.com/Alimedhat000" width="100px;"
1079
+ alt="Ali Medhat" />
1080
+ <br />
1081
+ <sub>
1082
+ <b>Ali Medhat</b>
1083
+ </sub>
1084
+ </a>
1085
+ </td>
1086
+ <td align="center">
1087
+ <a href="https://github.com/Soham-Powar">
1088
+ <img src="https://avatars.githubusercontent.com/Soham-Powar" width="100px;"
1089
+ alt="Soham Powar" />
1090
+ <br />
1091
+ <sub>
1092
+ <b>Soham Powar</b>
1093
+ </sub>
1094
+ </a>
1095
+ </td>
1096
+ <td align="center">
1097
+ <a href="https://github.com/a-arham-x">
1098
+ <img src="https://avatars.githubusercontent.com/a-arham-x" width="100px;"
1099
+ alt="Soham Powar" />
1100
+ <br />
1101
+ <sub>
1102
+ <b>Abdul Arham</b>
1103
+ </sub>
1104
+ </a>
1105
+ </td>
1106
+ <td align="center">
1107
+ <a href="https://github.com/Thenlie">
1108
+ <img src="https://avatars.githubusercontent.com/Thenlie" width="100px;"
1109
+ alt="Thenlie" />
1110
+ <br />
1111
+ <sub>
1112
+ <b>Leithen</b>
1113
+ </sub>
1114
+ </a>
1115
+ </td>
1116
+ <td align="center">
1117
+ <a href="https://github.com/rickyryden">
1118
+ <img src="https://avatars.githubusercontent.com/rickyryden" width="100px;"
1119
+ alt="Ricky Ryden" />
1120
+ <br />
1121
+ <sub>
1122
+ <b>Ricky Ryden</b>
1123
+ </sub>
1124
+ </a>
1125
+ </td>
1126
+ </tr>
1127
+ <tr>
1128
+ <td align="center">
1129
+ <a href="https://github.com/adityaatre26">
1130
+ <img src="https://avatars.githubusercontent.com/adityaatre26" width="100px;"
1131
+ alt="Aditya Atre" />
1132
+ <br />
1133
+ <sub>
1134
+ <b>Aditya Atre</b>
1135
+ </sub>
1136
+ </a>
1137
+ </td>
1138
+ <td align="center">
1139
+ <a href="https://github.com/kittenwarrior-qb">
1140
+ <img src="https://avatars.githubusercontent.com/kittenwarrior-qb" width="100px;"
1141
+ alt="quocbui05" />
1142
+ <br />
1143
+ <sub>
1144
+ <b>quocbui05</b>
1145
+ </sub>
1146
+ </a>
1147
+ </td>
1148
+ <td align="center">
1149
+ <a href="https://github.com/MariamEwas">
1150
+ <img src="https://avatars.githubusercontent.com/MariamEwas" width="100px;"
1151
+ alt="Mariam Hasan" />
1152
+ <br />
1153
+ <sub>
1154
+ <b>Mariam Hasan</b>
1155
+ </sub>
1156
+ </a>
1157
+ </td>
1158
+ <td align="center">
1159
+ <a href="https://github.com/milendrakumarbaghel">
1160
+ <img src="https://avatars.githubusercontent.com/milendrakumarbaghel" width="100px;"
1161
+ alt="Mariam Hasan" />
1162
+ <br />
1163
+ <sub>
1164
+ <b>Milendra Kumar Baghel</b>
1165
+ </sub>
1166
+ </a>
1167
+ </td>
1168
+ </tr>
1169
+ </tbody>
1170
+ </table>
1171
+
1172
+ ## <a id="community"></a>💬 Join the Community
1173
+
1174
+ Have questions, ideas, or want to contribute? Join our [Discord server](https://discord.gg/DmvY7XJMdk) to chat with the community, discuss features, and help shape the future of the project.
1175
+
1176
+ ## 📝 License
1177
+
1178
+ This project is licensed under the MIT License - see the LICENSE file for details.
1179
+
1180
+ ## 🙏 Acknowledgments
1181
+
1182
+ - Thank you to all contributors and users of this package!
1183
+ - Inspired by the need for comprehensive yet simple string manipulation utilities.
1184
+
1185
+ If you have contributed to this project and your image is not here, please let us know, and we'll be happy to add it!
1186
+
1187
+ ---
1188
+
1189
+ Made with ❤️ by Samarth Ruia