@luxass/utils 2.6.2 → 2.7.2

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/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { clamp } from "./number-Culbli-Y.js";
3
3
  import { getChangedKeys, getOwnProperty, hasOwnProperty, omit } from "./object-BtzfqVfB.js";
4
4
  import { appendTrailingSlash, prependLeadingSlash, trimLeadingSlash, trimTrailingSlash } from "./path-CFkUYi0a.js";
5
5
  import { capitalize, dedent, dedentRaw, formatStr, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string-BgrFQWVx.js";
6
- import { ElementOf, InferArguments, MaybeArray, MaybePromise, Nullable, Nullish, Prettify, RemoveIndexSignature, SafeOmit } from "./types-DwW0ucVr.js";
6
+ import { ElementOf, InferArguments, Prettify, RemoveIndexSignature } from "./types-CdpK0-xy.js";
7
7
  import pRetry from "p-retry";
8
8
 
9
9
  //#region src/common.d.ts
@@ -22,4 +22,4 @@ declare class InvariantError extends Error {
22
22
  */
23
23
  declare function invariant(predicate: unknown, message: string, ...positionals: unknown[]): asserts predicate;
24
24
  //#endregion
25
- export { type ElementOf, type InferArguments, InvariantError, type MaybeArray, type MaybePromise, type Nullable, type Nullish, type Prettify, type RemoveIndexSignature, type SafeOmit, appendTrailingSlash, capitalize, clamp, dedent, dedentRaw, formatStr, getChangedKeys, getOwnProperty, hasOwnProperty, invariant, isNotNull, isNotNullish, isNotUndefined, isTruthy, omit, prependLeadingSlash, pRetry as promiseRetry, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, trimLeadingSlash, trimTrailingSlash };
25
+ export { type ElementOf, type InferArguments, InvariantError, type Prettify, type RemoveIndexSignature, appendTrailingSlash, capitalize, clamp, dedent, dedentRaw, formatStr, getChangedKeys, getOwnProperty, hasOwnProperty, invariant, isNotNull, isNotNullish, isNotUndefined, isTruthy, omit, prependLeadingSlash, pRetry as promiseRetry, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, trimLeadingSlash, trimTrailingSlash };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { isNotNull, isNotNullish, isNotUndefined, isTruthy } from "./guards-O1HGJraI.js";
2
2
  import { capitalize, dedent, dedentRaw, formatStr, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string-BlwTLoKD.js";
3
3
  import { clamp } from "./number-BS9T5WGO.js";
4
- import { getChangedKeys, getOwnProperty, hasOwnProperty, omit } from "./object-CyGLe77G.js";
5
- import { appendTrailingSlash, prependLeadingSlash, trimLeadingSlash, trimTrailingSlash } from "./path-BcSxT2uo.js";
4
+ import { getChangedKeys, getOwnProperty, hasOwnProperty, omit } from "./object-DWHqMFiC.js";
5
+ import { appendTrailingSlash, prependLeadingSlash, trimLeadingSlash, trimTrailingSlash } from "./path-UEx_WP0U.js";
6
6
  import pRetry from "p-retry";
7
7
 
8
8
  //#region src/common.ts
@@ -19,7 +19,7 @@ function hasOwnProperty(obj, key) {
19
19
  return Object.prototype.hasOwnProperty.call(obj, key);
20
20
  }
21
21
  function getOwnProperty(obj, key) {
22
- if (!hasOwnProperty(obj, key)) return void 0;
22
+ if (!hasOwnProperty(obj, key)) return;
23
23
  return obj[key];
24
24
  }
25
25
  /**
package/dist/object.js CHANGED
@@ -1,3 +1,3 @@
1
- import { getChangedKeys, getOwnProperty, hasOwnProperty, omit } from "./object-CyGLe77G.js";
1
+ import { getChangedKeys, getOwnProperty, hasOwnProperty, omit } from "./object-DWHqMFiC.js";
2
2
 
3
3
  export { getChangedKeys, getOwnProperty, hasOwnProperty, omit };
@@ -119,8 +119,7 @@ function joinURL(base, ...segments) {
119
119
  if (path.length > 0) {
120
120
  const pathTrailing = path[path.length - 1] === "/";
121
121
  const segLeading = seg[0] === "/";
122
- const both = pathTrailing && segLeading;
123
- if (both) path += seg.slice(1);
122
+ if (pathTrailing && segLeading) path += seg.slice(1);
124
123
  else path += pathTrailing || segLeading ? seg : `/${seg}`;
125
124
  } else path += seg;
126
125
  }
package/dist/path.js CHANGED
@@ -1,3 +1,3 @@
1
- import { appendTrailingSlash, joinURL, prependLeadingSlash, trimLeadingSlash, trimTrailingSlash } from "./path-BcSxT2uo.js";
1
+ import { appendTrailingSlash, joinURL, prependLeadingSlash, trimLeadingSlash, trimTrailingSlash } from "./path-UEx_WP0U.js";
2
2
 
3
3
  export { appendTrailingSlash, joinURL, prependLeadingSlash, trimLeadingSlash, trimTrailingSlash };
@@ -0,0 +1,62 @@
1
+ //#region src/types.d.ts
2
+ /**
3
+ * Infers the element type of an array
4
+ * @template T
5
+ * @returns {T extends (infer E)[] ? E : never} The inferred element type
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { ElementOf } from "@luxass/utils/types";
10
+ *
11
+ * type A = ElementOf<string[]>
12
+ * // string
13
+ * ```
14
+ */
15
+ type ElementOf<T> = T extends (infer E)[] ? E : never;
16
+ /**
17
+ * Infers the arguments type of a function
18
+ * @template T
19
+ * @returns {T extends ((...args: infer A) => any) ? A : never} The inferred arguments type
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { InferArguments } from "@luxass/utils/types";
24
+ *
25
+ * type A = InferArguments<(a: string, b: number) => void>
26
+ * // [string, number]
27
+ * ```
28
+ */
29
+ type InferArguments<T> = T extends ((...args: infer A) => any) ? A : never;
30
+ /**
31
+ * Makes complex nested types more readable in editor tooltips by flattening
32
+ * the type to a simple object type with all properties
33
+ * @template T
34
+ * @returns {{ [K in keyof T]: T[K] } & {}} A simplified representation of the same type
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * import { Prettify } from "@luxass/utils/types";
39
+ *
40
+ * type Messy = { a: string } & { b: number } & { c: boolean }
41
+ * type Clean = Prettify<Messy>
42
+ * // { a: string; b: number; c: boolean }
43
+ * ```
44
+ */
45
+ type Prettify<T> = { [K in keyof T]: T[K] } & {};
46
+ /**
47
+ * Removes index signatures from a type while preserving specific properties
48
+ * @template T
49
+ * @returns {{ [K in keyof T as {} extends Record<K, 1> ? never : K]: T[K] }} A new type without index signatures
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * import { RemoveIndexSignature } from "@luxass/utils/types";
54
+ *
55
+ * type WithIndex = { id: number; [key: string]: any }
56
+ * type Clean = RemoveIndexSignature<WithIndex>
57
+ * // { id: number }
58
+ * ```
59
+ */
60
+ type RemoveIndexSignature<T> = { [K in keyof T as {} extends Record<K, 1> ? never : K]: T[K] };
61
+ //#endregion
62
+ export { ElementOf, InferArguments, Prettify, RemoveIndexSignature };
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { ElementOf, InferArguments, MaybeArray, MaybePromise, Nullable, Nullish, Prettify, RemoveIndexSignature, SafeOmit } from "./types-DwW0ucVr.js";
2
- export { ElementOf, InferArguments, MaybeArray, MaybePromise, Nullable, Nullish, Prettify, RemoveIndexSignature, SafeOmit };
1
+ import { ElementOf, InferArguments, Prettify, RemoveIndexSignature } from "./types-CdpK0-xy.js";
2
+ export { ElementOf, InferArguments, Prettify, RemoveIndexSignature };
package/dist/types.js CHANGED
@@ -0,0 +1 @@
1
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxass/utils",
3
- "version": "2.6.2",
3
+ "version": "2.7.2",
4
4
  "description": "A collection of utilities for JavaScript/TypeScript",
5
5
  "type": "module",
6
6
  "author": {
@@ -8,6 +8,7 @@
8
8
  "email": "lucasnrgaard@gmail.com",
9
9
  "url": "https://luxass.dev"
10
10
  },
11
+ "packageManager": "pnpm@10.16.0",
11
12
  "license": "MIT",
12
13
  "homepage": "https://github.com/luxass/utils",
13
14
  "repository": {
@@ -40,27 +41,27 @@
40
41
  "engines": {
41
42
  "node": ">=20"
42
43
  },
44
+ "scripts": {
45
+ "build": "tsdown",
46
+ "dev": "tsdown --watch",
47
+ "test": "vitest --run",
48
+ "test:watch": "vitest",
49
+ "lint": "eslint .",
50
+ "typecheck": "tsc --noEmit"
51
+ },
43
52
  "dependencies": {
44
- "p-retry": "^6.2.1"
53
+ "p-retry": "^7.0.0"
45
54
  },
46
55
  "devDependencies": {
47
- "@luxass/eslint-config": "^5.1.1",
48
- "@types/node": "^22.15.2",
56
+ "@luxass/eslint-config": "^5.3.1",
57
+ "@types/node": "^22.18.3",
49
58
  "@vitest/coverage-v8": "3.2.4",
50
- "eslint": "^9.32.0",
59
+ "eslint": "^9.35.0",
51
60
  "eslint-plugin-format": "^1.0.1",
52
61
  "publint": "^0.3.12",
53
- "tsdown": "^0.13.0",
54
- "typescript": "^5.8.3",
62
+ "tsdown": "^0.15.1",
63
+ "typescript": "^5.9.2",
55
64
  "vitest": "^3.2.4",
56
65
  "vitest-package-exports": "^0.1.1"
57
- },
58
- "scripts": {
59
- "build": "tsdown",
60
- "dev": "tsdown --watch",
61
- "test": "vitest --run",
62
- "test:watch": "vitest",
63
- "lint": "eslint .",
64
- "typecheck": "tsc --noEmit"
65
66
  }
66
- }
67
+ }
@@ -1,143 +0,0 @@
1
- //#region src/types.d.ts
2
- /**
3
- * Whatever type, or null
4
- * @template T
5
- * @returns {T | null} T or null
6
- *
7
- * @example
8
- * ```ts
9
- * import { Nullable } from "@luxass/utils/types";
10
- *
11
- * type A = Nullable<string>
12
- * // string | null
13
- * ```
14
- */
15
- type Nullable<T> = T | null;
16
- /**
17
- * Whatever type, null or undefined
18
- * @template T
19
- * @returns {T | null | undefined} T, undefined or null
20
- *
21
- * @example
22
- * ```ts
23
- * import { Nullish } from "@luxass/utils/types";
24
- *
25
- * type A = Nullish<string>
26
- * // string | null | undefined
27
- * ```
28
- */
29
- type Nullish<T> = T | null | undefined;
30
- /**
31
- * A type that can be an array or a single value.
32
- * @template T
33
- * @returns {T | T[]} T or T[]
34
- *
35
- * @example
36
- * ```ts
37
- * import { MaybeArray } from "@luxass/utils/types";
38
- *
39
- * type A = MaybeArray<string>
40
- * // string | string[]
41
- * ```
42
- */
43
- type MaybeArray<T> = T | T[];
44
- /**
45
- * A type that can be a value or a promise.
46
- * @template T
47
- * @returns {T | Promise<T>} T or Promise<T>
48
- *
49
- * @example
50
- * ```ts
51
- * import { MaybePromise } from "@luxass/utils/types";
52
- *
53
- * type A = MaybePromise<string>
54
- * // string | Promise<string>
55
- * ```
56
- */
57
- type MaybePromise<T> = T | Promise<T>;
58
- /**
59
- * Infers the element type of an array
60
- * @template T
61
- * @returns {T extends (infer E)[] ? E : never} The inferred element type
62
- *
63
- * @example
64
- * ```ts
65
- * import { ElementOf } from "@luxass/utils/types";
66
- *
67
- * type A = ElementOf<string[]>
68
- * // string
69
- * ```
70
- */
71
- type ElementOf<T> = T extends (infer E)[] ? E : never;
72
- /**
73
- * Infers the arguments type of a function
74
- * @template T
75
- * @returns {T extends ((...args: infer A) => any) ? A : never} The inferred arguments type
76
- *
77
- * @example
78
- * ```ts
79
- * import { InferArguments } from "@luxass/utils/types";
80
- *
81
- * type A = InferArguments<(a: string, b: number) => void>
82
- * // [string, number]
83
- * ```
84
- */
85
- type InferArguments<T> = T extends ((...args: infer A) => any) ? A : never;
86
- /**
87
- * Makes complex nested types more readable in editor tooltips by flattening
88
- * the type to a simple object type with all properties
89
- * @template T
90
- * @returns {{ [K in keyof T]: T[K] } & {}} A simplified representation of the same type
91
- *
92
- * @example
93
- * ```ts
94
- * import { Prettify } from "@luxass/utils/types";
95
- *
96
- * type Messy = { a: string } & { b: number } & { c: boolean }
97
- * type Clean = Prettify<Messy>
98
- * // { a: string; b: number; c: boolean }
99
- * ```
100
- */
101
- type Prettify<T> = { [K in keyof T]: T[K] } & {};
102
- /**
103
- * Removes index signatures from a type while preserving specific properties
104
- * @template T
105
- * @returns {{ [K in keyof T as {} extends Record<K, 1> ? never : K]: T[K] }} A new type without index signatures
106
- *
107
- * @example
108
- * ```ts
109
- * import { RemoveIndexSignature } from "@luxass/utils/types";
110
- *
111
- * type WithIndex = { id: number; [key: string]: any }
112
- * type Clean = RemoveIndexSignature<WithIndex>
113
- * // { id: number }
114
- * ```
115
- */
116
- type RemoveIndexSignature<T> = { [K in keyof T as {} extends Record<K, 1> ? never : K]: T[K] };
117
- /**
118
- * A safer version of the built-in Omit utility type that ensures the keys
119
- * being omitted actually exist on the source type
120
- * @template T
121
- * @template {keyof T} K
122
- * @returns {Omit<T, K>} A new type with the specified keys omitted
123
- *
124
- * @example
125
- * ```ts
126
- * import { SafeOmit } from "@luxass/utils/types";
127
- *
128
- * interface User {
129
- * id: number;
130
- * name: string;
131
- * email: string;
132
- * }
133
- *
134
- * type UserWithoutEmail = SafeOmit<User, 'email'>
135
- * // { id: number; name: string }
136
- *
137
- * // TypeScript error - 'invalid' is not a key of User
138
- * type Invalid = SafeOmit<User, 'invalid'>
139
- * ```
140
- */
141
- type SafeOmit<T, K extends keyof T> = Omit<T, K>;
142
- //#endregion
143
- export { ElementOf, InferArguments, MaybeArray, MaybePromise, Nullable, Nullish, Prettify, RemoveIndexSignature, SafeOmit };