@luxass/utils 1.1.0 → 1.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.
@@ -1,37 +1,27 @@
1
1
  // src/string.ts
2
2
  function capitalize(str) {
3
- if (typeof str !== "string")
4
- throw new TypeError("Expected a string");
5
- if (str.trim().length === 0)
6
- return "";
3
+ if (typeof str !== "string") throw new TypeError("Expected a string");
4
+ if (str.trim().length === 0) return "";
7
5
  return str[0].toUpperCase() + str.slice(1).toLowerCase();
8
6
  }
9
7
  function toCamelCase(str) {
10
- if (typeof str !== "string")
11
- throw new TypeError("Expected a string");
12
- if (str.trim().length === 0)
13
- return "";
8
+ if (typeof str !== "string") throw new TypeError("Expected a string");
9
+ if (str.trim().length === 0) return "";
14
10
  return str.toLowerCase().replace(/[-_](.)/g, (_, c) => c.toUpperCase());
15
11
  }
16
12
  function toKebabCase(str) {
17
- if (typeof str !== "string")
18
- throw new TypeError("Expected a string");
19
- if (str.trim().length === 0)
20
- return "";
13
+ if (typeof str !== "string") throw new TypeError("Expected a string");
14
+ if (str.trim().length === 0) return "";
21
15
  return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
22
16
  }
23
17
  function toPascalCase(str) {
24
- if (typeof str !== "string")
25
- throw new TypeError("Expected a string");
26
- if (str.trim().length === 0)
27
- return "";
18
+ if (typeof str !== "string") throw new TypeError("Expected a string");
19
+ if (str.trim().length === 0) return "";
28
20
  return str.toLowerCase().replace(/[-_](.)/g, (_, c) => c.toUpperCase()).replace(/^[a-z]/, (c) => c.toUpperCase());
29
21
  }
30
22
  function toSnakeCase(str) {
31
- if (typeof str !== "string")
32
- throw new TypeError("Expected a string");
33
- if (str.trim().length === 0)
34
- return "";
23
+ if (typeof str !== "string") throw new TypeError("Expected a string");
24
+ if (str.trim().length === 0) return "";
35
25
  return str.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
36
26
  }
37
27
 
package/dist/index.cjs CHANGED
@@ -21,38 +21,28 @@ function clamp(value, min, max) {
21
21
 
22
22
  // src/string.ts
23
23
  function capitalize(str) {
24
- if (typeof str !== "string")
25
- throw new TypeError("Expected a string");
26
- if (str.trim().length === 0)
27
- return "";
24
+ if (typeof str !== "string") throw new TypeError("Expected a string");
25
+ if (str.trim().length === 0) return "";
28
26
  return str[0].toUpperCase() + str.slice(1).toLowerCase();
29
27
  }
30
28
  function toCamelCase(str) {
31
- if (typeof str !== "string")
32
- throw new TypeError("Expected a string");
33
- if (str.trim().length === 0)
34
- return "";
29
+ if (typeof str !== "string") throw new TypeError("Expected a string");
30
+ if (str.trim().length === 0) return "";
35
31
  return str.toLowerCase().replace(/[-_](.)/g, (_, c) => c.toUpperCase());
36
32
  }
37
33
  function toKebabCase(str) {
38
- if (typeof str !== "string")
39
- throw new TypeError("Expected a string");
40
- if (str.trim().length === 0)
41
- return "";
34
+ if (typeof str !== "string") throw new TypeError("Expected a string");
35
+ if (str.trim().length === 0) return "";
42
36
  return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
43
37
  }
44
38
  function toPascalCase(str) {
45
- if (typeof str !== "string")
46
- throw new TypeError("Expected a string");
47
- if (str.trim().length === 0)
48
- return "";
39
+ if (typeof str !== "string") throw new TypeError("Expected a string");
40
+ if (str.trim().length === 0) return "";
49
41
  return str.toLowerCase().replace(/[-_](.)/g, (_, c) => c.toUpperCase()).replace(/^[a-z]/, (c) => c.toUpperCase());
50
42
  }
51
43
  function toSnakeCase(str) {
52
- if (typeof str !== "string")
53
- throw new TypeError("Expected a string");
54
- if (str.trim().length === 0)
55
- return "";
44
+ if (typeof str !== "string") throw new TypeError("Expected a string");
45
+ if (str.trim().length === 0) return "";
56
46
  return str.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
57
47
  }
58
48
 
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export { capitalize, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from './chunk-JVIVQFL7.mjs';
1
+ export { capitalize, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from './chunk-MNDVPE25.mjs';
2
2
  export { isNotNull, isNotNullish, isNotUndefined, isTruthy } from './chunk-OKC7RR3A.mjs';
3
3
  export { clamp } from './chunk-7RYURVAF.mjs';
package/dist/string.cjs CHANGED
@@ -2,38 +2,28 @@
2
2
 
3
3
  // src/string.ts
4
4
  function capitalize(str) {
5
- if (typeof str !== "string")
6
- throw new TypeError("Expected a string");
7
- if (str.trim().length === 0)
8
- return "";
5
+ if (typeof str !== "string") throw new TypeError("Expected a string");
6
+ if (str.trim().length === 0) return "";
9
7
  return str[0].toUpperCase() + str.slice(1).toLowerCase();
10
8
  }
11
9
  function toCamelCase(str) {
12
- if (typeof str !== "string")
13
- throw new TypeError("Expected a string");
14
- if (str.trim().length === 0)
15
- return "";
10
+ if (typeof str !== "string") throw new TypeError("Expected a string");
11
+ if (str.trim().length === 0) return "";
16
12
  return str.toLowerCase().replace(/[-_](.)/g, (_, c) => c.toUpperCase());
17
13
  }
18
14
  function toKebabCase(str) {
19
- if (typeof str !== "string")
20
- throw new TypeError("Expected a string");
21
- if (str.trim().length === 0)
22
- return "";
15
+ if (typeof str !== "string") throw new TypeError("Expected a string");
16
+ if (str.trim().length === 0) return "";
23
17
  return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
24
18
  }
25
19
  function toPascalCase(str) {
26
- if (typeof str !== "string")
27
- throw new TypeError("Expected a string");
28
- if (str.trim().length === 0)
29
- return "";
20
+ if (typeof str !== "string") throw new TypeError("Expected a string");
21
+ if (str.trim().length === 0) return "";
30
22
  return str.toLowerCase().replace(/[-_](.)/g, (_, c) => c.toUpperCase()).replace(/^[a-z]/, (c) => c.toUpperCase());
31
23
  }
32
24
  function toSnakeCase(str) {
33
- if (typeof str !== "string")
34
- throw new TypeError("Expected a string");
35
- if (str.trim().length === 0)
36
- return "";
25
+ if (typeof str !== "string") throw new TypeError("Expected a string");
26
+ if (str.trim().length === 0) return "";
37
27
  return str.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
38
28
  }
39
29
 
package/dist/string.mjs CHANGED
@@ -1 +1 @@
1
- export { capitalize, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from './chunk-JVIVQFL7.mjs';
1
+ export { capitalize, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from './chunk-MNDVPE25.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxass/utils",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "A collection of utilities for JavaScript/TypeScript",
5
5
  "type": "module",
6
6
  "author": {
@@ -8,7 +8,7 @@
8
8
  "email": "lucasnrgaard@gmail.com",
9
9
  "url": "https://luxass.dev"
10
10
  },
11
- "packageManager": "pnpm@8.12.0",
11
+ "packageManager": "pnpm@9.4.0",
12
12
  "license": "MIT",
13
13
  "homepage": "https://github.com/luxass/utils",
14
14
  "repository": {
@@ -83,12 +83,12 @@
83
83
  "typecheck": "tsc --noEmit"
84
84
  },
85
85
  "devDependencies": {
86
- "@luxass/eslint-config": "^4.0.0-beta.16",
87
- "@types/node": "^20.10.4",
88
- "eslint": "^8.55.0",
89
- "eslint-plugin-format": "^0.1.0",
90
- "tsup": "^8.0.1",
91
- "typescript": "^5.3.3",
92
- "vitest": "^1.0.4"
86
+ "@luxass/eslint-config": "^4.7.0",
87
+ "@types/node": "^20.14.9",
88
+ "eslint": "^9.6.0",
89
+ "eslint-plugin-format": "^0.1.2",
90
+ "tsup": "^8.1.0",
91
+ "typescript": "^5.5.2",
92
+ "vitest": "^1.6.0"
93
93
  }
94
94
  }