stringzy 2.1.0 → 2.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
@@ -1,4 +1,9 @@
1
- # stringzy
1
+
2
+ <div align="center">
3
+
4
+
5
+ ![Stringzy banner](./assets/stringzy-banner2.jpg)
6
+
2
7
 
3
8
  ![NPM Version](https://img.shields.io/npm/v/stringzy)
4
9
  ![Downloads](https://img.shields.io/npm/dt/stringzy)
@@ -11,6 +16,10 @@
11
16
 
12
17
  [Checkout our Contributors!](#contri)
13
18
 
19
+
20
+ </div>
21
+
22
+
14
23
  ## ✨ Features
15
24
 
16
25
  - 💪 **Powerful** - Transform, validate, analyze, and format strings with minimal code
@@ -59,6 +68,8 @@ const count = stringzy.analyze.wordCount('Hello world'); // 2
59
68
  - [capitalizeWords](#capitalizewords) - Capitalizes the first letter of each word
60
69
  - [removeSpecialChars](#removespecialchars) - Removes special characters from a string
61
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
62
73
  - [camelCase](#camelcase) - Converts the given string to Camel Case
63
74
  - [pascaslCase](#pascalcase) - Converts the given string to Pascal Case
64
75
  - [snakeCase](#snakecase) - Converts the given string to Snake Case
@@ -197,6 +208,55 @@ removeWords('JavaScript is awesome and JavaScript rocks', ['JavaScript']);
197
208
  | text | string | required | The input string to process |
198
209
  | wordsToRemove | string[] | required | Array of words to remove from the string |
199
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
+
200
260
  #### <a id="camelcase"></a>`camelCase(text)`
201
261
 
202
262
  Converts the given string to Camel Case.
@@ -622,6 +682,26 @@ Contributions are welcome! Please feel free to submit a Pull Request.
622
682
  </sub>
623
683
  </a>
624
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>
625
705
  </tr>
626
706
  </tbody>
627
707
  </table>
@@ -640,4 +720,4 @@ If you have contributed to this project and your image is not here, please let u
640
720
 
641
721
  ---
642
722
 
643
- Made with ❤️ by Samarth Ruia
723
+ Made with ❤️ by Samarth Ruia
Binary file
package/changelog.txt CHANGED
@@ -1,6 +1,16 @@
1
1
  CHANGELOG
2
2
 
3
3
  All notable changes to the `stringzy` package will be documented in this file.
4
+
5
+ =============================================================================
6
+ Version 2.1.0 - 2025-05-31
7
+ -----------------------------------------------------------------------------
8
+
9
+ ADDED:
10
+ - Added new utility functions:
11
+ - `removeDuplicates`: Removes duplicate words from a string
12
+ - Added the stringzy banner to the README
13
+
4
14
  =============================================================================
5
15
  Version 2.1.0 - 2025-05-31
6
16
  -----------------------------------------------------------------------------
package/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @module stringzy
9
9
  * @author Samarth Ruia
10
- * @version 2.1.0
10
+ * @version 2.2.0
11
11
  */
12
12
 
13
13
  import * as transformations from './transformations.js';
@@ -28,6 +28,8 @@ export const {
28
28
  titleCase,
29
29
  constantCase,
30
30
  removeWords,
31
+ initials,
32
+ removeDuplicates
31
33
  } = transformations;
32
34
 
33
35
  export const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stringzy",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -147,3 +147,44 @@ export function removeWords(str, wordsToRemove) {
147
147
  const regex = new RegExp(`\\b(${wordsArray.join('|')})\\b`, 'gi');
148
148
  return str.replace(regex, '').replace(/\s+/g, ' ').trim();
149
149
  }
150
+
151
+ export function initials(text, limit) {
152
+ if (typeof text !== "string") {
153
+ throw new Error("Input must be a string");
154
+ }
155
+
156
+ if (limit !== undefined && (typeof limit !== "number" || isNaN(limit))) {
157
+ throw new Error("Limit must be a valid number");
158
+ }
159
+
160
+ if (limit < 0) {
161
+ throw new Error("Limit must be a non-negative number");
162
+ }
163
+
164
+ const words = text
165
+ .trim()
166
+ .split(/\s+/)
167
+ .filter((word) => word.length > 0);
168
+
169
+ if (words.length === 0) return "";
170
+
171
+ const initialsArray = words
172
+ .map((word) => word.charAt(0))
173
+ .slice(0, limit ?? words.length);
174
+
175
+ return initialsArray.join("");
176
+ }
177
+
178
+ export function removeDuplicates(text) {
179
+ if (typeof text !== "string") {
180
+ throw new Error("Input must be a string");
181
+ }
182
+
183
+ const wordSet = new Set();
184
+
185
+ text.split(" ").forEach((word) => {
186
+ wordSet.add(word);
187
+ });
188
+
189
+ return Array.from(wordSet).join(" ");
190
+ }