@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/string.d.ts 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$1 as capitalize, dedent$1 as dedent, toCamelCase$1 as toCamelCase, toKebabCase$1 as toKebabCase, toPascalCase$1 as toPascalCase, toSnakeCase$1 as toSnakeCase } from "./string.d-Dv6EVJz4.js";
2
+ export { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
package/dist/string.js ADDED
@@ -0,0 +1,3 @@
1
+ import { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string-C8IOUSBw.js";
2
+
3
+ export { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
package/dist/types.cjs CHANGED
@@ -1,2 +0,0 @@
1
- 'use strict';
2
-
@@ -0,0 +1,72 @@
1
+ //#region src/types.d.ts
2
+ /**
3
+ * Whatever type, or Promise of that type
4
+ * @param T - Type
5
+ * @returns T or Promise<T>
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * type A = Awaitable<string>
10
+ * // string | Promise<string>
11
+ * ```
12
+ */type Awaitable<T> = T | PromiseLike<T>;
13
+
14
+ /**
15
+ * Whatever type, or null
16
+ * @param T - Type
17
+ * @returns T or null
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * type A = Nullable<string>
22
+ * // string | null
23
+ * ```
24
+ */
25
+ type Nullable<T> = T | null;
26
+
27
+ /**
28
+ * Whatever type, null or undefined
29
+ * @param T - Type
30
+ * @returns T, undefined or null
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * type A = Nullish<string>
35
+ * // string | null | undefined
36
+ * ```
37
+ */
38
+ type Nullish<T> = T | null | undefined;
39
+
40
+ /**
41
+ * Array, or not yet
42
+ */
43
+ type Arrayable<T> = T | Array<T>;
44
+
45
+ /**
46
+ * Infers the element type of an array
47
+ * @param T - Array type
48
+ * @returns The inferred element type
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * type A = ElementOf<string[]>
53
+ * // string
54
+ * ```
55
+ */
56
+ type ElementOf<T> = T extends (infer E)[] ? E : never;
57
+
58
+ /**
59
+ * Infers the arguments type of a function
60
+ * @param T - Function type
61
+ * @returns The inferred arguments type
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * type A = InferArguments<(a: string, b: number) => void>
66
+ * // [string, number]
67
+ * ```
68
+ */
69
+ type InferArguments<T> = T extends ((...args: infer A) => any) ? A : never;
70
+
71
+ //#endregion
72
+ export { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish };
@@ -0,0 +1,72 @@
1
+ //#region src/types.d.ts
2
+ /**
3
+ * Whatever type, or Promise of that type
4
+ * @param T - Type
5
+ * @returns T or Promise<T>
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * type A = Awaitable<string>
10
+ * // string | Promise<string>
11
+ * ```
12
+ */type Awaitable<T> = T | PromiseLike<T>;
13
+
14
+ /**
15
+ * Whatever type, or null
16
+ * @param T - Type
17
+ * @returns T or null
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * type A = Nullable<string>
22
+ * // string | null
23
+ * ```
24
+ */
25
+ type Nullable<T> = T | null;
26
+
27
+ /**
28
+ * Whatever type, null or undefined
29
+ * @param T - Type
30
+ * @returns T, undefined or null
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * type A = Nullish<string>
35
+ * // string | null | undefined
36
+ * ```
37
+ */
38
+ type Nullish<T> = T | null | undefined;
39
+
40
+ /**
41
+ * Array, or not yet
42
+ */
43
+ type Arrayable<T> = T | Array<T>;
44
+
45
+ /**
46
+ * Infers the element type of an array
47
+ * @param T - Array type
48
+ * @returns The inferred element type
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * type A = ElementOf<string[]>
53
+ * // string
54
+ * ```
55
+ */
56
+ type ElementOf<T> = T extends (infer E)[] ? E : never;
57
+
58
+ /**
59
+ * Infers the arguments type of a function
60
+ * @param T - Function type
61
+ * @returns The inferred arguments type
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * type A = InferArguments<(a: string, b: number) => void>
66
+ * // [string, number]
67
+ * ```
68
+ */
69
+ type InferArguments<T> = T extends ((...args: infer A) => any) ? A : never;
70
+
71
+ //#endregion
72
+ export { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish };
package/dist/types.d.cts CHANGED
@@ -1,66 +1,2 @@
1
- /**
2
- * Whatever type, or Promise of that type
3
- * @param T - Type
4
- * @returns T or Promise<T>
5
- *
6
- * @example
7
- * ```ts
8
- * type A = Awaitable<string>
9
- * // string | Promise<string>
10
- * ```
11
- */
12
- type Awaitable<T> = T | PromiseLike<T>;
13
- /**
14
- * Whatever type, or null
15
- * @param T - Type
16
- * @returns T or null
17
- *
18
- * @example
19
- * ```ts
20
- * type A = Nullable<string>
21
- * // string | null
22
- * ```
23
- */
24
- type Nullable<T> = T | null;
25
- /**
26
- * Whatever type, null or undefined
27
- * @param T - Type
28
- * @returns T, undefined or null
29
- *
30
- * @example
31
- * ```ts
32
- * type A = Nullish<string>
33
- * // string | null | undefined
34
- * ```
35
- */
36
- type Nullish<T> = T | null | undefined;
37
- /**
38
- * Array, or not yet
39
- */
40
- type Arrayable<T> = T | Array<T>;
41
- /**
42
- * Infers the element type of an array
43
- * @param T - Array type
44
- * @returns The inferred element type
45
- *
46
- * @example
47
- * ```ts
48
- * type A = ElementOf<string[]>
49
- * // string
50
- * ```
51
- */
52
- type ElementOf<T> = T extends (infer E)[] ? E : never;
53
- /**
54
- * Infers the arguments type of a function
55
- * @param T - Function type
56
- * @returns The inferred arguments type
57
- *
58
- * @example
59
- * ```ts
60
- * type A = InferArguments<(a: string, b: number) => void>
61
- * // [string, number]
62
- * ```
63
- */
64
- type InferArguments<T> = T extends ((...args: infer A) => any) ? A : never;
65
-
66
- export type { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish };
1
+ import { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish } from "./types.d-fcYBBT6c.cjs";
2
+ export { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish };
package/dist/types.d.ts CHANGED
@@ -1,66 +1,2 @@
1
- /**
2
- * Whatever type, or Promise of that type
3
- * @param T - Type
4
- * @returns T or Promise<T>
5
- *
6
- * @example
7
- * ```ts
8
- * type A = Awaitable<string>
9
- * // string | Promise<string>
10
- * ```
11
- */
12
- type Awaitable<T> = T | PromiseLike<T>;
13
- /**
14
- * Whatever type, or null
15
- * @param T - Type
16
- * @returns T or null
17
- *
18
- * @example
19
- * ```ts
20
- * type A = Nullable<string>
21
- * // string | null
22
- * ```
23
- */
24
- type Nullable<T> = T | null;
25
- /**
26
- * Whatever type, null or undefined
27
- * @param T - Type
28
- * @returns T, undefined or null
29
- *
30
- * @example
31
- * ```ts
32
- * type A = Nullish<string>
33
- * // string | null | undefined
34
- * ```
35
- */
36
- type Nullish<T> = T | null | undefined;
37
- /**
38
- * Array, or not yet
39
- */
40
- type Arrayable<T> = T | Array<T>;
41
- /**
42
- * Infers the element type of an array
43
- * @param T - Array type
44
- * @returns The inferred element type
45
- *
46
- * @example
47
- * ```ts
48
- * type A = ElementOf<string[]>
49
- * // string
50
- * ```
51
- */
52
- type ElementOf<T> = T extends (infer E)[] ? E : never;
53
- /**
54
- * Infers the arguments type of a function
55
- * @param T - Function type
56
- * @returns The inferred arguments type
57
- *
58
- * @example
59
- * ```ts
60
- * type A = InferArguments<(a: string, b: number) => void>
61
- * // [string, number]
62
- * ```
63
- */
64
- type InferArguments<T> = T extends ((...args: infer A) => any) ? A : never;
65
-
66
- export type { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish };
1
+ import { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish } from "./types.d-BcKIY6l3.js";
2
+ export { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish };
package/dist/types.js ADDED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxass/utils",
3
- "version": "1.2.1",
3
+ "version": "1.4.0",
4
4
  "description": "A collection of utilities for JavaScript/TypeScript",
5
5
  "type": "module",
6
6
  "author": {
@@ -8,12 +8,11 @@
8
8
  "email": "lucasnrgaard@gmail.com",
9
9
  "url": "https://luxass.dev"
10
10
  },
11
- "packageManager": "pnpm@9.12.3",
12
11
  "license": "MIT",
13
12
  "homepage": "https://github.com/luxass/utils",
14
13
  "repository": {
15
14
  "type": "git",
16
- "url": "https://github.com/luxass/utils"
15
+ "url": "git+https://github.com/luxass/utils.git"
17
16
  },
18
17
  "bugs": {
19
18
  "url": "https://github.com/luxass/utils/issues"
@@ -26,7 +25,7 @@
26
25
  ".": {
27
26
  "import": {
28
27
  "types": "./dist/index.d.ts",
29
- "default": "./dist/index.mjs"
28
+ "default": "./dist/index.js"
30
29
  },
31
30
  "require": {
32
31
  "types": "./dist/index.d.cts",
@@ -36,7 +35,7 @@
36
35
  "./guards": {
37
36
  "import": {
38
37
  "types": "./dist/guards.d.ts",
39
- "default": "./dist/guards.mjs"
38
+ "default": "./dist/guards.js"
40
39
  },
41
40
  "require": {
42
41
  "types": "./dist/guards.d.cts",
@@ -46,7 +45,7 @@
46
45
  "./number": {
47
46
  "import": {
48
47
  "types": "./dist/number.d.ts",
49
- "default": "./dist/number.mjs"
48
+ "default": "./dist/number.js"
50
49
  },
51
50
  "require": {
52
51
  "types": "./dist/number.d.cts",
@@ -56,7 +55,7 @@
56
55
  "./types": {
57
56
  "import": {
58
57
  "types": "./dist/types.d.ts",
59
- "default": "./dist/types.mjs"
58
+ "default": "./dist/types.js"
60
59
  },
61
60
  "require": {
62
61
  "types": "./dist/types.d.cts",
@@ -66,29 +65,30 @@
66
65
  "./package.json": "./package.json"
67
66
  },
68
67
  "main": "./dist/index.cjs",
69
- "module": "./dist/index.mjs",
68
+ "module": "./dist/index.js",
70
69
  "types": "./dist/index.d.ts",
71
70
  "files": [
72
71
  "dist"
73
72
  ],
74
73
  "engines": {
75
- "node": ">=18"
74
+ "node": ">=20"
75
+ },
76
+ "devDependencies": {
77
+ "@luxass/eslint-config": "^4.18.1",
78
+ "@types/node": "^22.15.2",
79
+ "eslint": "^9.25.1",
80
+ "eslint-plugin-format": "^1.0.1",
81
+ "publint": "^0.3.12",
82
+ "tsdown": "^0.9.9",
83
+ "typescript": "^5.8.3",
84
+ "vitest": "^3.1.2"
76
85
  },
77
86
  "scripts": {
78
- "build": "tsup",
79
- "dev": "tsup --watch",
87
+ "build": "tsdown",
88
+ "dev": "tsdown --watch",
80
89
  "test": "vitest --run",
81
90
  "test:watch": "vitest",
82
91
  "lint": "eslint .",
83
92
  "typecheck": "tsc --noEmit"
84
- },
85
- "devDependencies": {
86
- "@luxass/eslint-config": "^4.12.1",
87
- "@types/node": "^20.14.9",
88
- "eslint": "^9.14.0",
89
- "eslint-plugin-format": "^0.1.2",
90
- "tsup": "^8.3.5",
91
- "typescript": "^5.6.3",
92
- "vitest": "^2.1.4"
93
93
  }
94
- }
94
+ }
@@ -1,6 +0,0 @@
1
- // src/number.ts
2
- function clamp(value, min, max) {
3
- return Math.min(Math.max(value, min), max);
4
- }
5
-
6
- export { clamp };
@@ -1,28 +0,0 @@
1
- // src/string.ts
2
- function capitalize(str) {
3
- if (typeof str !== "string") throw new TypeError("Expected a string");
4
- if (str.trim().length === 0) return "";
5
- return str[0].toUpperCase() + str.slice(1).toLowerCase();
6
- }
7
- function toCamelCase(str) {
8
- if (typeof str !== "string") throw new TypeError("Expected a string");
9
- if (str.trim().length === 0) return "";
10
- return str.toLowerCase().replace(/[-_](.)/g, (_, c) => c.toUpperCase());
11
- }
12
- function toKebabCase(str) {
13
- if (typeof str !== "string") throw new TypeError("Expected a string");
14
- if (str.trim().length === 0) return "";
15
- return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
16
- }
17
- function toPascalCase(str) {
18
- if (typeof str !== "string") throw new TypeError("Expected a string");
19
- if (str.trim().length === 0) return "";
20
- return str.toLowerCase().replace(/[-_](.)/g, (_, c) => c.toUpperCase()).replace(/^[a-z]/, (c) => c.toUpperCase());
21
- }
22
- function toSnakeCase(str) {
23
- if (typeof str !== "string") throw new TypeError("Expected a string");
24
- if (str.trim().length === 0) return "";
25
- return str.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
26
- }
27
-
28
- export { capitalize, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
@@ -1,15 +0,0 @@
1
- // src/guards.ts
2
- function isNotNullish(v) {
3
- return v != null;
4
- }
5
- function isNotNull(v) {
6
- return v !== null;
7
- }
8
- function isNotUndefined(v) {
9
- return v !== void 0;
10
- }
11
- function isTruthy(v) {
12
- return Boolean(v);
13
- }
14
-
15
- export { isNotNull, isNotNullish, isNotUndefined, isTruthy };
package/dist/guards.mjs DELETED
@@ -1 +0,0 @@
1
- export { isNotNull, isNotNullish, isNotUndefined, isTruthy } from './chunk-OKC7RR3A.mjs';
package/dist/index.mjs DELETED
@@ -1,3 +0,0 @@
1
- export { isNotNull, isNotNullish, isNotUndefined, isTruthy } from './chunk-OKC7RR3A.mjs';
2
- export { clamp } from './chunk-7RYURVAF.mjs';
3
- export { capitalize, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from './chunk-MNDVPE25.mjs';
package/dist/number.mjs DELETED
@@ -1 +0,0 @@
1
- export { clamp } from './chunk-7RYURVAF.mjs';
package/dist/string.mjs DELETED
@@ -1 +0,0 @@
1
- export { capitalize, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from './chunk-MNDVPE25.mjs';
package/dist/types.mjs DELETED
@@ -1 +0,0 @@
1
-