text-utils-kit 1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Adarsh Yadav
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,145 @@
1
+ # text-utils-js
2
+
3
+ A lightweight JavaScript utility library for text processing and formatting.
4
+
5
+ ## Features
6
+
7
+ - Count words in a string
8
+ - Count characters in a string
9
+ - Remove extra spaces
10
+ - Capitalize the first letter of a string
11
+ - Generate URL-friendly slugs
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install text-utils-kit
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```javascript
22
+ const textUtils = require("text-utils-kit");;
23
+
24
+ console.log(textUtils.wordCount("Hello World"));
25
+ // 2
26
+
27
+ console.log(textUtils.charCount("Hello"));
28
+ // 5
29
+
30
+ console.log(textUtils.removeExtraSpaces("Hello World"));
31
+ // Hello World
32
+
33
+ console.log(textUtils.capitalize("adarsh"));
34
+ // Adarsh
35
+
36
+ console.log(textUtils.slugify("My First NPM Package"));
37
+ // my-first-npm-package
38
+ ```
39
+
40
+ ## API Reference
41
+
42
+ ### wordCount(text)
43
+
44
+ Returns the total number of words in a string.
45
+
46
+ ```javascript
47
+ textUtils.wordCount("Hello World");
48
+ ```
49
+
50
+ **Output**
51
+
52
+ ```javascript
53
+ 2
54
+ ```
55
+
56
+ ### charCount(text)
57
+
58
+ Returns the total number of characters in a string.
59
+
60
+ ```javascript
61
+ textUtils.charCount("Hello");
62
+ ```
63
+
64
+ **Output**
65
+
66
+ ```javascript
67
+ 5
68
+ ```
69
+
70
+ ### removeExtraSpaces(text)
71
+
72
+ Removes extra spaces from a string.
73
+
74
+ ```javascript
75
+ textUtils.removeExtraSpaces("Hello World");
76
+ ```
77
+
78
+ **Output**
79
+
80
+ ```javascript
81
+ "Hello World"
82
+ ```
83
+
84
+ ### capitalize(text)
85
+
86
+ Capitalizes the first letter of a string.
87
+
88
+ ```javascript
89
+ textUtils.capitalize("adarsh");
90
+ ```
91
+
92
+ **Output**
93
+
94
+ ```javascript
95
+ "Adarsh"
96
+ ```
97
+
98
+ ### slugify(text)
99
+
100
+ Converts text into a URL-friendly slug.
101
+
102
+ ```javascript
103
+ textUtils.slugify("My First NPM Package");
104
+ ```
105
+
106
+ **Output**
107
+
108
+ ```javascript
109
+ "my-first-npm-package"
110
+ ```
111
+
112
+ ## Example
113
+
114
+ ```javascript
115
+ const textUtils = require("text-utils-js");
116
+
117
+ const text = " hello world ";
118
+
119
+ console.log(textUtils.wordCount(text));
120
+ console.log(textUtils.charCount(text));
121
+ console.log(textUtils.removeExtraSpaces(text));
122
+ console.log(textUtils.capitalize("javascript"));
123
+ console.log(textUtils.slugify("JavaScript Utility Package"));
124
+ ```
125
+
126
+ ## Project Structure
127
+
128
+ ```text
129
+ text-utils-js/
130
+ ├── index.js
131
+ ├── test.js
132
+ ├── package.json
133
+ └── README.md
134
+ ```
135
+
136
+ ## Author
137
+
138
+ Adarsh Yadav
139
+
140
+ - GitHub: https://github.com/AdarshYadav-dev
141
+ - Repository: https://github.com/AdarshYadav-dev/text-utils-js
142
+
143
+ ## License
144
+
145
+ This project is licensed under the MIT License.
package/index.js ADDED
@@ -0,0 +1,33 @@
1
+ function wordCount(text) {
2
+ if (!text.trim()) return 0;
3
+ return text.trim().split(/\s+/).length;
4
+ }
5
+
6
+ function charCount(text) {
7
+ return text.length;
8
+ }
9
+
10
+ function removeExtraSpaces(text) {
11
+ return text.replace(/\s+/g, " ").trim();
12
+ }
13
+
14
+ function capitalize(text) {
15
+ return text.charAt(0).toUpperCase() + text.slice(1);
16
+ }
17
+
18
+
19
+ function slugify(text) {
20
+ return text
21
+ .toLowerCase()
22
+ .trim()
23
+ .replace(/\s+/g, "-");
24
+ }
25
+
26
+
27
+ module.exports = {
28
+ wordCount,
29
+ charCount,
30
+ removeExtraSpaces,
31
+ capitalize,
32
+ slugify
33
+ };
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "text-utils-kit",
3
+ "version": "1.0.0",
4
+ "description": "A lightweight JavaScript utility library for text processing and formatting.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "node test.js"
8
+ },
9
+ "keywords": [
10
+ "text",
11
+ "utils",
12
+ "javascript",
13
+ "word-count",
14
+ "slugify"
15
+ ],
16
+ "author": "Adarsh Yadav",
17
+ "license": "MIT"
18
+ }
package/test.js ADDED
@@ -0,0 +1,7 @@
1
+ const textUtils = require("./index");
2
+
3
+ console.log(textUtils.wordCount("Hello World"));
4
+ console.log(textUtils.charCount("Hello"));
5
+ console.log(textUtils.removeExtraSpaces("Hello World"));
6
+ console.log(textUtils.capitalize("adarsh"));
7
+ console.log(textUtils.slugify("My First NPM Package"));
Binary file