es-toolkit 1.52.0-dev.2105 → 1.52.0-dev.2106

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,11 +1,13 @@
1
+ import { Primitive } from "./Primitive.mjs";
2
+
1
3
  //#region src/types/DeepPartial.d.ts
2
4
  /**
3
5
  * Makes all properties of `T` optional recursively, unlike the built-in
4
6
  * `Partial` which only affects the first level.
5
7
  *
6
8
  * Recurses into plain objects, arrays/tuples (elements do not become sparse),
7
- * and `Map`/`Set` contents. Functions, `Date`, and `RegExp` pass through
8
- * unchanged.
9
+ * and `Map`/`Set` contents. Primitive types (including branded primitives),
10
+ * functions, `Date`, and `RegExp` pass through unchanged.
9
11
  *
10
12
  * @template T - The type to make deeply optional.
11
13
  *
@@ -16,6 +18,6 @@
16
18
  *
17
19
  * const patch: ConfigPatch = { server: { port: 8080 } }; // ok, host omitted
18
20
  */
19
- type DeepPartial<T> = T extends ((...args: any[]) => unknown) | Date | RegExp ? T : T extends Map<infer K, infer V> ? Map<DeepPartial<K>, DeepPartial<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepPartial<K>, DeepPartial<V>> : T extends Set<infer U> ? Set<DeepPartial<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepPartial<U>> : T extends readonly unknown[] ? { [K in keyof T]: DeepPartial<T[K]> } : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
21
+ type DeepPartial<T> = T extends Primitive | ((...args: never[]) => unknown) | Date | RegExp ? T : T extends Map<infer K, infer V> ? Map<DeepPartial<K>, DeepPartial<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepPartial<K>, DeepPartial<V>> : T extends Set<infer U> ? Set<DeepPartial<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepPartial<U>> : T extends readonly unknown[] ? { [K in keyof T]: DeepPartial<T[K]> } : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
20
22
  //#endregion
21
23
  export { DeepPartial };
@@ -1,11 +1,13 @@
1
+ import { Primitive } from "./Primitive.js";
2
+
1
3
  //#region src/types/DeepPartial.d.ts
2
4
  /**
3
5
  * Makes all properties of `T` optional recursively, unlike the built-in
4
6
  * `Partial` which only affects the first level.
5
7
  *
6
8
  * Recurses into plain objects, arrays/tuples (elements do not become sparse),
7
- * and `Map`/`Set` contents. Functions, `Date`, and `RegExp` pass through
8
- * unchanged.
9
+ * and `Map`/`Set` contents. Primitive types (including branded primitives),
10
+ * functions, `Date`, and `RegExp` pass through unchanged.
9
11
  *
10
12
  * @template T - The type to make deeply optional.
11
13
  *
@@ -16,6 +18,6 @@
16
18
  *
17
19
  * const patch: ConfigPatch = { server: { port: 8080 } }; // ok, host omitted
18
20
  */
19
- type DeepPartial<T> = T extends ((...args: any[]) => unknown) | Date | RegExp ? T : T extends Map<infer K, infer V> ? Map<DeepPartial<K>, DeepPartial<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepPartial<K>, DeepPartial<V>> : T extends Set<infer U> ? Set<DeepPartial<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepPartial<U>> : T extends readonly unknown[] ? { [K in keyof T]: DeepPartial<T[K]> } : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
21
+ type DeepPartial<T> = T extends Primitive | ((...args: never[]) => unknown) | Date | RegExp ? T : T extends Map<infer K, infer V> ? Map<DeepPartial<K>, DeepPartial<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepPartial<K>, DeepPartial<V>> : T extends Set<infer U> ? Set<DeepPartial<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepPartial<U>> : T extends readonly unknown[] ? { [K in keyof T]: DeepPartial<T[K]> } : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
20
22
  //#endregion
21
23
  export { DeepPartial };
@@ -1,11 +1,13 @@
1
+ import { Primitive } from "./Primitive.mjs";
2
+
1
3
  //#region src/types/DeepReadonly.d.ts
2
4
  /**
3
5
  * Makes all properties of `T` readonly recursively, unlike the built-in
4
6
  * `Readonly` which only affects the first level.
5
7
  *
6
8
  * Arrays and tuples become readonly, and `Map`/`Set` become
7
- * `ReadonlyMap`/`ReadonlySet`. Functions, `Date`, and `RegExp` pass through
8
- * unchanged.
9
+ * `ReadonlyMap`/`ReadonlySet`. Primitive types (including branded primitives),
10
+ * functions, `Date`, and `RegExp` pass through unchanged.
9
11
  *
10
12
  * @template T - The type to make deeply readonly.
11
13
  *
@@ -17,6 +19,6 @@
17
19
  * declare const state: FrozenState;
18
20
  * state.user.name = 'x'; // error: name is readonly
19
21
  */
20
- type DeepReadonly<T> = T extends ((...args: any[]) => unknown) | Date | RegExp ? T : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : T;
22
+ type DeepReadonly<T> = T extends Primitive | ((...args: never[]) => unknown) | Date | RegExp ? T : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : T;
21
23
  //#endregion
22
24
  export { DeepReadonly };
@@ -1,11 +1,13 @@
1
+ import { Primitive } from "./Primitive.js";
2
+
1
3
  //#region src/types/DeepReadonly.d.ts
2
4
  /**
3
5
  * Makes all properties of `T` readonly recursively, unlike the built-in
4
6
  * `Readonly` which only affects the first level.
5
7
  *
6
8
  * Arrays and tuples become readonly, and `Map`/`Set` become
7
- * `ReadonlyMap`/`ReadonlySet`. Functions, `Date`, and `RegExp` pass through
8
- * unchanged.
9
+ * `ReadonlyMap`/`ReadonlySet`. Primitive types (including branded primitives),
10
+ * functions, `Date`, and `RegExp` pass through unchanged.
9
11
  *
10
12
  * @template T - The type to make deeply readonly.
11
13
  *
@@ -17,6 +19,6 @@
17
19
  * declare const state: FrozenState;
18
20
  * state.user.name = 'x'; // error: name is readonly
19
21
  */
20
- type DeepReadonly<T> = T extends ((...args: any[]) => unknown) | Date | RegExp ? T : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : T;
22
+ type DeepReadonly<T> = T extends Primitive | ((...args: never[]) => unknown) | Date | RegExp ? T : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : T;
21
23
  //#endregion
22
24
  export { DeepReadonly };
@@ -6,13 +6,13 @@ import { ToConstantCaseKeys } from "./ToConstantCaseKeys.mjs";
6
6
  import { ToKebabCaseKeys } from "./ToKebabCaseKeys.mjs";
7
7
  import { ToPascalCaseKeys } from "./ToPascalCaseKeys.mjs";
8
8
  import { ToSnakeCaseKeys } from "./ToSnakeCaseKeys.mjs";
9
+ import { Primitive } from "./Primitive.mjs";
9
10
  import { DeepPartial } from "./DeepPartial.mjs";
10
11
  import { DeepReadonly } from "./DeepReadonly.mjs";
11
12
  import { EmptyObject } from "./EmptyObject.mjs";
12
13
  import { IsEqual } from "./IsEqual.mjs";
13
14
  import { JSONValue } from "./JSONValue.mjs";
14
15
  import { NonEmptyArray } from "./NonEmptyArray.mjs";
15
- import { Primitive } from "./Primitive.mjs";
16
16
  import { SetOptional } from "./SetOptional.mjs";
17
17
  import { SetRequired } from "./SetRequired.mjs";
18
18
  import { UnknownRecord } from "./UnknownRecord.mjs";
@@ -6,13 +6,13 @@ import { ToConstantCaseKeys } from "./ToConstantCaseKeys.js";
6
6
  import { ToKebabCaseKeys } from "./ToKebabCaseKeys.js";
7
7
  import { ToPascalCaseKeys } from "./ToPascalCaseKeys.js";
8
8
  import { ToSnakeCaseKeys } from "./ToSnakeCaseKeys.js";
9
+ import { Primitive } from "./Primitive.js";
9
10
  import { DeepPartial } from "./DeepPartial.js";
10
11
  import { DeepReadonly } from "./DeepReadonly.js";
11
12
  import { EmptyObject } from "./EmptyObject.js";
12
13
  import { IsEqual } from "./IsEqual.js";
13
14
  import { JSONValue } from "./JSONValue.js";
14
15
  import { NonEmptyArray } from "./NonEmptyArray.js";
15
- import { Primitive } from "./Primitive.js";
16
16
  import { SetOptional } from "./SetOptional.js";
17
17
  import { SetRequired } from "./SetRequired.js";
18
18
  import { UnknownRecord } from "./UnknownRecord.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
- "version": "1.52.0-dev.2105+3aee05dc",
3
+ "version": "1.52.0-dev.2106+2b60bce5",
4
4
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
5
5
  "homepage": "https://es-toolkit.dev",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",