stringzy 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/README.md +1 -0
- package/index.js +35 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
��
|
package/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
export function truncateText(text, length) {
|
|
3
|
+
if (typeof text !== "string" || typeof length !== "number") {
|
|
4
|
+
throw new Error("Invalid arguments. Expected (string, number).");
|
|
5
|
+
}
|
|
6
|
+
return text.length > length ? text.slice(0, length) + "..." : text;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export function toSlug(text) {
|
|
11
|
+
if (typeof text !== "string") {
|
|
12
|
+
throw new Error("Invalid argument. Expected a string.");
|
|
13
|
+
}
|
|
14
|
+
return text
|
|
15
|
+
.toLowerCase()
|
|
16
|
+
.trim()
|
|
17
|
+
.replace(/[\s]+/g, "-")
|
|
18
|
+
.replace(/[^\w-]+/g, "");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export function capitalizeWords(text) {
|
|
23
|
+
if (typeof text !== "string") {
|
|
24
|
+
throw new Error("Invalid argument. Expected a string.");
|
|
25
|
+
}
|
|
26
|
+
return text.replace(/\b\w/g, (char) => char.toUpperCase());
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function removeSpecialChars(text) {
|
|
30
|
+
if (typeof text !== "string") {
|
|
31
|
+
throw new Error("Invalid argument. Expected a string.");
|
|
32
|
+
}
|
|
33
|
+
return text.replace(/[^\w\s]/gi, "");
|
|
34
|
+
}
|
|
35
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "stringzy",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"author": "Samarth Ruia",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"description": "A versatile string manipulation library providing a range of text utilities for JavaScript and Node.js applications.",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"string",
|
|
14
|
+
"string-manipulation",
|
|
15
|
+
"text-formatting",
|
|
16
|
+
"cli",
|
|
17
|
+
"text-utils",
|
|
18
|
+
"stringify",
|
|
19
|
+
"stringer",
|
|
20
|
+
"string",
|
|
21
|
+
"text",
|
|
22
|
+
"manipulation",
|
|
23
|
+
"utilities",
|
|
24
|
+
"javascript",
|
|
25
|
+
"nodejs",
|
|
26
|
+
"text-processing",
|
|
27
|
+
"string-utils",
|
|
28
|
+
"text-utils",
|
|
29
|
+
"formatting",
|
|
30
|
+
"transformation",
|
|
31
|
+
"text-manipulation",
|
|
32
|
+
"npm-package"
|
|
33
|
+
],
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/Samarth2190/stringify.git"
|
|
37
|
+
}
|
|
38
|
+
}
|