@duplojs/utils 1.4.44 → 1.4.45

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 (113) hide show
  1. package/dist/clean/constraint/base.d.ts +5 -5
  2. package/dist/clean/constraint/defaultConstraint/number.d.ts +3 -3
  3. package/dist/clean/constraint/defaultConstraint/string.d.ts +2 -2
  4. package/dist/clean/entity.d.ts +2 -2
  5. package/dist/clean/flag.d.ts +1 -1
  6. package/dist/clean/newType.d.ts +5 -5
  7. package/dist/clean/primitive/base.d.ts +10 -10
  8. package/dist/clean/repository.d.ts +1 -1
  9. package/dist/clean/useCase.d.ts +1 -1
  10. package/dist/common/hasKinds.d.ts +3 -3
  11. package/dist/common/hasSomeKinds.d.ts +3 -3
  12. package/dist/common/path/resolveFrom.d.ts +1 -1
  13. package/dist/dataParser/base.d.ts +2 -2
  14. package/dist/dataParser/baseExtended.d.ts +2 -2
  15. package/dist/dataParser/extended/empty.d.ts +1 -1
  16. package/dist/dataParser/parsers/empty.d.ts +1 -1
  17. package/dist/date/create.d.ts +1 -1
  18. package/dist/date/createTime.d.ts +1 -1
  19. package/dist/either/bool/base.cjs +6 -1
  20. package/dist/either/bool/base.d.ts +4 -0
  21. package/dist/either/bool/base.mjs +6 -2
  22. package/dist/either/bool/create.d.ts +6 -6
  23. package/dist/either/bool/falsy.cjs +9 -4
  24. package/dist/either/bool/falsy.d.ts +23 -15
  25. package/dist/either/bool/falsy.mjs +10 -6
  26. package/dist/either/bool/truthy.cjs +9 -4
  27. package/dist/either/bool/truthy.d.ts +23 -15
  28. package/dist/either/bool/truthy.mjs +10 -6
  29. package/dist/either/future/base.cjs +6 -1
  30. package/dist/either/future/base.d.ts +4 -0
  31. package/dist/either/future/base.mjs +6 -2
  32. package/dist/either/future/create.d.ts +8 -8
  33. package/dist/either/future/error.cjs +7 -2
  34. package/dist/either/future/error.d.ts +15 -7
  35. package/dist/either/future/error.mjs +8 -4
  36. package/dist/either/future/success.cjs +7 -2
  37. package/dist/either/future/success.d.ts +15 -7
  38. package/dist/either/future/success.mjs +8 -4
  39. package/dist/either/hasInformation.cjs +2 -2
  40. package/dist/either/hasInformation.d.ts +8 -8
  41. package/dist/either/hasInformation.mjs +3 -3
  42. package/dist/either/index.cjs +24 -0
  43. package/dist/either/index.mjs +23 -23
  44. package/dist/either/kind.cjs +6 -1
  45. package/dist/either/kind.d.ts +4 -0
  46. package/dist/either/kind.mjs +6 -2
  47. package/dist/either/left/create.cjs +7 -2
  48. package/dist/either/left/create.d.ts +14 -6
  49. package/dist/either/left/create.mjs +8 -4
  50. package/dist/either/left/error.cjs +7 -2
  51. package/dist/either/left/error.d.ts +14 -6
  52. package/dist/either/left/error.mjs +7 -3
  53. package/dist/either/left/fail.cjs +7 -2
  54. package/dist/either/left/fail.d.ts +14 -6
  55. package/dist/either/left/fail.mjs +7 -3
  56. package/dist/either/left/is.cjs +2 -2
  57. package/dist/either/left/is.d.ts +4 -4
  58. package/dist/either/left/is.mjs +4 -4
  59. package/dist/either/left/when.d.ts +4 -4
  60. package/dist/either/nullable/base.cjs +6 -1
  61. package/dist/either/nullable/base.d.ts +4 -0
  62. package/dist/either/nullable/base.mjs +6 -2
  63. package/dist/either/nullable/create.d.ts +5 -5
  64. package/dist/either/nullable/empty.cjs +9 -4
  65. package/dist/either/nullable/empty.d.ts +23 -15
  66. package/dist/either/nullable/empty.mjs +10 -6
  67. package/dist/either/nullable/filled.cjs +9 -4
  68. package/dist/either/nullable/filled.d.ts +22 -14
  69. package/dist/either/nullable/filled.mjs +10 -6
  70. package/dist/either/nullish/base.cjs +6 -1
  71. package/dist/either/nullish/base.d.ts +4 -0
  72. package/dist/either/nullish/base.mjs +6 -2
  73. package/dist/either/nullish/create.d.ts +5 -5
  74. package/dist/either/nullish/empty.cjs +9 -4
  75. package/dist/either/nullish/empty.d.ts +23 -15
  76. package/dist/either/nullish/empty.mjs +10 -6
  77. package/dist/either/nullish/filled.cjs +9 -4
  78. package/dist/either/nullish/filled.d.ts +23 -15
  79. package/dist/either/nullish/filled.mjs +10 -6
  80. package/dist/either/optional/base.cjs +6 -1
  81. package/dist/either/optional/base.d.ts +4 -0
  82. package/dist/either/optional/base.mjs +6 -2
  83. package/dist/either/optional/create.d.ts +5 -5
  84. package/dist/either/optional/empty.cjs +9 -4
  85. package/dist/either/optional/empty.d.ts +23 -15
  86. package/dist/either/optional/empty.mjs +10 -6
  87. package/dist/either/optional/filled.cjs +9 -4
  88. package/dist/either/optional/filled.d.ts +22 -14
  89. package/dist/either/optional/filled.mjs +10 -6
  90. package/dist/either/right/asyncGroup.d.ts +7 -7
  91. package/dist/either/right/asyncPipe.d.ts +33 -25
  92. package/dist/either/right/create.cjs +7 -2
  93. package/dist/either/right/create.d.ts +15 -7
  94. package/dist/either/right/create.mjs +8 -4
  95. package/dist/either/right/group.d.ts +8 -8
  96. package/dist/either/right/is.cjs +2 -2
  97. package/dist/either/right/is.d.ts +4 -4
  98. package/dist/either/right/is.mjs +4 -4
  99. package/dist/either/right/ok.cjs +7 -2
  100. package/dist/either/right/ok.d.ts +14 -6
  101. package/dist/either/right/ok.mjs +7 -3
  102. package/dist/either/right/pipe.d.ts +32 -24
  103. package/dist/either/right/success.cjs +7 -2
  104. package/dist/either/right/success.d.ts +14 -6
  105. package/dist/either/right/success.mjs +7 -3
  106. package/dist/either/right/when.d.ts +4 -4
  107. package/dist/either/safeCallback.cjs +14 -4
  108. package/dist/either/safeCallback.d.ts +33 -17
  109. package/dist/either/safeCallback.mjs +13 -5
  110. package/dist/either/whenHasInformation.cjs +1 -1
  111. package/dist/either/whenHasInformation.d.ts +7 -7
  112. package/dist/either/whenHasInformation.mjs +2 -2
  113. package/package.json +1 -1
@@ -30,13 +30,13 @@ export interface ConstraintHandler<GenericName extends string = string, GenericP
30
30
  * const result = Between1And10.create(5);
31
31
  *
32
32
  * if (E.isRight(result)) {
33
- * // result : E.EitherRight<"createConstrainedType", C.ConstrainedType<"between-1-10", 5>>
33
+ * // result : E.Right<"createConstrainedType", C.ConstrainedType<"between-1-10", 5>>
34
34
  * }
35
35
  * ```
36
36
  *
37
37
  */
38
- create<GenericData extends GenericPrimitiveValue>(data: GenericData): (DEither.EitherRight<"createConstrainedType", ConstrainedType<GenericName, GenericData>> | DEither.EitherLeft<"createConstrainedTypeError", DDataParser.DataParserError>);
39
- create<GenericPrimitive extends Primitive<GenericPrimitiveValue>>(data: GenericPrimitive): (DEither.EitherRight<"createConstrainedType", (GenericPrimitive & ConstrainedType<GenericName, Unwrap<GenericPrimitive>>)> | DEither.EitherLeft<"createConstrainedTypeError", DDataParser.DataParserError>);
38
+ create<GenericData extends GenericPrimitiveValue>(data: GenericData): (DEither.Right<"createConstrainedType", ConstrainedType<GenericName, GenericData>> | DEither.Left<"createConstrainedTypeError", DDataParser.DataParserError>);
39
+ create<GenericPrimitive extends Primitive<GenericPrimitiveValue>>(data: GenericPrimitive): (DEither.Right<"createConstrainedType", (GenericPrimitive & ConstrainedType<GenericName, Unwrap<GenericPrimitive>>)> | DEither.Left<"createConstrainedTypeError", DDataParser.DataParserError>);
40
40
  /**
41
41
  * Creates a constrained value and throws on error.
42
42
  *
@@ -57,7 +57,7 @@ export interface ConstraintHandler<GenericName extends string = string, GenericP
57
57
  * ```
58
58
  *
59
59
  */
60
- createWithUnknown<GenericData extends unknown>(data: GenericData): (DEither.EitherRight<"createConstrainedType", ConstrainedType<GenericName, GenericPrimitiveValue>> | DEither.EitherLeft<"createConstrainedTypeError", DDataParser.DataParserError>);
60
+ createWithUnknown<GenericData extends unknown>(data: GenericData): (DEither.Right<"createConstrainedType", ConstrainedType<GenericName, GenericPrimitiveValue>> | DEither.Left<"createConstrainedTypeError", DDataParser.DataParserError>);
61
61
  /**
62
62
  * Creates a constrained value from an unknown input and throws on error.
63
63
  *
@@ -107,7 +107,7 @@ export declare class CreateConstrainedTypeError extends CreateConstrainedTypeErr
107
107
  * const result = Between1And10.create(5);
108
108
  *
109
109
  * if (E.isRight(result)) {
110
- * // result : E.EitherRight<"createConstrainedType", C.ConstrainedType<"between-1-10", 5>>
110
+ * // result : E.Right<"createConstrainedType", C.ConstrainedType<"between-1-10", 5>>
111
111
  * }
112
112
  *
113
113
  * const value = Between1And10.createOrThrow(7);
@@ -12,7 +12,7 @@ import * as DDataParser from "../../../dataParser";
12
12
  * const result = C.Int.create(12);
13
13
  *
14
14
  * if (E.isRight(result)) {
15
- * // result: E.EitherRight<"createConstrainedType", C.ConstrainedType<"int", 12>>
15
+ * // result: E.Right<"createConstrainedType", C.ConstrainedType<"int", 12>>
16
16
  * }
17
17
  *
18
18
  * const value = C.Int.createOrThrow(7);
@@ -41,7 +41,7 @@ export type Int = GetConstraint<typeof Int>;
41
41
  * const result = C.Positive.create(4);
42
42
  *
43
43
  * if (E.isRight(result)) {
44
- * // result: E.EitherRight<"createConstrainedType", C.ConstrainedType<"positive", 4>>
44
+ * // result: E.Right<"createConstrainedType", C.ConstrainedType<"positive", 4>>
45
45
  * }
46
46
  *
47
47
  * const value = C.Positive.createOrThrow(10);
@@ -70,7 +70,7 @@ export type Positive = GetConstraint<typeof Positive>;
70
70
  * const result = C.Negative.create(-4);
71
71
  *
72
72
  * if (E.isRight(result)) {
73
- * // result: E.EitherRight<"createConstrainedType", C.ConstrainedType<"negative", -4>>
73
+ * // result: E.Right<"createConstrainedType", C.ConstrainedType<"negative", -4>>
74
74
  * }
75
75
  *
76
76
  * const value = C.Negative.createOrThrow(-10);
@@ -12,7 +12,7 @@ import * as DDataParser from "../../../dataParser";
12
12
  * const result = C.Email.create("hello@duplojs.dev");
13
13
  *
14
14
  * if (E.isRight(result)) {
15
- * // result: E.EitherRight<"createConstrainedType", C.ConstrainedType<"email", "hello@duplojs.dev">>
15
+ * // result: E.Right<"createConstrainedType", C.ConstrainedType<"email", "hello@duplojs.dev">>
16
16
  * }
17
17
  *
18
18
  * const email = C.Email.createOrThrow("a@b.com");
@@ -41,7 +41,7 @@ export type Email = GetConstraint<typeof Email>;
41
41
  * const result = C.Url.create("https://duplojs.dev");
42
42
  *
43
43
  * if (E.isRight(result)) {
44
- * // result: E.EitherRight<"createConstrainedType", C.ConstrainedType<"url", "https://duplojs.dev">>
44
+ * // result: E.Right<"createConstrainedType", C.ConstrainedType<"url", "https://duplojs.dev">>
45
45
  * }
46
46
  *
47
47
  * const url = C.Url.createOrThrow("https://example.com");
@@ -85,7 +85,7 @@ export interface EntityHandler<GenericName extends string = string, GenericPrope
85
85
  * ```
86
86
  *
87
87
  */
88
- map(rawProperties: EntityRawProperties<GenericPropertiesDefinition>): (DEither.EitherRight<"createEntity", Entity<GenericName> & EntityProperties<GenericPropertiesDefinition>> | DEither.EitherLeft<"createEntityError", DDataParser.DataParserError>);
88
+ map(rawProperties: EntityRawProperties<GenericPropertiesDefinition>): (DEither.Right<"createEntity", Entity<GenericName> & EntityProperties<GenericPropertiesDefinition>> | DEither.Left<"createEntityError", DDataParser.DataParserError>);
89
89
  /**
90
90
  * Validates raw properties and throws on error.
91
91
  *
@@ -209,7 +209,7 @@ export interface PropertiesDefinitionParams {
209
209
  * });
210
210
  *
211
211
  * if (E.isRight(mappedResult)) {
212
- * // mappedResult: E.EitherRight<"createEntity", C.Entity<"User">>
212
+ * // mappedResult: E.Right<"createEntity", C.Entity<"User">>
213
213
  * }
214
214
  *
215
215
  * ```
@@ -91,7 +91,7 @@ export interface Flag<GenericName extends string = string, GenericValue extends
91
91
  * drinkAlcohol,
92
92
  * ),
93
93
  * );
94
- * // E.EitherLeft<"not-major", undefined> | E.EitherRight<"not-thirsty-anymore", undefined>
94
+ * // E.Left<"not-major", undefined> | E.Right<"not-thirsty-anymore", undefined>
95
95
  *
96
96
  * const flagged = User.MajorFlag.append(user, user.age);
97
97
  * const value = User.MajorFlag.getValue(flagged);
@@ -34,8 +34,8 @@ export interface NewTypeHandler<GenericName extends string = string, GenericValu
34
34
  * ```
35
35
  *
36
36
  */
37
- create<const GenericData extends GenericValue>(data: GenericData): (DEither.EitherRight<"createNewType", NewType<GenericName, GenericData, GenericConstrainHandler[number]["name"]>> | DEither.EitherLeft<"createNewTypeError", DDataParser.DataParserError>);
38
- create<GenericPrimitive extends Primitive<Extract<GenericValue, EligiblePrimitive>>>(data: GenericPrimitive): (DEither.EitherRight<"createNewType", (GenericPrimitive & NewType<GenericName, Unwrap<GenericPrimitive>, GenericConstrainHandler[number]["name"]>)> | DEither.EitherLeft<"createNewTypeError", DDataParser.DataParserError>);
37
+ create<const GenericData extends GenericValue>(data: GenericData): (DEither.Right<"createNewType", NewType<GenericName, GenericData, GenericConstrainHandler[number]["name"]>> | DEither.Left<"createNewTypeError", DDataParser.DataParserError>);
38
+ create<GenericPrimitive extends Primitive<Extract<GenericValue, EligiblePrimitive>>>(data: GenericPrimitive): (DEither.Right<"createNewType", (GenericPrimitive & NewType<GenericName, Unwrap<GenericPrimitive>, GenericConstrainHandler[number]["name"]>)> | DEither.Left<"createNewTypeError", DDataParser.DataParserError>);
39
39
  /**
40
40
  * Creates a NewType value and throws on error. Works with raw values or primitives.
41
41
  *
@@ -60,12 +60,12 @@ export interface NewTypeHandler<GenericName extends string = string, GenericValu
60
60
  * const maybe = UserId.createWithUnknown(unknownValue);
61
61
  *
62
62
  * if (E.isRight(maybe)) {
63
- * // maybe: E.EitherRight<"createNewType", UserId>
63
+ * // maybe: E.Right<"createNewType", UserId>
64
64
  * }
65
65
  * ```
66
66
  *
67
67
  */
68
- createWithUnknown<GenericData extends unknown>(data: GenericData): (DEither.EitherRight<"createNewType", NewType<GenericName, GenericValue, GenericConstrainHandler[number]["name"]>> | DEither.EitherLeft<"createNewTypeError", DDataParser.DataParserError>);
68
+ createWithUnknown<GenericData extends unknown>(data: GenericData): (DEither.Right<"createNewType", NewType<GenericName, GenericValue, GenericConstrainHandler[number]["name"]>> | DEither.Left<"createNewTypeError", DDataParser.DataParserError>);
69
69
  /**
70
70
  * Creates a NewType value from an unknown input and throws on error.
71
71
  *
@@ -125,7 +125,7 @@ export declare class CreateNewTypeError extends CreateNewTypeError_base {
125
125
  * const maybe = UserId.createWithUnknown(unknownValue);
126
126
  *
127
127
  * if (E.isRight(maybe)) {
128
- * // maybe: E.EitherRight<"createNewType", UserId>
128
+ * // maybe: E.Right<"createNewType", UserId>
129
129
  * }
130
130
  *
131
131
  * const strictValue = UserId.createWithUnknownOrThrow(unknownValue);
@@ -14,12 +14,12 @@ export interface PrimitiveHandler<GenericValue extends EligiblePrimitive = Eligi
14
14
  * const result = C.String.create("hello");
15
15
  *
16
16
  * if (E.isRight(result)) {
17
- * // result: E.EitherRight<"createNewType", C.Primitive<"hello">>
17
+ * // result: E.Right<"createNewType", C.Primitive<"hello">>
18
18
  * }
19
19
  * ```
20
20
  *
21
21
  */
22
- create<GenericData extends GenericValue>(data: GenericData): (DEither.EitherRight<"createNewType", Primitive<GenericData>> | DEither.EitherLeft<"createNewTypeError", DDataParser.DataParserError>);
22
+ create<GenericData extends GenericValue>(data: GenericData): (DEither.Right<"createNewType", Primitive<GenericData>> | DEither.Left<"createNewTypeError", DDataParser.DataParserError>);
23
23
  /**
24
24
  * Creates a primitive value and throws on error.
25
25
  *
@@ -36,11 +36,11 @@ export interface PrimitiveHandler<GenericValue extends EligiblePrimitive = Eligi
36
36
  * ```ts
37
37
  * const unknownValue: unknown = "world";
38
38
  * const maybe = C.String.createWithUnknown(unknownValue);
39
- * // E.EitherLeft<"createNewTypeError", DataParserError> | E.EitherRight<"createNewType", C.Primitive<string>>
39
+ * // E.Left<"createNewTypeError", DataParserError> | E.Right<"createNewType", C.Primitive<string>>
40
40
  * ```
41
41
  *
42
42
  */
43
- createWithUnknown<GenericData extends unknown>(data: GenericData): (DEither.EitherRight<"createNewType", Primitive<GenericValue>> | DEither.EitherLeft<"createNewTypeError", DDataParser.DataParserError>);
43
+ createWithUnknown<GenericData extends unknown>(data: GenericData): (DEither.Right<"createNewType", Primitive<GenericValue>> | DEither.Left<"createNewTypeError", DDataParser.DataParserError>);
44
44
  /**
45
45
  * Creates a primitive value from an unknown input and throws on error.
46
46
  *
@@ -89,7 +89,7 @@ export declare class CreatePrimitiveError extends CreatePrimitiveError_base {
89
89
  * const result = C.String.create("hello");
90
90
  *
91
91
  * if (E.isRight(result)) {
92
- * // result: E.EitherRight<"createNewType", C.Primitive<"hello">>
92
+ * // result: E.Right<"createNewType", C.Primitive<"hello">>
93
93
  * }
94
94
  *
95
95
  * const value = C.String.createOrThrow("world");
@@ -122,7 +122,7 @@ export type String = ReturnType<typeof String["createWithUnknownOrThrow"]>;
122
122
  * const result = C.Number.create(42);
123
123
  *
124
124
  * if (E.isRight(result)) {
125
- * // result: E.EitherRight<"createNewType", C.Primitive<42>>
125
+ * // result: E.Right<"createNewType", C.Primitive<42>>
126
126
  * }
127
127
  *
128
128
  * const value = C.Number.createOrThrow(7);
@@ -155,7 +155,7 @@ export type Number = ReturnType<typeof Number["createWithUnknownOrThrow"]>;
155
155
  * const result = C.BigInt.create(10n);
156
156
  *
157
157
  * if (E.isRight(result)) {
158
- * // result: E.EitherRight<"createNewType", C.Primitive<10n>>
158
+ * // result: E.Right<"createNewType", C.Primitive<10n>>
159
159
  * }
160
160
  *
161
161
  * const value = C.BigInt.createOrThrow(99n);
@@ -188,7 +188,7 @@ export type BigInt = ReturnType<typeof BigInt["createWithUnknownOrThrow"]>;
188
188
  * const result = C.Boolean.create(true);
189
189
  *
190
190
  * if (E.isRight(result)) {
191
- * // result: E.EitherRight<"createNewType", C.Primitive<true>>
191
+ * // result: E.Right<"createNewType", C.Primitive<true>>
192
192
  * }
193
193
  *
194
194
  * const value = C.Boolean.createOrThrow(false);
@@ -223,7 +223,7 @@ export type Boolean = ReturnType<typeof Boolean["createWithUnknownOrThrow"]>;
223
223
  * const result = C.Date.create(date);
224
224
  *
225
225
  * if (E.isRight(result)) {
226
- * // result: E.EitherRight<"createNewType", C.Primitive<D.TheDate>>
226
+ * // result: E.Right<"createNewType", C.Primitive<D.TheDate>>
227
227
  * }
228
228
  *
229
229
  * const value = C.Date.createOrThrow(date);
@@ -258,7 +258,7 @@ export type Date = ReturnType<typeof Date["createWithUnknownOrThrow"]>;
258
258
  * const result = C.Time.create(theTime);
259
259
  *
260
260
  * if (E.isRight(result)) {
261
- * // result: E.EitherRight<"createNewType", C.Primitive<D.TheTime>>
261
+ * // result: E.Right<"createNewType", C.Primitive<D.TheTime>>
262
262
  * }
263
263
  *
264
264
  * const value = C.Time.createOrThrow(theTime);
@@ -55,7 +55,7 @@ export interface RepositoryHandler<GenericRepository extends object = object> ex
55
55
  *
56
56
  * // Application Layer
57
57
  * interface UserRepository {
58
- * findById(id: User.Id): Promise<E.EitherSuccess<User.Entity> | E.EitherFail>;
58
+ * findById(id: User.Id): Promise<E.Success<User.Entity> | E.Fail>;
59
59
  * }
60
60
  *
61
61
  * const UserRepository = C.createRepository<UserRepository>();
@@ -60,7 +60,7 @@ export interface UseCaseHandler<GenericDependencies extends UseCaseDependencies
60
60
  *
61
61
  * // Application Layer
62
62
  * interface UserRepository {
63
- * findById(id: User.Id): Promise<E.EitherSuccess<User.Entity> | E.EitherFail>;
63
+ * findById(id: User.Id): Promise<E.Success<User.Entity> | E.Fail>;
64
64
  * }
65
65
  *
66
66
  * const UserRepository = C.createRepository<UserRepository>();
@@ -12,13 +12,13 @@ import { type AnyTuple, type UnionToIntersection } from "./types";
12
12
  * Predicate overloads (type guards) narrow the output type.
13
13
  *
14
14
  * ```ts
15
- * const input = E.ok() as E.EitherOk | E.EitherError;
15
+ * const input = E.ok() as E.Ok | E.Error;
16
16
  *
17
17
  * if (hasKinds(input, [
18
18
  * E.eitherOkKind,
19
19
  * E.eitherRightKind,
20
20
  * ])) {
21
- * // type: E.EitherOk
21
+ * // type: E.Ok
22
22
  * }
23
23
  *
24
24
  * const result = pipe(
@@ -31,7 +31,7 @@ import { type AnyTuple, type UnionToIntersection } from "./types";
31
31
  * () => "ok",
32
32
  * ),
33
33
  * );
34
- * // result: "ok" | E.EitherError<unknown>
34
+ * // result: "ok" | E.Error<unknown>
35
35
  * ```
36
36
  *
37
37
  * @see https://utils.duplojs.dev/en/v1/api/common/hasKinds
@@ -12,13 +12,13 @@ import { type AnyTuple } from "./types";
12
12
  * Predicate overloads (type guards) narrow the output type.
13
13
  *
14
14
  * ```ts
15
- * const input = E.ok() as E.EitherOk | E.EitherError;
15
+ * const input = E.ok() as E.Ok | E.Error;
16
16
  *
17
17
  * if (hasSomeKinds(input, [
18
18
  * E.eitherOkKind,
19
19
  * E.eitherErrorKind,
20
20
  * ])) {
21
- * // type: E.EitherOk | E.EitherError
21
+ * // type: E.Ok | E.Error
22
22
  * }
23
23
  *
24
24
  * const result = pipe(
@@ -31,7 +31,7 @@ import { type AnyTuple } from "./types";
31
31
  * () => "known",
32
32
  * ),
33
33
  * );
34
- * // result: "known" | E.EitherError<unknown>
34
+ * // result: "known" | E.Error<unknown>
35
35
  * ```
36
36
  *
37
37
  * @see https://utils.duplojs.dev/en/v1/api/common/hasSomeKinds
@@ -24,4 +24,4 @@ import type { AnyTuple } from "../types";
24
24
  * @see https://utils.duplojs.dev/en/v1/api/common/path/resolveFrom
25
25
  *
26
26
  */
27
- export declare function resolveFrom<GenericSegment extends string>(origin: string, segments: AnyTuple<GenericSegment>): DEither.EitherFail | DEither.EitherSuccess<string>;
27
+ export declare function resolveFrom<GenericSegment extends string>(origin: string, segments: AnyTuple<GenericSegment>): DEither.Fail | DEither.Success<string>;
@@ -67,7 +67,7 @@ export interface DataParser<GenericDefinition extends DataParserDefinition = Dat
67
67
  * @namespace DP
68
68
  *
69
69
  */
70
- parse(data: unknown): DEither.EitherSuccess<GenericOutput> | DEither.EitherError<DataParserError>;
70
+ parse(data: unknown): DEither.Success<GenericOutput> | DEither.Error<DataParserError>;
71
71
  /**
72
72
  * The asyncParse() method runs a data parser asynchronously and resolves to an Either with the parsed value or a DataParserError.
73
73
  *
@@ -79,7 +79,7 @@ export interface DataParser<GenericDefinition extends DataParserDefinition = Dat
79
79
  * @namespace DP
80
80
  *
81
81
  */
82
- asyncParse(data: unknown): Promise<DEither.EitherSuccess<GenericOutput> | DEither.EitherError<DataParserError>>;
82
+ asyncParse(data: unknown): Promise<DEither.Success<GenericOutput> | DEither.Error<DataParserError>>;
83
83
  /**
84
84
  * The addChecker() method returns a new data parser with one or more additional checkers appended.
85
85
  *
@@ -45,7 +45,7 @@ export interface DataParserExtended<GenericDefinition extends DataParserDefiniti
45
45
  * @namespace DPE
46
46
  *
47
47
  */
48
- parse(data: unknown): DEither.EitherSuccess<GenericOutput> | DEither.EitherError<DataParserError>;
48
+ parse(data: unknown): DEither.Success<GenericOutput> | DEither.Error<DataParserError>;
49
49
  /**
50
50
  * The asyncParse() method runs an extended data parser asynchronously and resolves to an Either with the parsed value or a DataParserError.
51
51
  *
@@ -57,7 +57,7 @@ export interface DataParserExtended<GenericDefinition extends DataParserDefiniti
57
57
  * @namespace DPE
58
58
  *
59
59
  */
60
- asyncParse(data: unknown): Promise<DEither.EitherSuccess<GenericOutput> | DEither.EitherError<DataParserError>>;
60
+ asyncParse(data: unknown): Promise<DEither.Success<GenericOutput> | DEither.Error<DataParserError>>;
61
61
  /**
62
62
  * The parseOrThrow() method runs an extended data parser synchronously and returns the parsed value or throws a DataParserThrowError.
63
63
  *
@@ -26,7 +26,7 @@ export interface DataParserEmptyExtended<GenericDefinition extends dataParsers.D
26
26
  * const parser = DPE.empty();
27
27
  * const result = parser.parse(undefined);
28
28
  * if (E.isRight(result)) {
29
- * // E.EitherSuccess<undefined>
29
+ * // E.Success<undefined>
30
30
  * }
31
31
  *
32
32
  * const coerceParser = DPE.coerce.empty();
@@ -33,7 +33,7 @@ export interface DataParserEmpty<GenericDefinition extends DataParserDefinitionE
33
33
  * const parser = DP.empty();
34
34
  * const result = parser.parse(undefined);
35
35
  * if (E.isRight(result)) {
36
- * // E.EitherSuccess<undefined>
36
+ * // E.Success<undefined>
37
37
  * }
38
38
  *
39
39
  * const withCheckers = DP.empty({
@@ -2,7 +2,7 @@ import type { Hour, IsLeapYear, IsSafeYear, Millisecond, Minute, Second, TheDate
2
2
  import * as DEither from "../either";
3
3
  import type * as DString from "../string";
4
4
  import { type And, type IsEqual, type Not, type IsExtends } from "../common";
5
- export type MayBe = DEither.EitherRight<"date-created", TheDate> | DEither.EitherLeft<"date-created-error", null>;
5
+ export type MayBe = DEither.Right<"date-created", TheDate> | DEither.Left<"date-created-error", null>;
6
6
  type SafeDate = `${number}-${MonthWithDay}`;
7
7
  declare const SymbolForbiddenDate: unique symbol;
8
8
  type ForbiddenDate<GenericDate extends string> = And<[
@@ -3,7 +3,7 @@ import { type maxTimeValue, type minTimeValue } from "./constants";
3
3
  import { type TheTime, type SpoolingTime } from "./types";
4
4
  import * as DEither from "../either";
5
5
  import { type IsGreater, type IsLess } from "../number";
6
- export type MayBeTime = DEither.EitherRight<"time-created", TheTime> | DEither.EitherLeft<"time-created-error", null>;
6
+ export type MayBeTime = DEither.Right<"time-created", TheTime> | DEither.Left<"time-created-error", null>;
7
7
  type Units = "week" | "day" | "hour" | "minute" | "second" | "millisecond";
8
8
  declare const SymbolForbiddenTime: unique symbol;
9
9
  type ForbiddenTime<GenericInput extends number, GenericUnit extends Units> = IsEqual<GenericInput, number> extends true ? {
@@ -2,6 +2,11 @@
2
2
 
3
3
  var kind = require('../kind.cjs');
4
4
 
5
- const eitherBoolKind = kind.createEitherKind("bool");
5
+ const boolKind = kind.createEitherKind("bool");
6
+ /**
7
+ * @deprecated use boolKind
8
+ */
9
+ const eitherBoolKind = boolKind;
6
10
 
11
+ exports.boolKind = boolKind;
7
12
  exports.eitherBoolKind = eitherBoolKind;
@@ -1 +1,5 @@
1
+ export declare const boolKind: import("../..").KindHandler<import("../..").KindDefinition<"@DuplojsUtilsEither/bool", unknown>>;
2
+ /**
3
+ * @deprecated use boolKind
4
+ */
1
5
  export declare const eitherBoolKind: import("../..").KindHandler<import("../..").KindDefinition<"@DuplojsUtilsEither/bool", unknown>>;
@@ -1,5 +1,9 @@
1
1
  import { createEitherKind } from '../kind.mjs';
2
2
 
3
- const eitherBoolKind = createEitherKind("bool");
3
+ const boolKind = createEitherKind("bool");
4
+ /**
5
+ * @deprecated use boolKind
6
+ */
7
+ const eitherBoolKind = boolKind;
4
8
 
5
- export { eitherBoolKind };
9
+ export { boolKind, eitherBoolKind };
@@ -1,8 +1,8 @@
1
1
  import { type FalsyValue, type IsEqual } from "../../common";
2
- import { type EitherBoolFalsy } from "./falsy";
3
- import { type EitherBoolTruthy } from "./truthy";
2
+ import { type BoolFalsy } from "./falsy";
3
+ import { type BoolTruthy } from "./truthy";
4
4
  /**
5
- * Converts any value into a boolean monad (EitherBoolTruthy or EitherBoolFalsy). Handy to keep track of the test while benefiting from the whenIsBoolTruthy/whenIsBoolFalsy helpers.
5
+ * Converts any value into a boolean monad (BoolTruthy or BoolFalsy). Handy to keep track of the test while benefiting from the whenIsBoolTruthy/whenIsBoolFalsy helpers.
6
6
  *
7
7
  * Signature: `bool(value)` → returns a value
8
8
  *
@@ -15,7 +15,7 @@ import { type EitherBoolTruthy } from "./truthy";
15
15
  * E.bool,
16
16
  * );
17
17
  *
18
- * // type: E.EitherBoolFalsy<undefined> | E.EitherBoolTruthy<"nest">
18
+ * // type: E.BoolFalsy<undefined> | E.BoolTruthy<"nest">
19
19
  * ```
20
20
  *
21
21
  * @see https://utils.duplojs.dev/en/v1/api/either/bool
@@ -23,5 +23,5 @@ import { type EitherBoolTruthy } from "./truthy";
23
23
  * @namespace E
24
24
  *
25
25
  */
26
- export declare function bool<const GenericValue extends unknown = undefined>(value: GenericValue): GenericValue extends FalsyValue ? EitherBoolFalsy<GenericValue> : IsEqual<GenericValue, number> extends true ? EitherBoolTruthy<GenericValue> | EitherBoolFalsy<0> : IsEqual<GenericValue, bigint> extends true ? EitherBoolTruthy<GenericValue> | EitherBoolFalsy<0n> : IsEqual<GenericValue, string> extends true ? EitherBoolTruthy<GenericValue> | EitherBoolFalsy<""> : EitherBoolTruthy<GenericValue>;
27
- export type Bool<GenericValue extends unknown> = EitherBoolTruthy<GenericValue> | EitherBoolFalsy;
26
+ export declare function bool<const GenericValue extends unknown = undefined>(value: GenericValue): GenericValue extends FalsyValue ? BoolFalsy<GenericValue> : IsEqual<GenericValue, number> extends true ? BoolTruthy<GenericValue> | BoolFalsy<0> : IsEqual<GenericValue, bigint> extends true ? BoolTruthy<GenericValue> | BoolFalsy<0n> : IsEqual<GenericValue, string> extends true ? BoolTruthy<GenericValue> | BoolFalsy<""> : BoolTruthy<GenericValue>;
27
+ export type Bool<GenericValue extends unknown> = BoolTruthy<GenericValue> | BoolFalsy;
@@ -8,7 +8,11 @@ var is = require('../left/is.cjs');
8
8
  var is$1 = require('../right/is.cjs');
9
9
  var unwrap = require('../../common/unwrap.cjs');
10
10
 
11
- const eitherBoolFalsyKind = kind.createEitherKind("bool-falsy");
11
+ const boolFalsyKind = kind.createEitherKind("bool-falsy");
12
+ /**
13
+ * @deprecated use boolFalsyKind
14
+ */
15
+ const eitherBoolFalsyKind = boolFalsyKind;
12
16
  /**
13
17
  * {@include either/boolFalsy/index.md}
14
18
  */
@@ -19,12 +23,12 @@ const eitherBoolFalsyKind = kind.createEitherKind("bool-falsy");
19
23
  * {@include either/whenIsBoolFalsy/index.md}
20
24
  */
21
25
  function boolFalsy(value = undefined) {
22
- return base.eitherBoolKind.setTo(eitherBoolFalsyKind.setTo(create.left("bool", value)));
26
+ return base.boolKind.setTo(boolFalsyKind.setTo(create.left("bool", value)));
23
27
  }
24
28
  function isBoolFalsy(input) {
25
29
  return is.isLeft(input)
26
- && base.eitherBoolKind.has(input)
27
- && eitherBoolFalsyKind.has(input);
30
+ && base.boolKind.has(input)
31
+ && boolFalsyKind.has(input);
28
32
  }
29
33
  function whenIsBoolFalsy(...args) {
30
34
  if (args.length === 1) {
@@ -48,6 +52,7 @@ function whenIsBoolFalsy(...args) {
48
52
  }
49
53
 
50
54
  exports.boolFalsy = boolFalsy;
55
+ exports.boolFalsyKind = boolFalsyKind;
51
56
  exports.eitherBoolFalsyKind = eitherBoolFalsyKind;
52
57
  exports.isBoolFalsy = isBoolFalsy;
53
58
  exports.whenIsBoolFalsy = whenIsBoolFalsy;
@@ -1,15 +1,23 @@
1
1
  import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink, type FalsyValue } from "../../common";
2
2
  import { type Kind } from "../../common/kind";
3
- import { eitherBoolKind } from "./base";
3
+ import { boolKind } from "./base";
4
4
  import { bool } from "./create";
5
- import { type EitherLeft } from "../left";
6
- import { type EitherRight } from "../right";
5
+ import { type Left } from "../left";
6
+ import { type Right } from "../right";
7
+ export declare const boolFalsyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/bool-falsy", unknown>>;
8
+ /**
9
+ * @deprecated use boolFalsyKind
10
+ */
7
11
  export declare const eitherBoolFalsyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/bool-falsy", unknown>>;
8
- type _EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> = (EitherLeft<"bool", GenericValue> & Kind<typeof eitherBoolKind.definition> & Kind<typeof eitherBoolFalsyKind.definition>);
9
- export interface EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> extends _EitherBoolFalsy<GenericValue> {
12
+ type _BoolFalsy<GenericValue extends FalsyValue = FalsyValue> = (Left<"bool", GenericValue> & Kind<typeof boolKind.definition> & Kind<typeof boolFalsyKind.definition>);
13
+ export interface BoolFalsy<GenericValue extends FalsyValue = FalsyValue> extends _BoolFalsy<GenericValue> {
10
14
  }
11
15
  /**
12
- * Builds an EitherLeft<"bool"> for an explicitly falsy value (0, "", null, undefined, false).
16
+ * @deprecated use BoolFalsy
17
+ */
18
+ export type EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> = BoolFalsy<GenericValue>;
19
+ /**
20
+ * Builds an Left<"bool"> for an explicitly falsy value (0, "", null, undefined, false).
13
21
  *
14
22
  * Signature: `boolFalsy(value)` → returns a value
15
23
  *
@@ -26,7 +34,7 @@ export interface EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> e
26
34
  * ),
27
35
  * );
28
36
  *
29
- * // type: string | E.EitherBoolFalsy<"">
37
+ * // type: string | E.BoolFalsy<"">
30
38
  * ```
31
39
  *
32
40
  * @see https://utils.duplojs.dev/en/v1/api/either/boolFalsy
@@ -35,7 +43,7 @@ export interface EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> e
35
43
  *
36
44
  */
37
45
  /**
38
- * Type guard that detects an EitherBoolFalsy.
46
+ * Type guard that detects an BoolFalsy.
39
47
  *
40
48
  * Signature: `isBoolFalsy(input)` → returns a value
41
49
  *
@@ -45,7 +53,7 @@ export interface EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> e
45
53
  * const maybeInput = E.bool(true ? true : null);
46
54
  *
47
55
  * if (E.isBoolFalsy(maybeInput)) {
48
- * // type: E.EitherBoolFalsy<null>
56
+ * // type: E.BoolFalsy<null>
49
57
  * }
50
58
  * ```
51
59
  *
@@ -69,7 +77,7 @@ export interface EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> e
69
77
  * E.whenIsBoolFalsy(() => "falsy"),
70
78
  * );
71
79
  *
72
- * // type: E.EitherBoolTruthy<"value"> | "falsy"
80
+ * // type: E.BoolTruthy<"value"> | "falsy"
73
81
  * ```
74
82
  *
75
83
  * @see https://utils.duplojs.dev/en/v1/api/either/whenIsBoolFalsy
@@ -77,10 +85,10 @@ export interface EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> e
77
85
  * @namespace E
78
86
  *
79
87
  */
80
- export declare function boolFalsy<const GenericValue extends FalsyValue = undefined>(value?: GenericValue): EitherBoolFalsy<GenericValue>;
81
- type Either = EitherRight | EitherLeft;
82
- export declare function isBoolFalsy<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, EitherBoolFalsy>;
88
+ export declare function boolFalsy<const GenericValue extends FalsyValue = undefined>(value?: GenericValue): BoolFalsy<GenericValue>;
89
+ type Either = Right | Left;
90
+ export declare function isBoolFalsy<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, BoolFalsy>;
83
91
  type ToEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof bool<GenericValue>>;
84
- export declare function whenIsBoolFalsy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, EitherBoolFalsy>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<BreakGenericLink<GenericInput>>, EitherBoolFalsy>;
85
- export declare function whenIsBoolFalsy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, EitherBoolFalsy>>) => GenericOutput): GenericOutput | Exclude<ToEither<GenericInput>, EitherBoolFalsy>;
92
+ export declare function whenIsBoolFalsy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, BoolFalsy>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<BreakGenericLink<GenericInput>>, BoolFalsy>;
93
+ export declare function whenIsBoolFalsy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, BoolFalsy>>) => GenericOutput): GenericOutput | Exclude<ToEither<GenericInput>, BoolFalsy>;
86
94
  export {};
@@ -1,12 +1,16 @@
1
1
  import { createEitherKind } from '../kind.mjs';
2
- import { eitherBoolKind } from './base.mjs';
2
+ import { boolKind } from './base.mjs';
3
3
  import { bool } from './create.mjs';
4
4
  import { left } from '../left/create.mjs';
5
5
  import { isLeft } from '../left/is.mjs';
6
6
  import { isRight } from '../right/is.mjs';
7
7
  import { unwrap } from '../../common/unwrap.mjs';
8
8
 
9
- const eitherBoolFalsyKind = createEitherKind("bool-falsy");
9
+ const boolFalsyKind = createEitherKind("bool-falsy");
10
+ /**
11
+ * @deprecated use boolFalsyKind
12
+ */
13
+ const eitherBoolFalsyKind = boolFalsyKind;
10
14
  /**
11
15
  * {@include either/boolFalsy/index.md}
12
16
  */
@@ -17,12 +21,12 @@ const eitherBoolFalsyKind = createEitherKind("bool-falsy");
17
21
  * {@include either/whenIsBoolFalsy/index.md}
18
22
  */
19
23
  function boolFalsy(value = undefined) {
20
- return eitherBoolKind.setTo(eitherBoolFalsyKind.setTo(left("bool", value)));
24
+ return boolKind.setTo(boolFalsyKind.setTo(left("bool", value)));
21
25
  }
22
26
  function isBoolFalsy(input) {
23
27
  return isLeft(input)
24
- && eitherBoolKind.has(input)
25
- && eitherBoolFalsyKind.has(input);
28
+ && boolKind.has(input)
29
+ && boolFalsyKind.has(input);
26
30
  }
27
31
  function whenIsBoolFalsy(...args) {
28
32
  if (args.length === 1) {
@@ -45,4 +49,4 @@ function whenIsBoolFalsy(...args) {
45
49
  return either;
46
50
  }
47
51
 
48
- export { boolFalsy, eitherBoolFalsyKind, isBoolFalsy, whenIsBoolFalsy };
52
+ export { boolFalsy, boolFalsyKind, eitherBoolFalsyKind, isBoolFalsy, whenIsBoolFalsy };