@luxass/utils 1.2.1 → 1.4.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 (43) hide show
  1. package/dist/guards-DE5pQVvl.cjs +93 -0
  2. package/dist/guards-O1HGJraI.js +68 -0
  3. package/dist/guards.cjs +5 -19
  4. package/dist/guards.d-DXUlpL_S.d.cts +62 -0
  5. package/dist/guards.d-n1BzCANy.d.ts +62 -0
  6. package/dist/guards.d.cts +2 -58
  7. package/dist/guards.d.ts +2 -58
  8. package/dist/guards.js +3 -0
  9. package/dist/index.cjs +15 -58
  10. package/dist/index.d.cts +5 -4
  11. package/dist/index.d.ts +5 -4
  12. package/dist/index.js +5 -0
  13. package/dist/number-Bfr1z0Nr.js +26 -0
  14. package/dist/number-DRbo8lb6.cjs +33 -0
  15. package/dist/number.cjs +2 -7
  16. package/dist/number.d-C1FAMQlq.d.cts +23 -0
  17. package/dist/number.d-C2Xuq3Is.d.ts +23 -0
  18. package/dist/number.d.cts +2 -22
  19. package/dist/number.d.ts +2 -22
  20. package/dist/number.js +3 -0
  21. package/dist/string-C8IOUSBw.js +117 -0
  22. package/dist/string-CkqQ4Tys.cjs +154 -0
  23. package/dist/string.cjs +7 -33
  24. package/dist/string.d-DbrXP95T.d.cts +90 -0
  25. package/dist/string.d-Dv6EVJz4.d.ts +90 -0
  26. package/dist/string.d.cts +2 -79
  27. package/dist/string.d.ts +2 -79
  28. package/dist/string.js +3 -0
  29. package/dist/types.cjs +0 -2
  30. package/dist/types.d-BcKIY6l3.d.ts +72 -0
  31. package/dist/types.d-fcYBBT6c.d.cts +72 -0
  32. package/dist/types.d.cts +2 -66
  33. package/dist/types.d.ts +2 -66
  34. package/dist/types.js +0 -0
  35. package/package.json +21 -21
  36. package/dist/chunk-7RYURVAF.mjs +0 -6
  37. package/dist/chunk-MNDVPE25.mjs +0 -28
  38. package/dist/chunk-OKC7RR3A.mjs +0 -15
  39. package/dist/guards.mjs +0 -1
  40. package/dist/index.mjs +0 -3
  41. package/dist/number.mjs +0 -1
  42. package/dist/string.mjs +0 -1
  43. package/dist/types.mjs +0 -1
package/dist/number.d.cts CHANGED
@@ -1,22 +1,2 @@
1
- /**
2
- * Clamp a value between a min and max value.
3
- * @param {number} value
4
- * @param {number} min
5
- * @param {number} max
6
- * @returns {number} the clamped value
7
- *
8
- * @example
9
- * ```ts
10
- * clamp(5, 0, 10)
11
- * // 5
12
- *
13
- * clamp(5, 10, 20)
14
- * // 10
15
- *
16
- * clamp(5, 0, 4)
17
- * // 4
18
- * ```
19
- */
20
- declare function clamp(value: number, min: number, max: number): number;
21
-
22
- export { clamp };
1
+ import { clamp } from "./number.d-C1FAMQlq.cjs";
2
+ export { clamp };
package/dist/number.d.ts CHANGED
@@ -1,22 +1,2 @@
1
- /**
2
- * Clamp a value between a min and max value.
3
- * @param {number} value
4
- * @param {number} min
5
- * @param {number} max
6
- * @returns {number} the clamped value
7
- *
8
- * @example
9
- * ```ts
10
- * clamp(5, 0, 10)
11
- * // 5
12
- *
13
- * clamp(5, 10, 20)
14
- * // 10
15
- *
16
- * clamp(5, 0, 4)
17
- * // 4
18
- * ```
19
- */
20
- declare function clamp(value: number, min: number, max: number): number;
21
-
22
- export { clamp };
1
+ import { clamp$1 as clamp } from "./number.d-C2Xuq3Is.js";
2
+ export { clamp };
package/dist/number.js ADDED
@@ -0,0 +1,3 @@
1
+ import { clamp } from "./number-Bfr1z0Nr.js";
2
+
3
+ export { clamp };
@@ -0,0 +1,117 @@
1
+ //#region src/string.ts
2
+ const FULL_WHITESPACE_RE = /^\s*$/;
3
+ /**
4
+ * Capitalizes the first character of a string and converts the rest to lowercase
5
+ * @param {string} str - The string to capitalize
6
+ * @returns {string} The capitalized string
7
+ * @example
8
+ * ```ts
9
+ * capitalize("hello") // "Hello"
10
+ * capitalize("hELLO") // "Hello"
11
+ * capitalize("") // ""
12
+ * ```
13
+ */
14
+ function capitalize(str) {
15
+ if (!str) return "";
16
+ return str[0].toUpperCase() + str.slice(1).toLowerCase();
17
+ }
18
+ /**
19
+ * Converts a string to camelCase format
20
+ * @param {string} str - The string to convert to camelCase
21
+ * @returns {string} The string in camelCase format
22
+ * @example
23
+ * ```ts
24
+ * toCamelCase("hello world") // "helloWorld"
25
+ * toCamelCase("hello-world") // "helloWorld"
26
+ * toCamelCase("hello_world") // "helloWorld"
27
+ * toCamelCase("HelloWorld") // "helloWorld"
28
+ * toCamelCase("") // ""
29
+ * ```
30
+ */
31
+ function toCamelCase(str) {
32
+ if (!str) return "";
33
+ str = str.trim().replace(/\s+/g, " ");
34
+ const words = str.split(/[\s\-_]+/);
35
+ if (words.length === 1 && words[0]?.length === 1) return words[0].toLowerCase();
36
+ let result = words[0]?.toLowerCase() || "";
37
+ for (let i = 1; i < words.length; i++) {
38
+ const word = words[i];
39
+ if (!word) continue;
40
+ const hasCamelCase = word.match(/[a-z][A-Z]/g);
41
+ result += hasCamelCase ? word.charAt(0).toUpperCase() + word.slice(1) : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
42
+ }
43
+ return result;
44
+ }
45
+ /**
46
+ * Converts a string to kebab-case format
47
+ * @param {string} str - The string to convert to kebab-case
48
+ * @returns {string} The string in kebab-case format
49
+ * @example
50
+ * ```ts
51
+ * toKebabCase("hello world") // "hello-world"
52
+ * toKebabCase("helloWorld") // "hello-world"
53
+ * toKebabCase("hello_world") // "hello-world"
54
+ * toKebabCase("HelloWorld") // "hello-world"
55
+ * toKebabCase("") // ""
56
+ * ```
57
+ */
58
+ function toKebabCase(str) {
59
+ if (!str) return "";
60
+ return str.trim().replace(/_/g, "-").replace(/\s+/g, " ").replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/\s+/g, "-").replace(/-+/g, "-").toLowerCase();
61
+ }
62
+ /**
63
+ * Converts a string to PascalCase format
64
+ * @param {string} str - The string to convert to PascalCase
65
+ * @returns {string} The string in PascalCase format
66
+ * @example
67
+ * ```ts
68
+ * toPascalCase("hello world") // "HelloWorld"
69
+ * toPascalCase("hello-world") // "HelloWorld"
70
+ * toPascalCase("hello_world") // "HelloWorld"
71
+ * toPascalCase("helloWorld") // "HelloWorld"
72
+ * toPascalCase("") // ""
73
+ * ```
74
+ */
75
+ function toPascalCase(str) {
76
+ if (!str) return "";
77
+ return str.trim().replace(/[_-]+/g, " ").replace(/\s+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z])([A-Z][a-z])/g, "$1 $2").replace(/(\d+)([a-z])/gi, "$1 $2").split(" ").filter((word) => word.length > 0).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
78
+ }
79
+ /**
80
+ * Converts a string to snake_case format
81
+ * @param {string} str - The string to convert to snake_case
82
+ * @returns {string} The string in snake_case format
83
+ * @example
84
+ * ```ts
85
+ * toSnakeCase("hello world") // "hello_world"
86
+ * toSnakeCase("helloWorld") // "hello_world"
87
+ * toSnakeCase("hello-world") // "hello_world"
88
+ * toSnakeCase("HelloWorld") // "hello_world"
89
+ * toSnakeCase("") // ""
90
+ * ```
91
+ */
92
+ function toSnakeCase(str) {
93
+ if (!str) return "";
94
+ return str.trim().replace(/-/g, "_").replace(/\s+/g, " ").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/\s+/g, "_").replace(/_+/g, "_").toLowerCase();
95
+ }
96
+ function dedent(strings, ...values) {
97
+ const raw = typeof strings === "string" ? [strings] : strings.raw;
98
+ let result = "";
99
+ for (let i = 0; i < raw.length; i++) {
100
+ const next = raw[i];
101
+ result += next;
102
+ if (i < values.length) result += values[i];
103
+ }
104
+ const lines = result.split("\n");
105
+ const whitespaceLines = lines.map((line) => FULL_WHITESPACE_RE.test(line));
106
+ const commonIndent = lines.reduce((min, line, idx) => {
107
+ if (whitespaceLines[idx]) return min;
108
+ const indent = line.match(/^\s*/)?.[0].length;
109
+ return indent === void 0 ? min : Math.min(min, indent);
110
+ }, Number.POSITIVE_INFINITY);
111
+ const firstNonWhitespaceLine = whitespaceLines.findIndex((isWhitespace) => !isWhitespace);
112
+ const lastNonWhitespaceLine = whitespaceLines.lastIndexOf(false);
113
+ return lines.slice(firstNonWhitespaceLine >= 0 ? firstNonWhitespaceLine : 0, lastNonWhitespaceLine >= 0 ? lastNonWhitespaceLine + 1 : lines.length).map((line) => line.slice(commonIndent)).join("\n");
114
+ }
115
+
116
+ //#endregion
117
+ export { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+
3
+ //#region src/string.ts
4
+ const FULL_WHITESPACE_RE = /^\s*$/;
5
+ /**
6
+ * Capitalizes the first character of a string and converts the rest to lowercase
7
+ * @param {string} str - The string to capitalize
8
+ * @returns {string} The capitalized string
9
+ * @example
10
+ * ```ts
11
+ * capitalize("hello") // "Hello"
12
+ * capitalize("hELLO") // "Hello"
13
+ * capitalize("") // ""
14
+ * ```
15
+ */
16
+ function capitalize(str) {
17
+ if (!str) return "";
18
+ return str[0].toUpperCase() + str.slice(1).toLowerCase();
19
+ }
20
+ /**
21
+ * Converts a string to camelCase format
22
+ * @param {string} str - The string to convert to camelCase
23
+ * @returns {string} The string in camelCase format
24
+ * @example
25
+ * ```ts
26
+ * toCamelCase("hello world") // "helloWorld"
27
+ * toCamelCase("hello-world") // "helloWorld"
28
+ * toCamelCase("hello_world") // "helloWorld"
29
+ * toCamelCase("HelloWorld") // "helloWorld"
30
+ * toCamelCase("") // ""
31
+ * ```
32
+ */
33
+ function toCamelCase(str) {
34
+ if (!str) return "";
35
+ str = str.trim().replace(/\s+/g, " ");
36
+ const words = str.split(/[\s\-_]+/);
37
+ if (words.length === 1 && words[0]?.length === 1) return words[0].toLowerCase();
38
+ let result = words[0]?.toLowerCase() || "";
39
+ for (let i = 1; i < words.length; i++) {
40
+ const word = words[i];
41
+ if (!word) continue;
42
+ const hasCamelCase = word.match(/[a-z][A-Z]/g);
43
+ result += hasCamelCase ? word.charAt(0).toUpperCase() + word.slice(1) : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
44
+ }
45
+ return result;
46
+ }
47
+ /**
48
+ * Converts a string to kebab-case format
49
+ * @param {string} str - The string to convert to kebab-case
50
+ * @returns {string} The string in kebab-case format
51
+ * @example
52
+ * ```ts
53
+ * toKebabCase("hello world") // "hello-world"
54
+ * toKebabCase("helloWorld") // "hello-world"
55
+ * toKebabCase("hello_world") // "hello-world"
56
+ * toKebabCase("HelloWorld") // "hello-world"
57
+ * toKebabCase("") // ""
58
+ * ```
59
+ */
60
+ function toKebabCase(str) {
61
+ if (!str) return "";
62
+ return str.trim().replace(/_/g, "-").replace(/\s+/g, " ").replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/\s+/g, "-").replace(/-+/g, "-").toLowerCase();
63
+ }
64
+ /**
65
+ * Converts a string to PascalCase format
66
+ * @param {string} str - The string to convert to PascalCase
67
+ * @returns {string} The string in PascalCase format
68
+ * @example
69
+ * ```ts
70
+ * toPascalCase("hello world") // "HelloWorld"
71
+ * toPascalCase("hello-world") // "HelloWorld"
72
+ * toPascalCase("hello_world") // "HelloWorld"
73
+ * toPascalCase("helloWorld") // "HelloWorld"
74
+ * toPascalCase("") // ""
75
+ * ```
76
+ */
77
+ function toPascalCase(str) {
78
+ if (!str) return "";
79
+ return str.trim().replace(/[_-]+/g, " ").replace(/\s+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z])([A-Z][a-z])/g, "$1 $2").replace(/(\d+)([a-z])/gi, "$1 $2").split(" ").filter((word) => word.length > 0).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
80
+ }
81
+ /**
82
+ * Converts a string to snake_case format
83
+ * @param {string} str - The string to convert to snake_case
84
+ * @returns {string} The string in snake_case format
85
+ * @example
86
+ * ```ts
87
+ * toSnakeCase("hello world") // "hello_world"
88
+ * toSnakeCase("helloWorld") // "hello_world"
89
+ * toSnakeCase("hello-world") // "hello_world"
90
+ * toSnakeCase("HelloWorld") // "hello_world"
91
+ * toSnakeCase("") // ""
92
+ * ```
93
+ */
94
+ function toSnakeCase(str) {
95
+ if (!str) return "";
96
+ return str.trim().replace(/-/g, "_").replace(/\s+/g, " ").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/\s+/g, "_").replace(/_+/g, "_").toLowerCase();
97
+ }
98
+ function dedent(strings, ...values) {
99
+ const raw = typeof strings === "string" ? [strings] : strings.raw;
100
+ let result = "";
101
+ for (let i = 0; i < raw.length; i++) {
102
+ const next = raw[i];
103
+ result += next;
104
+ if (i < values.length) result += values[i];
105
+ }
106
+ const lines = result.split("\n");
107
+ const whitespaceLines = lines.map((line) => FULL_WHITESPACE_RE.test(line));
108
+ const commonIndent = lines.reduce((min, line, idx) => {
109
+ if (whitespaceLines[idx]) return min;
110
+ const indent = line.match(/^\s*/)?.[0].length;
111
+ return indent === void 0 ? min : Math.min(min, indent);
112
+ }, Number.POSITIVE_INFINITY);
113
+ const firstNonWhitespaceLine = whitespaceLines.findIndex((isWhitespace) => !isWhitespace);
114
+ const lastNonWhitespaceLine = whitespaceLines.lastIndexOf(false);
115
+ return lines.slice(firstNonWhitespaceLine >= 0 ? firstNonWhitespaceLine : 0, lastNonWhitespaceLine >= 0 ? lastNonWhitespaceLine + 1 : lines.length).map((line) => line.slice(commonIndent)).join("\n");
116
+ }
117
+
118
+ //#endregion
119
+ Object.defineProperty(exports, 'capitalize', {
120
+ enumerable: true,
121
+ get: function () {
122
+ return capitalize;
123
+ }
124
+ });
125
+ Object.defineProperty(exports, 'dedent', {
126
+ enumerable: true,
127
+ get: function () {
128
+ return dedent;
129
+ }
130
+ });
131
+ Object.defineProperty(exports, 'toCamelCase', {
132
+ enumerable: true,
133
+ get: function () {
134
+ return toCamelCase;
135
+ }
136
+ });
137
+ Object.defineProperty(exports, 'toKebabCase', {
138
+ enumerable: true,
139
+ get: function () {
140
+ return toKebabCase;
141
+ }
142
+ });
143
+ Object.defineProperty(exports, 'toPascalCase', {
144
+ enumerable: true,
145
+ get: function () {
146
+ return toPascalCase;
147
+ }
148
+ });
149
+ Object.defineProperty(exports, 'toSnakeCase', {
150
+ enumerable: true,
151
+ get: function () {
152
+ return toSnakeCase;
153
+ }
154
+ });
package/dist/string.cjs CHANGED
@@ -1,34 +1,8 @@
1
- 'use strict';
1
+ const require_string = require('./string-CkqQ4Tys.cjs');
2
2
 
3
- // src/string.ts
4
- function capitalize(str) {
5
- if (typeof str !== "string") throw new TypeError("Expected a string");
6
- if (str.trim().length === 0) return "";
7
- return str[0].toUpperCase() + str.slice(1).toLowerCase();
8
- }
9
- function toCamelCase(str) {
10
- if (typeof str !== "string") throw new TypeError("Expected a string");
11
- if (str.trim().length === 0) return "";
12
- return str.toLowerCase().replace(/[-_](.)/g, (_, c) => c.toUpperCase());
13
- }
14
- function toKebabCase(str) {
15
- if (typeof str !== "string") throw new TypeError("Expected a string");
16
- if (str.trim().length === 0) return "";
17
- return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
18
- }
19
- function toPascalCase(str) {
20
- if (typeof str !== "string") throw new TypeError("Expected a string");
21
- if (str.trim().length === 0) return "";
22
- return str.toLowerCase().replace(/[-_](.)/g, (_, c) => c.toUpperCase()).replace(/^[a-z]/, (c) => c.toUpperCase());
23
- }
24
- function toSnakeCase(str) {
25
- if (typeof str !== "string") throw new TypeError("Expected a string");
26
- if (str.trim().length === 0) return "";
27
- return str.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
28
- }
29
-
30
- exports.capitalize = capitalize;
31
- exports.toCamelCase = toCamelCase;
32
- exports.toKebabCase = toKebabCase;
33
- exports.toPascalCase = toPascalCase;
34
- exports.toSnakeCase = toSnakeCase;
3
+ exports.capitalize = require_string.capitalize
4
+ exports.dedent = require_string.dedent
5
+ exports.toCamelCase = require_string.toCamelCase
6
+ exports.toKebabCase = require_string.toKebabCase
7
+ exports.toPascalCase = require_string.toPascalCase
8
+ exports.toSnakeCase = require_string.toSnakeCase
@@ -0,0 +1,90 @@
1
+ //#region src/string.d.ts
2
+ /**
3
+ * Capitalizes the first character of a string and converts the rest to lowercase
4
+ * @param {string} str - The string to capitalize
5
+ * @returns {string} The capitalized string
6
+ * @example
7
+ * ```ts
8
+ * capitalize("hello") // "Hello"
9
+ * capitalize("hELLO") // "Hello"
10
+ * capitalize("") // ""
11
+ * ```
12
+ */declare function capitalize(str: string): string;
13
+
14
+ /**
15
+ * Converts a string to camelCase format
16
+ * @param {string} str - The string to convert to camelCase
17
+ * @returns {string} The string in camelCase format
18
+ * @example
19
+ * ```ts
20
+ * toCamelCase("hello world") // "helloWorld"
21
+ * toCamelCase("hello-world") // "helloWorld"
22
+ * toCamelCase("hello_world") // "helloWorld"
23
+ * toCamelCase("HelloWorld") // "helloWorld"
24
+ * toCamelCase("") // ""
25
+ * ```
26
+ */
27
+ declare function toCamelCase(str: string): string;
28
+
29
+ /**
30
+ * Converts a string to kebab-case format
31
+ * @param {string} str - The string to convert to kebab-case
32
+ * @returns {string} The string in kebab-case format
33
+ * @example
34
+ * ```ts
35
+ * toKebabCase("hello world") // "hello-world"
36
+ * toKebabCase("helloWorld") // "hello-world"
37
+ * toKebabCase("hello_world") // "hello-world"
38
+ * toKebabCase("HelloWorld") // "hello-world"
39
+ * toKebabCase("") // ""
40
+ * ```
41
+ */
42
+ declare function toKebabCase(str: string): string;
43
+
44
+ /**
45
+ * Converts a string to PascalCase format
46
+ * @param {string} str - The string to convert to PascalCase
47
+ * @returns {string} The string in PascalCase format
48
+ * @example
49
+ * ```ts
50
+ * toPascalCase("hello world") // "HelloWorld"
51
+ * toPascalCase("hello-world") // "HelloWorld"
52
+ * toPascalCase("hello_world") // "HelloWorld"
53
+ * toPascalCase("helloWorld") // "HelloWorld"
54
+ * toPascalCase("") // ""
55
+ * ```
56
+ */
57
+ declare function toPascalCase(str: string): string;
58
+
59
+ /**
60
+ * Converts a string to snake_case format
61
+ * @param {string} str - The string to convert to snake_case
62
+ * @returns {string} The string in snake_case format
63
+ * @example
64
+ * ```ts
65
+ * toSnakeCase("hello world") // "hello_world"
66
+ * toSnakeCase("helloWorld") // "hello_world"
67
+ * toSnakeCase("hello-world") // "hello_world"
68
+ * toSnakeCase("HelloWorld") // "hello_world"
69
+ * toSnakeCase("") // ""
70
+ * ```
71
+ */
72
+ declare function toSnakeCase(str: string): string;
73
+
74
+ /**
75
+ * Removes leading and trailing whitespace from each line of a string
76
+ * @param {TemplateStringsArray | string} literals - The string to dedent
77
+ * @returns {string} The dedented string
78
+ * @example ```ts
79
+ dedent`
80
+ This is a test.
81
+ This is another line.
82
+ `
83
+ // "This is a test.\nThis is another line."
84
+ ```
85
+ */
86
+ declare function dedent(literals: string): string;
87
+ declare function dedent(strings: TemplateStringsArray, ...values: unknown[]): string;
88
+
89
+ //#endregion
90
+ export { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
@@ -0,0 +1,90 @@
1
+ //#region src/string.d.ts
2
+ /**
3
+ * Capitalizes the first character of a string and converts the rest to lowercase
4
+ * @param {string} str - The string to capitalize
5
+ * @returns {string} The capitalized string
6
+ * @example
7
+ * ```ts
8
+ * capitalize("hello") // "Hello"
9
+ * capitalize("hELLO") // "Hello"
10
+ * capitalize("") // ""
11
+ * ```
12
+ */declare function capitalize(str: string): string;
13
+
14
+ /**
15
+ * Converts a string to camelCase format
16
+ * @param {string} str - The string to convert to camelCase
17
+ * @returns {string} The string in camelCase format
18
+ * @example
19
+ * ```ts
20
+ * toCamelCase("hello world") // "helloWorld"
21
+ * toCamelCase("hello-world") // "helloWorld"
22
+ * toCamelCase("hello_world") // "helloWorld"
23
+ * toCamelCase("HelloWorld") // "helloWorld"
24
+ * toCamelCase("") // ""
25
+ * ```
26
+ */
27
+ declare function toCamelCase(str: string): string;
28
+
29
+ /**
30
+ * Converts a string to kebab-case format
31
+ * @param {string} str - The string to convert to kebab-case
32
+ * @returns {string} The string in kebab-case format
33
+ * @example
34
+ * ```ts
35
+ * toKebabCase("hello world") // "hello-world"
36
+ * toKebabCase("helloWorld") // "hello-world"
37
+ * toKebabCase("hello_world") // "hello-world"
38
+ * toKebabCase("HelloWorld") // "hello-world"
39
+ * toKebabCase("") // ""
40
+ * ```
41
+ */
42
+ declare function toKebabCase(str: string): string;
43
+
44
+ /**
45
+ * Converts a string to PascalCase format
46
+ * @param {string} str - The string to convert to PascalCase
47
+ * @returns {string} The string in PascalCase format
48
+ * @example
49
+ * ```ts
50
+ * toPascalCase("hello world") // "HelloWorld"
51
+ * toPascalCase("hello-world") // "HelloWorld"
52
+ * toPascalCase("hello_world") // "HelloWorld"
53
+ * toPascalCase("helloWorld") // "HelloWorld"
54
+ * toPascalCase("") // ""
55
+ * ```
56
+ */
57
+ declare function toPascalCase(str: string): string;
58
+
59
+ /**
60
+ * Converts a string to snake_case format
61
+ * @param {string} str - The string to convert to snake_case
62
+ * @returns {string} The string in snake_case format
63
+ * @example
64
+ * ```ts
65
+ * toSnakeCase("hello world") // "hello_world"
66
+ * toSnakeCase("helloWorld") // "hello_world"
67
+ * toSnakeCase("hello-world") // "hello_world"
68
+ * toSnakeCase("HelloWorld") // "hello_world"
69
+ * toSnakeCase("") // ""
70
+ * ```
71
+ */
72
+ declare function toSnakeCase(str: string): string;
73
+
74
+ /**
75
+ * Removes leading and trailing whitespace from each line of a string
76
+ * @param {TemplateStringsArray | string} literals - The string to dedent
77
+ * @returns {string} The dedented string
78
+ * @example ```ts
79
+ dedent`
80
+ This is a test.
81
+ This is another line.
82
+ `
83
+ // "This is a test.\nThis is another line."
84
+ ```
85
+ */
86
+ declare function dedent(literals: string): string;
87
+ declare function dedent(strings: TemplateStringsArray, ...values: unknown[]): string;
88
+
89
+ //#endregion
90
+ export { capitalize as capitalize$1, dedent as dedent$1, toCamelCase as toCamelCase$1, toKebabCase as toKebabCase$1, toPascalCase as toPascalCase$1, toSnakeCase as toSnakeCase$1 };
package/dist/string.d.cts CHANGED
@@ -1,79 +1,2 @@
1
- /**
2
- * First letter uppercase, other lowercase
3
- * @param {string} str - The string to capitalize
4
- * @returns {string} The capitalized string
5
- * @throws {TypeError} If `str` is not string
6
- *
7
- * @example
8
- * ```ts
9
- * capitalize("hello")
10
- * // "Hello"
11
- * ```
12
- */
13
- declare function capitalize(str: string): string;
14
- /**
15
- * Converts a string to camel case.
16
- * @param {string} str - The input string to be converted.
17
- * @returns {string} The camel cased string.
18
- * @throws {TypeError} If the input is not a string.
19
- *
20
- * @example
21
- * ```ts
22
- * toCamelCase("some_text_here")
23
- * // "someTextHere"
24
- *
25
- * toCamelCase("another-Example")
26
- * // "anotherExample"
27
- * ```
28
- */
29
- declare function toCamelCase(str: string): string;
30
- /**
31
- * Converts a string to kebab case.
32
- * @param {string} str - The input string to be converted.
33
- * @returns {string} The kebab cased string.
34
- * @throws {TypeError} If the input is not a string.
35
- *
36
- * @example
37
- * ```ts
38
- * toKebabCase("someTextHere")
39
- * // "some-text-here"
40
- *
41
- * toKebabCase("anotherExample")
42
- * // "another-example"
43
- * ```
44
- */
45
- declare function toKebabCase(str: string): string;
46
- /**
47
- * Converts a string to pascal case.
48
- * @param {string} str - The input string to be converted.
49
- * @returns {string} The pascal cased string.
50
- * @throws {TypeError} If the input is not a string.
51
- *
52
- * @example
53
- * ```ts
54
- * toPascalCase("some_text_here")
55
- * // "SomeTextHere"
56
- *
57
- * toPascalCase("another-Example")
58
- * // "AnotherExample"
59
- * ```
60
- */
61
- declare function toPascalCase(str: string): string;
62
- /**
63
- * Converts a string to snake case.
64
- * @param {string} str - The input string to be converted.
65
- * @returns {string} The snake cased string.
66
- * @throws {TypeError} If the input is not a string.
67
- *
68
- * @example
69
- * ```ts
70
- * toSnakeCase("someTextHere")
71
- * // "some_text_here"
72
- *
73
- * toSnakeCase("anotherExample")
74
- * // "another_example"
75
- * ```
76
- */
77
- declare function toSnakeCase(str: string): string;
78
-
79
- export { capitalize, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
1
+ import { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string.d-DbrXP95T.cjs";
2
+ export { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };