umt 2.20.0 → 3.1.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 (71) hide show
  1. package/module/Date/getDay.d.ts +1 -2
  2. package/module/Object/keyBy.d.ts +3 -4
  3. package/module/Validate/array/arrayOf.d.ts +8 -6
  4. package/module/Validate/array/arrayOf.js +2 -3
  5. package/module/Validate/array/arrayOf.js.map +1 -1
  6. package/module/Validate/array/index.d.ts +0 -1
  7. package/module/Validate/array/index.js +0 -1
  8. package/module/Validate/array/index.js.map +1 -1
  9. package/module/Validate/function/core.d.ts +9 -10
  10. package/module/Validate/function/core.js.map +1 -1
  11. package/module/Validate/instanceof/core.d.ts +1 -2
  12. package/module/Validate/map/core.d.ts +2 -3
  13. package/module/Validate/map/core.js.map +1 -1
  14. package/module/Validate/object/intersection.d.ts +6 -4
  15. package/module/Validate/object/intersection.js.map +1 -1
  16. package/module/Validate/object/nullable.d.ts +1 -2
  17. package/module/Validate/object/optional.d.ts +1 -2
  18. package/module/Validate/object/partial.d.ts +1 -2
  19. package/module/Validate/object/required.d.ts +2 -3
  20. package/module/Validate/object/union.d.ts +2 -3
  21. package/module/Validate/object/union.js.map +1 -1
  22. package/module/Validate/set/core.d.ts +2 -3
  23. package/module/Validate/set/core.js.map +1 -1
  24. package/module/Validate/string/oneOf.d.ts +10 -7
  25. package/module/Validate/string/oneOf.js +5 -3
  26. package/module/Validate/string/oneOf.js.map +1 -1
  27. package/module/Validate/templateLiteral/core.d.ts +5 -6
  28. package/module/Validate/templateLiteral/core.js.map +1 -1
  29. package/module/Validate/type.d.ts +14 -2
  30. package/module/es5/Date/getDay.d.ts +1 -2
  31. package/module/es5/Object/keyBy.d.ts +3 -4
  32. package/module/es5/Validate/array/arrayOf.d.ts +8 -6
  33. package/module/es5/Validate/array/arrayOf.js +10 -5
  34. package/module/es5/Validate/array/index.d.ts +0 -1
  35. package/module/es5/Validate/array/index.js +0 -11
  36. package/module/es5/Validate/function/core.d.ts +9 -10
  37. package/module/es5/Validate/function/core.js +0 -2
  38. package/module/es5/Validate/instanceof/core.d.ts +1 -2
  39. package/module/es5/Validate/map/core.d.ts +2 -3
  40. package/module/es5/Validate/object/intersection.d.ts +6 -4
  41. package/module/es5/Validate/object/intersection.js +6 -0
  42. package/module/es5/Validate/object/nullable.d.ts +1 -2
  43. package/module/es5/Validate/object/optional.d.ts +1 -2
  44. package/module/es5/Validate/object/partial.d.ts +1 -2
  45. package/module/es5/Validate/object/required.d.ts +2 -3
  46. package/module/es5/Validate/object/union.d.ts +2 -3
  47. package/module/es5/Validate/set/core.d.ts +2 -3
  48. package/module/es5/Validate/string/oneOf.d.ts +10 -7
  49. package/module/es5/Validate/string/oneOf.js +8 -6
  50. package/module/es5/Validate/templateLiteral/core.d.ts +5 -6
  51. package/module/es5/Validate/type.d.ts +14 -2
  52. package/module/es5/types/array/chunk.d.ts +1 -2
  53. package/module/es5/types/array/zip.d.ts +4 -2
  54. package/module/es5/types/logic/binary1bitNor.d.ts +1 -2
  55. package/module/es5/types/logic/binaryFullAdder.d.ts +1 -2
  56. package/module/es5/types/math/divide.d.ts +1 -2
  57. package/module/es5/types/math/multiply.d.ts +1 -2
  58. package/module/es5/types/object/pickDeep.d.ts +3 -4
  59. package/module/types/array/chunk.d.ts +1 -2
  60. package/module/types/array/zip.d.ts +4 -2
  61. package/module/types/logic/binary1bitNor.d.ts +1 -2
  62. package/module/types/logic/binaryFullAdder.d.ts +1 -2
  63. package/module/types/math/divide.d.ts +1 -2
  64. package/module/types/math/multiply.d.ts +1 -2
  65. package/module/types/object/pickDeep.d.ts +3 -4
  66. package/package.json +1 -1
  67. package/module/Validate/array/core.d.ts +0 -14
  68. package/module/Validate/array/core.js +0 -43
  69. package/module/Validate/array/core.js.map +0 -1
  70. package/module/es5/Validate/array/core.d.ts +0 -14
  71. package/module/es5/Validate/array/core.js +0 -62
@@ -5,7 +5,7 @@
5
5
  * `instanceof_` because `instanceof` is a reserved keyword in JavaScript.
6
6
  */
7
7
  import type { ValidateCoreReturnType } from "../../Validate/type";
8
- type Constructor<T> = new (...arguments_: any[]) => T;
8
+ export type Constructor<T> = new (...arguments_: any[]) => T;
9
9
  /**
10
10
  * Creates a validator that checks whether a value is an instance of the given
11
11
  * constructor. Subclasses of the constructor satisfy the validator, matching
@@ -16,4 +16,3 @@ type Constructor<T> = new (...arguments_: any[]) => T;
16
16
  * @returns {Function} - Validator function for instances of the constructor
17
17
  */
18
18
  export declare const instanceof_: <T>(classConstructor: Constructor<T>, message?: string) => (value: T) => ValidateCoreReturnType<T>;
19
- export {};
@@ -5,7 +5,7 @@
5
5
  * `arrayOf()` validates each element of an array.
6
6
  */
7
7
  import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
8
- type ExtractValidatedType<V> = V extends (value: never) => {
8
+ export type MapExtractValidatedType<V> = V extends (value: never) => {
9
9
  type: infer T;
10
10
  } ? ValidateType<T> : never;
11
11
  /**
@@ -20,5 +20,4 @@ type ExtractValidatedType<V> = V extends (value: never) => {
20
20
  * @param {string} [message] - Custom error message for type validation
21
21
  * @returns {Function} - Validator function for Map instances
22
22
  */
23
- export declare const map: <KV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, VV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, K = ExtractValidatedType<KV>, V = ExtractValidatedType<VV>>(keyValidator?: KV, valueValidator?: VV, message?: string) => (value: Map<K, V>) => ValidateCoreReturnType<Map<K, V>>;
24
- export {};
23
+ export declare const map: <KV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, VV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, K = MapExtractValidatedType<KV>, V = MapExtractValidatedType<VV>>(keyValidator?: KV, valueValidator?: VV, message?: string) => (value: Map<K, V>) => ValidateCoreReturnType<Map<K, V>>;
@@ -1,12 +1,14 @@
1
- import type { UnionToIntersection } from "../../types/logic";
2
1
  import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
3
- type ExtractValidatedType<V> = V extends (value: never) => {
2
+ export type IntersectionExtractValidatedType<V> = V extends (value: never) => {
4
3
  type: infer T;
5
4
  } ? ValidateType<T> : never;
5
+ export type IntersectValidatedTypes<Vs> = Vs extends readonly [
6
+ infer Head,
7
+ ...infer Tail
8
+ ] ? IntersectionExtractValidatedType<Head> & IntersectValidatedTypes<Tail> : unknown;
6
9
  /**
7
10
  * Creates an intersection validator that passes only if all given validators pass
8
11
  * @param validators - Validator functions to compose as an intersection (logical AND)
9
12
  * @returns {Function} - Validator that checks if the value matches all validators
10
13
  */
11
- export declare const intersection: <Vs extends ((value: never) => ValidateCoreReturnType<unknown>)[]>(...validators: [...Vs]) => (value: UnionToIntersection<ExtractValidatedType<Vs[number]>>) => ValidateCoreReturnType<UnionToIntersection<ExtractValidatedType<Vs[number]>>>;
12
- export {};
14
+ export declare const intersection: <Vs extends ((value: never) => ValidateCoreReturnType<unknown>)[]>(...validators: [...Vs]) => (value: IntersectValidatedTypes<Vs>) => ValidateCoreReturnType<IntersectValidatedTypes<Vs>>;
@@ -10,6 +10,12 @@ exports.intersection = void 0;
10
10
  // literal union via the `type` field (such as `oneOf`) flow through
11
11
  // intersection without being collapsed by `Types<T>`.
12
12
 
13
+ // Walk the validator tuple and `&`-combine each element's extracted type.
14
+ // Reducing element-by-element preserves any union exposed by an individual
15
+ // validator (e.g. `union(A, B)`), unlike `UnionToIntersection` over
16
+ // `Vs[number]` which would distribute over the inner union and collapse
17
+ // `(A | B) & C` into `A & B & C`.
18
+
13
19
  /**
14
20
  * Creates an intersection validator that passes only if all given validators pass
15
21
  * @param validators - Validator functions to compose as an intersection (logical AND)
@@ -1,4 +1,4 @@
1
- interface NullReturn {
1
+ export interface NullReturn {
2
2
  validate: boolean;
3
3
  message: string;
4
4
  type: "null";
@@ -15,4 +15,3 @@ export declare const nullable: <T, R extends {
15
15
  message: string;
16
16
  validate: boolean;
17
17
  }>(validator: (value: T) => R) => ((value: T | null) => R | NullReturn);
18
- export {};
@@ -1,4 +1,4 @@
1
- interface UndefinedReturn {
1
+ export interface UndefinedReturn {
2
2
  validate: boolean;
3
3
  message: string;
4
4
  type: "undefined";
@@ -33,4 +33,3 @@ export declare const optional: <T, R extends {
33
33
  message: string;
34
34
  validate: boolean;
35
35
  }>(validator: (value: T) => R) => OptionalValidator<T, R>;
36
- export {};
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { type ObjectShape, type ObjectValidator } from "./core";
8
8
  import { type OptionalValidator } from "./optional";
9
- type PartialShape<T extends ObjectShape> = {
9
+ export type PartialShape<T extends ObjectShape> = {
10
10
  [K in keyof T]: OptionalValidator<Parameters<T[K]>[0], ReturnType<T[K]> extends {
11
11
  type: unknown;
12
12
  message: string;
@@ -22,4 +22,3 @@ type PartialShape<T extends ObjectShape> = {
22
22
  * @returns {ObjectValidator<PartialShape<T>>} - New validator where every key accepts undefined
23
23
  */
24
24
  export declare const partial: <T extends ObjectShape>(validator: ObjectValidator<T>, message?: string) => ObjectValidator<PartialShape<T>>;
25
- export {};
@@ -6,8 +6,8 @@
6
6
  */
7
7
  import { type ObjectShape, type ObjectValidator } from "./core";
8
8
  import type { OptionalValidator } from "./optional";
9
- type UnwrapOptional<V> = V extends OptionalValidator<infer Inner, infer R> ? (value: Inner) => R : V;
10
- type RequiredShape<T extends ObjectShape> = {
9
+ export type UnwrapOptional<V> = V extends OptionalValidator<infer Inner, infer R> ? (value: Inner) => R : V;
10
+ export type RequiredShape<T extends ObjectShape> = {
11
11
  [K in keyof T]: UnwrapOptional<T[K]> extends ObjectShape[string] ? UnwrapOptional<T[K]> : T[K];
12
12
  };
13
13
  /**
@@ -19,4 +19,3 @@ type RequiredShape<T extends ObjectShape> = {
19
19
  * @returns {ObjectValidator<RequiredShape<T>>} - New validator where every optional layer is removed
20
20
  */
21
21
  export declare const required: <T extends ObjectShape>(validator: ObjectValidator<T>, message?: string) => ObjectValidator<RequiredShape<T>>;
22
- export {};
@@ -1,5 +1,5 @@
1
1
  import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
2
- type ExtractValidatedType<V> = V extends (value: never) => {
2
+ export type UnionExtractValidatedType<V> = V extends (value: never) => {
3
3
  type: infer T;
4
4
  } ? ValidateType<T> : never;
5
5
  /**
@@ -7,5 +7,4 @@ type ExtractValidatedType<V> = V extends (value: never) => {
7
7
  * @param validators - Validator functions to compose as a union (logical OR)
8
8
  * @returns {Function} - Validator that checks if the value matches any of the validators
9
9
  */
10
- export declare const union: <Vs extends ((value: never) => ValidateCoreReturnType<unknown>)[]>(...validators: [...Vs]) => (value: ExtractValidatedType<Vs[number]>) => ValidateCoreReturnType<ExtractValidatedType<Vs[number]>>;
11
- export {};
10
+ export declare const union: <Vs extends ((value: never) => ValidateCoreReturnType<unknown>)[]>(...validators: [...Vs]) => (value: UnionExtractValidatedType<Vs[number]>) => ValidateCoreReturnType<UnionExtractValidatedType<Vs[number]>>;
@@ -8,7 +8,7 @@
8
8
  * already exposes a `set` runtime helper.
9
9
  */
10
10
  import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
11
- type ExtractValidatedType<V> = V extends (value: never) => {
11
+ export type SetExtractValidatedType<V> = V extends (value: never) => {
12
12
  type: infer T;
13
13
  } ? ValidateType<T> : never;
14
14
  /**
@@ -20,5 +20,4 @@ type ExtractValidatedType<V> = V extends (value: never) => {
20
20
  * @param {string} [message] - Custom error message for type validation
21
21
  * @returns {Function} - Validator function for Set instances
22
22
  */
23
- export declare const set_: <IV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, T = ExtractValidatedType<IV>>(itemValidator?: IV, message?: string) => (value: Set<T>) => ValidateCoreReturnType<Set<T>>;
24
- export {};
23
+ export declare const set_: <IV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, T = SetExtractValidatedType<IV>>(itemValidator?: IV, message?: string) => (value: Set<T>) => ValidateCoreReturnType<Set<T>>;
@@ -5,20 +5,23 @@
5
5
  * such as `'standard' | 'squat' | 'decanter' | 'round' | 'tall' | 'flask'`.
6
6
  *
7
7
  * The validator's return type carries the literal union through its `type`
8
- * field directly (instead of going through `Types<T>` which would collapse
9
- * to `"string"`), so consumers like `object()`, `union()`, and `intersection()`
10
- * can preserve the literal union in their inferred types.
8
+ * field as a `LiteralBrand<T>` so that consumers like `object()`, `union()`,
9
+ * and `intersection()` can preserve the literal union in their inferred types.
10
+ * The brand also prevents collisions with reserved type tags such as
11
+ * `"string"`, `"number"`, or `"boolean"` when an allowed value happens to
12
+ * match one of those tag strings.
11
13
  */
14
+ import type { LiteralBrand } from "../../Validate/type";
12
15
  /**
13
16
  * Return type produced by a `oneOf` validator. Structurally compatible with
14
- * `ValidateCoreReturnType<unknown>`, but exposes the literal union directly
15
- * via the `type` field so the inferred type can flow through `object()`,
16
- * `union()`, and `intersection()` without being collapsed to `string`.
17
+ * `ValidateCoreReturnType<unknown>`, but exposes the literal union via a
18
+ * `LiteralBrand` so the inferred type can flow through `object()`, `union()`,
19
+ * and `intersection()` without being collapsed by `ValidateType`.
17
20
  */
18
21
  export interface OneOfReturnType<T extends string> {
19
22
  validate: boolean;
20
23
  message: string;
21
- type: T;
24
+ type: LiteralBrand<T>;
22
25
  }
23
26
  /**
24
27
  * Creates a top-level validator that checks if a string value is one of the
@@ -11,16 +11,18 @@ exports.oneOf = void 0;
11
11
  * such as `'standard' | 'squat' | 'decanter' | 'round' | 'tall' | 'flask'`.
12
12
  *
13
13
  * The validator's return type carries the literal union through its `type`
14
- * field directly (instead of going through `Types<T>` which would collapse
15
- * to `"string"`), so consumers like `object()`, `union()`, and `intersection()`
16
- * can preserve the literal union in their inferred types.
14
+ * field as a `LiteralBrand<T>` so that consumers like `object()`, `union()`,
15
+ * and `intersection()` can preserve the literal union in their inferred types.
16
+ * The brand also prevents collisions with reserved type tags such as
17
+ * `"string"`, `"number"`, or `"boolean"` when an allowed value happens to
18
+ * match one of those tag strings.
17
19
  */
18
20
 
19
21
  /**
20
22
  * Return type produced by a `oneOf` validator. Structurally compatible with
21
- * `ValidateCoreReturnType<unknown>`, but exposes the literal union directly
22
- * via the `type` field so the inferred type can flow through `object()`,
23
- * `union()`, and `intersection()` without being collapsed to `string`.
23
+ * `ValidateCoreReturnType<unknown>`, but exposes the literal union via a
24
+ * `LiteralBrand` so the inferred type can flow through `object()`, `union()`,
25
+ * and `intersection()` without being collapsed by `ValidateType`.
24
26
  */
25
27
 
26
28
  /**
@@ -7,7 +7,7 @@
7
7
  * inferred type is the corresponding TypeScript template literal type.
8
8
  */
9
9
  import type { ValidateType } from "../../Validate/type";
10
- type AnyValidator = (value?: any) => {
10
+ export type TemplateLiteralAnyValidator = (value?: any) => {
11
11
  type: unknown;
12
12
  };
13
13
  /**
@@ -15,12 +15,12 @@ type AnyValidator = (value?: any) => {
15
15
  * string literal that must appear verbatim, or a primitive validator whose
16
16
  * accepted shape is converted to a regex fragment at construction time.
17
17
  */
18
- export type TemplateLiteralPart = string | AnyValidator;
19
- type ExtractValidatorTag<V> = V extends (value: never) => {
18
+ export type TemplateLiteralPart = string | TemplateLiteralAnyValidator;
19
+ export type ExtractValidatorTag<V> = V extends (value: never) => {
20
20
  type: infer T;
21
21
  } ? T : never;
22
- type TagToTemplate<T> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T extends "bigint" ? bigint : ValidateType<T>;
23
- type PartToTemplate<P> = P extends string ? P : TagToTemplate<ExtractValidatorTag<P>>;
22
+ export type TagToTemplate<T> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T extends "bigint" ? bigint : ValidateType<T>;
23
+ export type PartToTemplate<P> = P extends string ? P : TagToTemplate<ExtractValidatorTag<P>>;
24
24
  /**
25
25
  * Builds the template literal type produced by joining `Parts`. Each part is
26
26
  * mapped to either its literal string value or to the runtime type that the
@@ -52,4 +52,3 @@ export interface TemplateLiteralReturnType<T extends string> {
52
52
  * @returns {Function} - Validator function for template literal strings
53
53
  */
54
54
  export declare const templateLiteral: <const Parts extends readonly TemplateLiteralPart[]>(parts: Parts, message?: string) => (value: BuildTemplateLiteral<Parts>) => TemplateLiteralReturnType<BuildTemplateLiteral<Parts>>;
55
- export {};
@@ -30,16 +30,28 @@ export interface ValidateReturnType<T> {
30
30
  * @template T - The type of value to validate
31
31
  */
32
32
  export type ValidateFunctionType<T> = (value: T) => boolean;
33
+ declare const LITERAL_BRAND: unique symbol;
34
+ /**
35
+ * Branded literal type used by validators (such as `oneOf`) that need to keep
36
+ * a string literal verbatim through `ValidateType`. The brand prevents the
37
+ * literal from colliding with reserved type tags like `"string"`, `"number"`,
38
+ * or `"boolean"` when the same string also happens to name a primitive type.
39
+ * @template T - The literal value preserved by the brand
40
+ */
41
+ export type LiteralBrand<T extends string> = T & {
42
+ readonly [LITERAL_BRAND]: T;
43
+ };
33
44
  export type _ValidateType<T> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T;
34
45
  export type _ValidateType2<T> = T extends "undefined" ? undefined : T extends "null" ? null : T;
35
46
  export type _ValidateType3<T> = T extends "bigint" ? bigint : T extends "any" ? any : T extends "unknown" ? unknown : T extends "never" ? never : T;
36
47
  /**
37
48
  * Maps string literal type names back to their TypeScript types
38
49
  * @template T - The string literal type name ("string", "number", "boolean", "bigint", "undefined", "null", "any", "unknown", "never")
39
- * @returns The corresponding TypeScript type or the original type T when no tag matches
50
+ * @returns The corresponding TypeScript type, the unwrapped literal when `T` is a `LiteralBrand`, or the original type `T` when no tag matches
40
51
  */
41
- export type ValidateType<T> = T extends "string" | "number" | "boolean" ? _ValidateType<T> : T extends "undefined" | "null" ? _ValidateType2<T> : T extends "bigint" | "any" | "unknown" | "never" ? _ValidateType3<T> : T;
52
+ export type ValidateType<T> = T extends LiteralBrand<infer L> ? L : T extends "string" | "number" | "boolean" ? _ValidateType<T> : T extends "undefined" | "null" ? _ValidateType2<T> : T extends "bigint" | "any" | "unknown" | "never" ? _ValidateType3<T> : T;
42
53
  export type SchemaToInterface<T extends (value: any) => ValidateCoreReturnType<any>> = ValidateType<ReturnType<T>["type"]>;
43
54
  export type OptionalKeys<T> = {
44
55
  [K in keyof T]: undefined extends T[K] ? K : never;
45
56
  }[keyof T];
57
+ export {};
@@ -1,4 +1,3 @@
1
1
  import type { Length } from "../logic/length";
2
- type Chunk<T, N extends number, C extends unknown[] = [], R extends unknown[] = []> = T extends [infer F, ...infer L] ? Length<C> extends N ? Chunk<L, N, [F], [...R, C]> : Chunk<L, N, [...C, F], R> : Length<C> extends 0 ? Length<R> extends 0 ? T[] : R : [...R, C];
2
+ export type Chunk<T, N extends number, C extends unknown[] = [], R extends unknown[] = []> = T extends [infer F, ...infer L] ? Length<C> extends N ? Chunk<L, N, [F], [...R, C]> : Chunk<L, N, [...C, F], R> : Length<C> extends 0 ? Length<R> extends 0 ? T[] : R : [...R, C];
3
3
  export type ChunkArrayType<T, N extends number> = Chunk<T, N>;
4
- export {};
@@ -1,3 +1,5 @@
1
- type ZIP<T, O extends unknown[] = []> = T extends [infer Head, ...infer Tail] ? Head extends unknown[] ? ZIP<Tail, [...O, Head[number]]> : never : T extends [] ? O[] : T;
1
+ export type ZIP<T, O extends unknown[] = []> = T extends [
2
+ infer Head,
3
+ ...infer Tail
4
+ ] ? Head extends unknown[] ? ZIP<Tail, [...O, Head[number]]> : never : T extends [] ? O[] : T;
2
5
  export type ZipArrayType<T extends unknown[][]> = ZIP<T>;
3
- export {};
@@ -1,3 +1,2 @@
1
1
  export type Binary1bitNor<X extends `${0 | 1}`, Y extends `${0 | 1}`> = Binary1bitNorParser<X, Y>;
2
- type Binary1bitNorParser<X extends string, Y extends string> = X extends "1" ? "0" : Y extends "1" ? "0" : "1";
3
- export {};
2
+ export type Binary1bitNorParser<X extends string, Y extends string> = X extends "1" ? "0" : Y extends "1" ? "0" : "1";
@@ -5,5 +5,4 @@ import type { LengthOfString } from "./lengthOfString";
5
5
  import type { ShiftString } from "./shiftString";
6
6
  import type { StringReverse } from "./stringReverse";
7
7
  export type BinaryFullAdder<X extends string, Y extends string, B extends number = LengthOfString<X>> = LengthOfString<X> extends LengthOfString<Y> ? FirstNChars<ShiftString<StringReverse<BinaryFullAdderParser<StringReverse<FirstNChars<X, B>>, StringReverse<FirstNChars<Y, B>>>>>, B> : never;
8
- type BinaryFullAdderParser<X extends string, Y extends string, A extends string = "", C extends string = "0"> = X extends `${infer F}${infer R}` ? Y extends `${infer F2}${infer R2}` ? BinaryHalfAdderParser<F, F2> extends `${infer F3}${infer R3}` ? BinaryHalfAdderParser<R3, C> extends `${infer F4}${infer R4}` ? BinaryFullAdderParser<R, R2, `${A}${R4}`, Binary1bitOrParser<F3, F4>> : never : never : never : `${A}${C}`;
9
- export {};
8
+ export type BinaryFullAdderParser<X extends string, Y extends string, A extends string = "", C extends string = "0"> = X extends `${infer F}${infer R}` ? Y extends `${infer F2}${infer R2}` ? BinaryHalfAdderParser<F, F2> extends `${infer F3}${infer R3}` ? BinaryHalfAdderParser<R3, C> extends `${infer F4}${infer R4}` ? BinaryFullAdderParser<R, R2, `${A}${R4}`, Binary1bitOrParser<F3, F4>> : never : never : never : `${A}${C}`;
@@ -2,5 +2,4 @@ import type { Add } from "./add";
2
2
  import type { Subtract } from "./subtract";
3
3
  import type { BGreaterThanA } from "../logic/bGreaterThanA";
4
4
  export type Divide<A extends number, B extends number> = A extends 0 ? never : B extends 0 ? never : `${A}` extends `-${infer N extends number}` ? `${B}` extends `-${infer M extends number}` ? DivideHelper<N, M> : `-${DivideHelper<N, B>}` extends `${infer R extends number}` ? R : never : `${B}` extends `-${infer M extends number}` ? `-${DivideHelper<A, M>}` extends `${infer R extends number}` ? R : never : DivideHelper<A, B>;
5
- type DivideHelper<X extends number, Y extends number, A extends number = 0> = BGreaterThanA<X, Y> extends true ? A : DivideHelper<Subtract<X, Y>, Y, Add<A, 1>>;
6
- export {};
5
+ export type DivideHelper<X extends number, Y extends number, A extends number = 0> = BGreaterThanA<X, Y> extends true ? A : DivideHelper<Subtract<X, Y>, Y, Add<A, 1>>;
@@ -1,5 +1,4 @@
1
1
  import type { Add } from "./add";
2
2
  import type { Subtract } from "./subtract";
3
3
  export type Multiply<A extends number, B extends number> = MultiHelper<A, B>;
4
- type MultiHelper<X extends number, Y extends number, A extends number = 0> = `${X}` extends `-${infer N extends number}` ? `${Y}` extends `-${infer M extends number}` ? MultiHelper<N, M, A> : `-${MultiHelper<N, Y, A>}` extends `${infer R extends number}` ? R : never : `${Y}` extends `-${infer M extends number}` ? `-${MultiHelper<X, M, A>}` extends `${infer R extends number}` ? R : never : Y extends 0 ? A : MultiHelper<X, Subtract<Y, 1>, Add<X, A>>;
5
- export {};
4
+ export type MultiHelper<X extends number, Y extends number, A extends number = 0> = `${X}` extends `-${infer N extends number}` ? `${Y}` extends `-${infer M extends number}` ? MultiHelper<N, M, A> : `-${MultiHelper<N, Y, A>}` extends `${infer R extends number}` ? R : never : `${Y}` extends `-${infer M extends number}` ? `-${MultiHelper<X, M, A>}` extends `${infer R extends number}` ? R : never : Y extends 0 ? A : MultiHelper<X, Subtract<Y, 1>, Add<X, A>>;
@@ -1,13 +1,12 @@
1
1
  import type { PickDeepKey } from "./pickDeepKey";
2
2
  import type { UnionToIntersection } from "../logic/unionToIntersection";
3
- type GetValueAtPath<T, P extends string> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? T[Key] extends object ? GetValueAtPath<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never;
4
- type ConstructNestedObject<P extends string, V> = P extends `${infer Key}.${infer Rest}` ? {
3
+ export type GetValueAtPath<T, P extends string> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? T[Key] extends object ? GetValueAtPath<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never;
4
+ export type ConstructNestedObject<P extends string, V> = P extends `${infer Key}.${infer Rest}` ? {
5
5
  [K in Key]: ConstructNestedObject<Rest, V>;
6
6
  } : {
7
7
  [K in P]: V;
8
8
  };
9
- type ProcessKeys<T extends object, K extends readonly PickDeepKey<T>[]> = {
9
+ export type ProcessKeys<T extends object, K extends readonly PickDeepKey<T>[]> = {
10
10
  [I in keyof K]: K[I] extends string ? ConstructNestedObject<K[I], GetValueAtPath<T, K[I]>> : never;
11
11
  }[number];
12
12
  export type PickDeep<T extends object, K extends readonly PickDeepKey<T>[]> = UnionToIntersection<ProcessKeys<T, K>>;
13
- export {};
@@ -1,4 +1,3 @@
1
1
  import type { Length } from "../logic/length";
2
- type Chunk<T, N extends number, C extends unknown[] = [], R extends unknown[] = []> = T extends [infer F, ...infer L] ? Length<C> extends N ? Chunk<L, N, [F], [...R, C]> : Chunk<L, N, [...C, F], R> : Length<C> extends 0 ? Length<R> extends 0 ? T[] : R : [...R, C];
2
+ export type Chunk<T, N extends number, C extends unknown[] = [], R extends unknown[] = []> = T extends [infer F, ...infer L] ? Length<C> extends N ? Chunk<L, N, [F], [...R, C]> : Chunk<L, N, [...C, F], R> : Length<C> extends 0 ? Length<R> extends 0 ? T[] : R : [...R, C];
3
3
  export type ChunkArrayType<T, N extends number> = Chunk<T, N>;
4
- export {};
@@ -1,3 +1,5 @@
1
- type ZIP<T, O extends unknown[] = []> = T extends [infer Head, ...infer Tail] ? Head extends unknown[] ? ZIP<Tail, [...O, Head[number]]> : never : T extends [] ? O[] : T;
1
+ export type ZIP<T, O extends unknown[] = []> = T extends [
2
+ infer Head,
3
+ ...infer Tail
4
+ ] ? Head extends unknown[] ? ZIP<Tail, [...O, Head[number]]> : never : T extends [] ? O[] : T;
2
5
  export type ZipArrayType<T extends unknown[][]> = ZIP<T>;
3
- export {};
@@ -1,3 +1,2 @@
1
1
  export type Binary1bitNor<X extends `${0 | 1}`, Y extends `${0 | 1}`> = Binary1bitNorParser<X, Y>;
2
- type Binary1bitNorParser<X extends string, Y extends string> = X extends "1" ? "0" : Y extends "1" ? "0" : "1";
3
- export {};
2
+ export type Binary1bitNorParser<X extends string, Y extends string> = X extends "1" ? "0" : Y extends "1" ? "0" : "1";
@@ -5,5 +5,4 @@ import type { LengthOfString } from "./lengthOfString";
5
5
  import type { ShiftString } from "./shiftString";
6
6
  import type { StringReverse } from "./stringReverse";
7
7
  export type BinaryFullAdder<X extends string, Y extends string, B extends number = LengthOfString<X>> = LengthOfString<X> extends LengthOfString<Y> ? FirstNChars<ShiftString<StringReverse<BinaryFullAdderParser<StringReverse<FirstNChars<X, B>>, StringReverse<FirstNChars<Y, B>>>>>, B> : never;
8
- type BinaryFullAdderParser<X extends string, Y extends string, A extends string = "", C extends string = "0"> = X extends `${infer F}${infer R}` ? Y extends `${infer F2}${infer R2}` ? BinaryHalfAdderParser<F, F2> extends `${infer F3}${infer R3}` ? BinaryHalfAdderParser<R3, C> extends `${infer F4}${infer R4}` ? BinaryFullAdderParser<R, R2, `${A}${R4}`, Binary1bitOrParser<F3, F4>> : never : never : never : `${A}${C}`;
9
- export {};
8
+ export type BinaryFullAdderParser<X extends string, Y extends string, A extends string = "", C extends string = "0"> = X extends `${infer F}${infer R}` ? Y extends `${infer F2}${infer R2}` ? BinaryHalfAdderParser<F, F2> extends `${infer F3}${infer R3}` ? BinaryHalfAdderParser<R3, C> extends `${infer F4}${infer R4}` ? BinaryFullAdderParser<R, R2, `${A}${R4}`, Binary1bitOrParser<F3, F4>> : never : never : never : `${A}${C}`;
@@ -2,5 +2,4 @@ import type { Add } from "./add";
2
2
  import type { Subtract } from "./subtract";
3
3
  import type { BGreaterThanA } from "../logic/bGreaterThanA";
4
4
  export type Divide<A extends number, B extends number> = A extends 0 ? never : B extends 0 ? never : `${A}` extends `-${infer N extends number}` ? `${B}` extends `-${infer M extends number}` ? DivideHelper<N, M> : `-${DivideHelper<N, B>}` extends `${infer R extends number}` ? R : never : `${B}` extends `-${infer M extends number}` ? `-${DivideHelper<A, M>}` extends `${infer R extends number}` ? R : never : DivideHelper<A, B>;
5
- type DivideHelper<X extends number, Y extends number, A extends number = 0> = BGreaterThanA<X, Y> extends true ? A : DivideHelper<Subtract<X, Y>, Y, Add<A, 1>>;
6
- export {};
5
+ export type DivideHelper<X extends number, Y extends number, A extends number = 0> = BGreaterThanA<X, Y> extends true ? A : DivideHelper<Subtract<X, Y>, Y, Add<A, 1>>;
@@ -1,5 +1,4 @@
1
1
  import type { Add } from "./add";
2
2
  import type { Subtract } from "./subtract";
3
3
  export type Multiply<A extends number, B extends number> = MultiHelper<A, B>;
4
- type MultiHelper<X extends number, Y extends number, A extends number = 0> = `${X}` extends `-${infer N extends number}` ? `${Y}` extends `-${infer M extends number}` ? MultiHelper<N, M, A> : `-${MultiHelper<N, Y, A>}` extends `${infer R extends number}` ? R : never : `${Y}` extends `-${infer M extends number}` ? `-${MultiHelper<X, M, A>}` extends `${infer R extends number}` ? R : never : Y extends 0 ? A : MultiHelper<X, Subtract<Y, 1>, Add<X, A>>;
5
- export {};
4
+ export type MultiHelper<X extends number, Y extends number, A extends number = 0> = `${X}` extends `-${infer N extends number}` ? `${Y}` extends `-${infer M extends number}` ? MultiHelper<N, M, A> : `-${MultiHelper<N, Y, A>}` extends `${infer R extends number}` ? R : never : `${Y}` extends `-${infer M extends number}` ? `-${MultiHelper<X, M, A>}` extends `${infer R extends number}` ? R : never : Y extends 0 ? A : MultiHelper<X, Subtract<Y, 1>, Add<X, A>>;
@@ -1,13 +1,12 @@
1
1
  import type { PickDeepKey } from "./pickDeepKey";
2
2
  import type { UnionToIntersection } from "../logic/unionToIntersection";
3
- type GetValueAtPath<T, P extends string> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? T[Key] extends object ? GetValueAtPath<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never;
4
- type ConstructNestedObject<P extends string, V> = P extends `${infer Key}.${infer Rest}` ? {
3
+ export type GetValueAtPath<T, P extends string> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? T[Key] extends object ? GetValueAtPath<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never;
4
+ export type ConstructNestedObject<P extends string, V> = P extends `${infer Key}.${infer Rest}` ? {
5
5
  [K in Key]: ConstructNestedObject<Rest, V>;
6
6
  } : {
7
7
  [K in P]: V;
8
8
  };
9
- type ProcessKeys<T extends object, K extends readonly PickDeepKey<T>[]> = {
9
+ export type ProcessKeys<T extends object, K extends readonly PickDeepKey<T>[]> = {
10
10
  [I in keyof K]: K[I] extends string ? ConstructNestedObject<K[I], GetValueAtPath<T, K[I]>> : never;
11
11
  }[number];
12
12
  export type PickDeep<T extends object, K extends readonly PickDeepKey<T>[]> = UnionToIntersection<ProcessKeys<T, K>>;
13
- export {};
package/package.json CHANGED
@@ -226,5 +226,5 @@
226
226
  },
227
227
  "type": "module",
228
228
  "types": "module/index.d.ts",
229
- "version": "2.20.0"
229
+ "version": "3.1.0"
230
230
  }
@@ -1,14 +0,0 @@
1
- /**
2
- * Array validation core module
3
- * Provides functionality to validate arrays with type-specific validation rules
4
- */
5
- import type { Types, ValidateCoreReturnType, ValidateType } from "../../Validate/type";
6
- /**
7
- * Creates an array validator with type-specific validation rules
8
- * @template A - Type of array elements (string | number | boolean)
9
- * @template O - Object containing validation functions for each type
10
- * @param {O} option - Validation functions for each type
11
- * @param {string} [message] - Custom error message for array type validation
12
- * @returns {Function} - Validator function for arrays
13
- */
14
- export declare const array: <A extends string | number | boolean, O extends { [P in Types<A>]: (value: ValidateType<P>) => ValidateCoreReturnType<ValidateType<P>>; } = { [P in Types<A>]: (value: ValidateType<P>) => ValidateCoreReturnType<ValidateType<P>>; }>(option?: O, message?: string) => (values: A[]) => ValidateCoreReturnType<A[]>;
@@ -1,43 +0,0 @@
1
- /**
2
- * Array validation core module
3
- * Provides functionality to validate arrays with type-specific validation rules
4
- */
5
- import { isArray } from "../../Validate/isArray";
6
- import { isNotEmpty } from "../../Validate/isNotEmpty";
7
- /**
8
- * Creates an array validator with type-specific validation rules
9
- * @template A - Type of array elements (string | number | boolean)
10
- * @template O - Object containing validation functions for each type
11
- * @param {O} option - Validation functions for each type
12
- * @param {string} [message] - Custom error message for array type validation
13
- * @returns {Function} - Validator function for arrays
14
- */
15
- export const array = (option = {}, message) => {
16
- return (values) => {
17
- if (!isArray(values)) {
18
- return {
19
- validate: false,
20
- message: message ?? "",
21
- type: values,
22
- };
23
- }
24
- if (isNotEmpty(option)) {
25
- for (const value of values) {
26
- const validator = option[typeof value];
27
- if (!validator?.(value).validate) {
28
- return {
29
- validate: false,
30
- message: validator?.(value).message || "",
31
- type: values,
32
- };
33
- }
34
- }
35
- }
36
- return {
37
- validate: true,
38
- message: "",
39
- type: values,
40
- };
41
- };
42
- };
43
- //# sourceMappingURL=core.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/array/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAOnD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAYnB,SAAY,EAAO,EACnB,OAAgB,EAChB,EAAE;IACF,OAAO,CAAC,MAAW,EAA+B,EAAE;QAClD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACrB,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,MAAM;aACb,CAAC;QACJ,CAAC;QACD,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACvB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,KAAiB,CAAC,CAAC;gBACnD,IAAI,CAAC,SAAS,EAAE,CAAC,KAAc,CAAC,CAAC,QAAQ,EAAE,CAAC;oBAC1C,OAAO;wBACL,QAAQ,EAAE,KAAK;wBACf,OAAO,EAAE,SAAS,EAAE,CAAC,KAAc,CAAC,CAAC,OAAO,IAAI,EAAE;wBAClD,IAAI,EAAE,MAAM;qBACb,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,MAAM;SACb,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -1,14 +0,0 @@
1
- /**
2
- * Array validation core module
3
- * Provides functionality to validate arrays with type-specific validation rules
4
- */
5
- import type { Types, ValidateCoreReturnType, ValidateType } from "../../Validate/type";
6
- /**
7
- * Creates an array validator with type-specific validation rules
8
- * @template A - Type of array elements (string | number | boolean)
9
- * @template O - Object containing validation functions for each type
10
- * @param {O} option - Validation functions for each type
11
- * @param {string} [message] - Custom error message for array type validation
12
- * @returns {Function} - Validator function for arrays
13
- */
14
- export declare const array: <A extends string | number | boolean, O extends { [P in Types<A>]: (value: ValidateType<P>) => ValidateCoreReturnType<ValidateType<P>>; } = { [P in Types<A>]: (value: ValidateType<P>) => ValidateCoreReturnType<ValidateType<P>>; }>(option?: O, message?: string) => (values: A[]) => ValidateCoreReturnType<A[]>;
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.array = void 0;
7
- var _isArray = require("../../Validate/isArray");
8
- var _isNotEmpty = require("../../Validate/isNotEmpty");
9
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
11
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } /**
13
- * Array validation core module
14
- * Provides functionality to validate arrays with type-specific validation rules
15
- */
16
- /**
17
- * Creates an array validator with type-specific validation rules
18
- * @template A - Type of array elements (string | number | boolean)
19
- * @template O - Object containing validation functions for each type
20
- * @param {O} option - Validation functions for each type
21
- * @param {string} [message] - Custom error message for array type validation
22
- * @returns {Function} - Validator function for arrays
23
- */
24
- var array = exports.array = function array() {
25
- var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26
- var message = arguments.length > 1 ? arguments[1] : undefined;
27
- return function (values) {
28
- if (!(0, _isArray.isArray)(values)) {
29
- return {
30
- validate: false,
31
- message: message !== null && message !== void 0 ? message : "",
32
- type: values
33
- };
34
- }
35
- if ((0, _isNotEmpty.isNotEmpty)(option)) {
36
- var _iterator = _createForOfIteratorHelper(values),
37
- _step;
38
- try {
39
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
40
- var _value = _step.value;
41
- var validator = option[_typeof(_value)];
42
- if (!(validator !== null && validator !== void 0 && validator(_value).validate)) {
43
- return {
44
- validate: false,
45
- message: (validator === null || validator === void 0 ? void 0 : validator(_value).message) || "",
46
- type: values
47
- };
48
- }
49
- }
50
- } catch (err) {
51
- _iterator.e(err);
52
- } finally {
53
- _iterator.f();
54
- }
55
- }
56
- return {
57
- validate: true,
58
- message: "",
59
- type: values
60
- };
61
- };
62
- };