@duplojs/lang 0.0.1-beta.8 → 0.0.1-beta.9
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/chrono/createDate.cjs +1 -1
- package/dist/chrono/createDate.mjs +1 -1
- package/dist/common/constraint/cast/index.d.ts +3 -3
- package/dist/common/constraint/infer/string.d.ts +1 -0
- package/dist/common/types/index.d.ts +1 -0
- package/dist/common/types/isObject.d.ts +8 -0
- package/dist/dataStructure/common/codec/base.cjs +2 -2
- package/dist/dataStructure/common/codec/base.mjs +2 -2
- package/dist/dataStructure/common/error.cjs +4 -2
- package/dist/dataStructure/common/error.d.ts +4 -2
- package/dist/dataStructure/common/error.mjs +4 -2
- package/dist/dataStructure/common/errorInterpreter.cjs +6 -6
- package/dist/dataStructure/common/errorInterpreter.d.ts +7 -3
- package/dist/dataStructure/common/errorInterpreter.mjs +6 -6
- package/dist/dataStructure/constraint/defaults/allowedCharacters.d.ts +1 -3
- package/dist/dataStructure/helpers/index.d.ts +5 -2
- package/dist/dataStructure/helpers/isNullable.cjs +12 -0
- package/dist/dataStructure/helpers/isNullable.d.ts +2 -0
- package/dist/dataStructure/helpers/isNullable.mjs +12 -0
- package/dist/dataStructure/helpers/isOptional.cjs +12 -0
- package/dist/dataStructure/helpers/isOptional.d.ts +2 -0
- package/dist/dataStructure/helpers/isOptional.mjs +12 -0
- package/dist/dataStructure/helpers/unwrapLazy.cjs +9 -0
- package/dist/dataStructure/helpers/unwrapLazy.d.ts +2 -0
- package/dist/dataStructure/helpers/unwrapLazy.mjs +9 -0
- package/dist/dataStructure/index.cjs +11 -2
- package/dist/dataStructure/index.mjs +9 -3
- package/dist/dataStructure/structure/base.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/array.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/lazy.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/object.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/record.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/type.d.ts +1 -1
- package/dist/dataStructure/structure/defaults/union.d.ts +1 -1
- package/dist/either/index.cjs +30 -8
- package/dist/either/index.d.ts +4 -0
- package/dist/either/index.mjs +23 -9
- package/dist/either/left/index.d.ts +3 -2
- package/dist/either/left/none.cjs +15 -0
- package/dist/either/left/none.d.ts +7 -0
- package/dist/either/left/none.mjs +14 -0
- package/dist/either/matchInformationOtherwise.d.ts +1 -1
- package/dist/either/rewriteInformation.cjs +22 -0
- package/dist/either/rewriteInformation.d.ts +14 -0
- package/dist/either/rewriteInformation.mjs +22 -0
- package/dist/either/right/asyncGroup.cjs +2 -2
- package/dist/either/right/asyncGroup.mjs +2 -2
- package/dist/either/right/group.cjs +1 -1
- package/dist/either/right/group.mjs +1 -1
- package/dist/either/right/index.d.ts +6 -5
- package/dist/either/right/some.cjs +15 -0
- package/dist/either/right/some.d.ts +7 -0
- package/dist/either/right/some.mjs +14 -0
- package/dist/either/toMaybe.cjs +12 -0
- package/dist/either/toMaybe.d.ts +5 -0
- package/dist/either/toMaybe.mjs +12 -0
- package/dist/either/types/mayBe.d.ts +3 -0
- package/dist/either/unwrapOr.cjs +14 -0
- package/dist/either/unwrapOr.d.ts +8 -0
- package/dist/either/unwrapOr.mjs +14 -0
- package/dist/either/unwrapOtherwise.cjs +14 -0
- package/dist/either/unwrapOtherwise.d.ts +8 -0
- package/dist/either/unwrapOtherwise.mjs +14 -0
- package/dist/generator/reduce.cjs +2 -1
- package/dist/generator/reduce.mjs +1 -1
- package/dist/invocation/index.cjs +8 -8
- package/dist/invocation/index.d.ts +1 -1
- package/dist/invocation/index.mjs +6 -6
- package/dist/invocation/reader.cjs +26 -0
- package/dist/invocation/reader.d.ts +28 -0
- package/dist/invocation/reader.mjs +25 -0
- package/dist/modeling/entity/base.cjs +19 -2
- package/dist/modeling/entity/base.d.ts +9 -2
- package/dist/modeling/entity/base.mjs +19 -3
- package/dist/modeling/entity/namespace.cjs +1 -1
- package/dist/modeling/entity/namespace.d.ts +1 -1
- package/dist/modeling/entity/namespace.mjs +1 -1
- package/dist/modeling/flag/base.cjs +1 -5
- package/dist/modeling/flag/base.d.ts +6 -7
- package/dist/modeling/flag/base.mjs +1 -5
- package/dist/modeling/index.cjs +6 -0
- package/dist/modeling/index.mjs +7 -4
- package/dist/modeling/newType/base.cjs +21 -3
- package/dist/modeling/newType/base.d.ts +9 -2
- package/dist/modeling/newType/base.mjs +19 -3
- package/dist/modeling/taggedObject/base.cjs +19 -2
- package/dist/modeling/taggedObject/base.d.ts +9 -2
- package/dist/modeling/taggedObject/base.mjs +19 -3
- package/dist/object/types/forbiddenUndefinedProps.d.ts +3 -0
- package/dist/object/types/index.d.ts +2 -1
- package/dist/object/types/split.d.ts +2 -2
- package/dist/pattern/matchWithNumber.d.ts +4 -4
- package/dist/pattern/matchWithNumberOtherwise.d.ts +4 -4
- package/dist/pattern/matchWithString.d.ts +4 -4
- package/dist/pattern/matchWithStringOtherwise.d.ts +4 -4
- package/dist/string/constraints/allowedCharacters.d.ts +3 -3
- package/dist/string/isComposedOf.cjs +0 -1
- package/dist/string/isComposedOf.d.ts +5 -8
- package/dist/string/isComposedOf.mjs +0 -1
- package/dist/string/types/IsAllowedString.d.ts +3 -0
- package/dist/string/types/index.d.ts +1 -0
- package/package.json +2 -2
- package/dist/invocation/useCase.cjs +0 -26
- package/dist/invocation/useCase.d.ts +0 -28
- package/dist/invocation/useCase.mjs +0 -25
|
@@ -7,6 +7,6 @@ export declare const typeStructureKind: DKind.Handler<DKind.Definition<"@Duplojs
|
|
|
7
7
|
export interface TypeStructureDefinition<GenericConstraints extends readonly Constraint[] = readonly Constraint[]> extends StructureDefinition<GenericConstraints> {
|
|
8
8
|
readonly type: Type;
|
|
9
9
|
}
|
|
10
|
-
export interface TypeStructure<GenericType extends unknown = unknown, GenericConstraints extends readonly Constraint<GenericType>[] = readonly Constraint<GenericType>[]> extends DCommon.Forward<Structure<GenericType, TypeStructureDefinition<GenericConstraints>> & DKind.Kind<typeof typeStructureKind>> {
|
|
10
|
+
export interface TypeStructure<out GenericType extends unknown = unknown, out GenericConstraints extends readonly Constraint<GenericType>[] = readonly Constraint<GenericType>[]> extends DCommon.Forward<Structure<GenericType, TypeStructureDefinition<GenericConstraints>> & DKind.Kind<typeof typeStructureKind>> {
|
|
11
11
|
}
|
|
12
12
|
export declare const TypeStructure: <GenericType extends Type, const GenericConstraints extends readonly Constraint<TypeValue<GenericType>>[]>(type: GenericType, constraints: GenericConstraints) => NoInfer<TypeStructure<TypeValue<GenericType>, readonly [...GenericConstraints]>>;
|
|
@@ -7,6 +7,6 @@ export declare const unionStructureKind: DKind.Handler<DKind.Definition<"@Duploj
|
|
|
7
7
|
export interface UnionStructureDefinition<GenericConstraints extends readonly Constraint[] = readonly Constraint[]> extends StructureDefinition<GenericConstraints> {
|
|
8
8
|
readonly values: DCommon.Memoized<DCommon.AnyTuple<Structure>>;
|
|
9
9
|
}
|
|
10
|
-
export interface UnionStructure<GenericValue extends unknown = unknown, GenericConstraints extends readonly Constraint<GenericValue>[] = readonly Constraint<GenericValue>[]> extends DCommon.Forward<Structure<GenericValue, UnionStructureDefinition<GenericConstraints>> & DKind.Kind<typeof unionStructureKind>> {
|
|
10
|
+
export interface UnionStructure<out GenericValue extends unknown = unknown, out GenericConstraints extends readonly Constraint<GenericValue>[] = readonly Constraint<GenericValue>[]> extends DCommon.Forward<Structure<GenericValue, UnionStructureDefinition<GenericConstraints>> & DKind.Kind<typeof unionStructureKind>> {
|
|
11
11
|
}
|
|
12
12
|
export declare const UnionStructure: <GenericValues extends DCommon.AnyTuple<Structure>, const GenericConstraints extends readonly Constraint<StructureValue<GenericValues[number]>>[]>(values: GenericValues, constraints: GenericConstraints) => NoInfer<UnionStructure<StructureValue<GenericValues[number]>, readonly [...GenericConstraints]>>;
|
package/dist/either/index.cjs
CHANGED
|
@@ -4,23 +4,25 @@ const require_create = require("./left/create.cjs");
|
|
|
4
4
|
const require_error = require("./left/error.cjs");
|
|
5
5
|
const require_fail = require("./left/fail.cjs");
|
|
6
6
|
const require_is = require("./left/is.cjs");
|
|
7
|
+
const require_create$1 = require("./right/create.cjs");
|
|
8
|
+
const require_none = require("./left/none.cjs");
|
|
9
|
+
const require_unwrap = require("./left/unwrap.cjs");
|
|
10
|
+
const require_unwrapOrThrow = require("./left/unwrapOrThrow.cjs");
|
|
7
11
|
const require_when = require("./left/when.cjs");
|
|
8
12
|
const require_whenOtherwise = require("./left/whenOtherwise.cjs");
|
|
9
|
-
const
|
|
10
|
-
const require_unwrap = require("./left/unwrap.cjs");
|
|
11
|
-
const require_create$1 = require("./right/create.cjs");
|
|
13
|
+
const require_asyncGroup = require("./right/asyncGroup.cjs");
|
|
12
14
|
const require_success = require("./right/success.cjs");
|
|
13
15
|
const require_is$1 = require("./right/is.cjs");
|
|
14
16
|
const require_asyncPipe = require("./right/asyncPipe.cjs");
|
|
17
|
+
const require_when$1 = require("./right/when.cjs");
|
|
18
|
+
const require_group = require("./right/group.cjs");
|
|
15
19
|
const require_ok = require("./right/ok.cjs");
|
|
16
20
|
const require_pipe = require("./right/pipe.cjs");
|
|
17
|
-
const require_when$1 = require("./right/when.cjs");
|
|
18
|
-
const require_whenOtherwise$1 = require("./right/whenOtherwise.cjs");
|
|
19
21
|
const require_result = require("./right/result.cjs");
|
|
20
|
-
const
|
|
22
|
+
const require_some = require("./right/some.cjs");
|
|
21
23
|
const require_unwrap$1 = require("./right/unwrap.cjs");
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
+
const require_unwrapOrThrow$1 = require("./right/unwrapOrThrow.cjs");
|
|
25
|
+
const require_whenOtherwise$1 = require("./right/whenOtherwise.cjs");
|
|
24
26
|
const require_whenHasInformation = require("./whenHasInformation.cjs");
|
|
25
27
|
const require_whenHasInformationOtherwise = require("./whenHasInformationOtherwise.cjs");
|
|
26
28
|
const require_whenIsSelected = require("./whenIsSelected.cjs");
|
|
@@ -30,12 +32,16 @@ const require_asyncSafeCallback = require("./asyncSafeCallback.cjs");
|
|
|
30
32
|
const require_expect = require("./expect.cjs");
|
|
31
33
|
const require_matchInformation = require("./matchInformation.cjs");
|
|
32
34
|
const require_matchInformationOtherwise = require("./matchInformationOtherwise.cjs");
|
|
35
|
+
const require_rewriteInformation = require("./rewriteInformation.cjs");
|
|
36
|
+
const require_toMaybe = require("./toMaybe.cjs");
|
|
33
37
|
const require_unwrapSelection = require("./unwrapSelection.cjs");
|
|
34
38
|
const require_unwrapSelectionOrThrow = require("./unwrapSelectionOrThrow.cjs");
|
|
35
39
|
const require_forwardAssertsSelection = require("./forwardAssertsSelection.cjs");
|
|
36
40
|
const require_hasInformation = require("./hasInformation.cjs");
|
|
37
41
|
const require_unwrapByInformation = require("./unwrapByInformation.cjs");
|
|
38
42
|
const require_unwrapByInformationOrThrow = require("./unwrapByInformationOrThrow.cjs");
|
|
43
|
+
const require_unwrapOr = require("./unwrapOr.cjs");
|
|
44
|
+
const require_unwrapOtherwise = require("./unwrapOtherwise.cjs");
|
|
39
45
|
const require_keepAsRightByInformation = require("./keepAsRightByInformation.cjs");
|
|
40
46
|
const require_keepAsRightSelection = require("./keepAsRightSelection.cjs");
|
|
41
47
|
//#region scripts/either/index.ts
|
|
@@ -65,21 +71,29 @@ var either_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
65
71
|
leftKind: () => require_create.leftKind,
|
|
66
72
|
matchInformation: () => require_matchInformation.matchInformation,
|
|
67
73
|
matchInformationOtherwise: () => require_matchInformationOtherwise.matchInformationOtherwise,
|
|
74
|
+
none: () => require_none.none,
|
|
75
|
+
noneKind: () => require_none.noneKind,
|
|
68
76
|
ok: () => require_ok.ok,
|
|
69
77
|
okKind: () => require_ok.okKind,
|
|
70
78
|
result: () => require_result.result,
|
|
71
79
|
resultKind: () => require_result.resultKind,
|
|
80
|
+
rewriteInformation: () => require_rewriteInformation.rewriteInformation,
|
|
72
81
|
right: () => require_create$1.right,
|
|
73
82
|
rightAsyncPipe: () => require_asyncPipe.rightAsyncPipe,
|
|
74
83
|
rightKind: () => require_create$1.rightKind,
|
|
75
84
|
rightPipe: () => require_pipe.rightPipe,
|
|
76
85
|
safeCallback: () => require_safeCallback.safeCallback,
|
|
86
|
+
some: () => require_some.some,
|
|
87
|
+
someKind: () => require_some.someKind,
|
|
77
88
|
success: () => require_success.success,
|
|
78
89
|
successKind: () => require_success.successKind,
|
|
90
|
+
toMaybe: () => require_toMaybe.toMaybe,
|
|
79
91
|
unwrapByInformation: () => require_unwrapByInformation.unwrapByInformation,
|
|
80
92
|
unwrapByInformationOrThrow: () => require_unwrapByInformationOrThrow.unwrapByInformationOrThrow,
|
|
81
93
|
unwrapLeft: () => require_unwrap.unwrapLeft,
|
|
82
94
|
unwrapLeftOrThrow: () => require_unwrapOrThrow.unwrapLeftOrThrow,
|
|
95
|
+
unwrapOr: () => require_unwrapOr.unwrapOr,
|
|
96
|
+
unwrapOtherwise: () => require_unwrapOtherwise.unwrapOtherwise,
|
|
83
97
|
unwrapRight: () => require_unwrap$1.unwrapRight,
|
|
84
98
|
unwrapRightOrThrow: () => require_unwrapOrThrow$1.unwrapRightOrThrow,
|
|
85
99
|
unwrapSelection: () => require_unwrapSelection.unwrapSelection,
|
|
@@ -126,21 +140,29 @@ exports.left = require_create.left;
|
|
|
126
140
|
exports.leftKind = require_create.leftKind;
|
|
127
141
|
exports.matchInformation = require_matchInformation.matchInformation;
|
|
128
142
|
exports.matchInformationOtherwise = require_matchInformationOtherwise.matchInformationOtherwise;
|
|
143
|
+
exports.none = require_none.none;
|
|
144
|
+
exports.noneKind = require_none.noneKind;
|
|
129
145
|
exports.ok = require_ok.ok;
|
|
130
146
|
exports.okKind = require_ok.okKind;
|
|
131
147
|
exports.result = require_result.result;
|
|
132
148
|
exports.resultKind = require_result.resultKind;
|
|
149
|
+
exports.rewriteInformation = require_rewriteInformation.rewriteInformation;
|
|
133
150
|
exports.right = require_create$1.right;
|
|
134
151
|
exports.rightAsyncPipe = require_asyncPipe.rightAsyncPipe;
|
|
135
152
|
exports.rightKind = require_create$1.rightKind;
|
|
136
153
|
exports.rightPipe = require_pipe.rightPipe;
|
|
137
154
|
exports.safeCallback = require_safeCallback.safeCallback;
|
|
155
|
+
exports.some = require_some.some;
|
|
156
|
+
exports.someKind = require_some.someKind;
|
|
138
157
|
exports.success = require_success.success;
|
|
139
158
|
exports.successKind = require_success.successKind;
|
|
159
|
+
exports.toMaybe = require_toMaybe.toMaybe;
|
|
140
160
|
exports.unwrapByInformation = require_unwrapByInformation.unwrapByInformation;
|
|
141
161
|
exports.unwrapByInformationOrThrow = require_unwrapByInformationOrThrow.unwrapByInformationOrThrow;
|
|
142
162
|
exports.unwrapLeft = require_unwrap.unwrapLeft;
|
|
143
163
|
exports.unwrapLeftOrThrow = require_unwrapOrThrow.unwrapLeftOrThrow;
|
|
164
|
+
exports.unwrapOr = require_unwrapOr.unwrapOr;
|
|
165
|
+
exports.unwrapOtherwise = require_unwrapOtherwise.unwrapOtherwise;
|
|
144
166
|
exports.unwrapRight = require_unwrap$1.unwrapRight;
|
|
145
167
|
exports.unwrapRightOrThrow = require_unwrapOrThrow$1.unwrapRightOrThrow;
|
|
146
168
|
exports.unwrapSelection = require_unwrapSelection.unwrapSelection;
|
package/dist/either/index.d.ts
CHANGED
|
@@ -11,11 +11,15 @@ export * from './asyncSafeCallback';
|
|
|
11
11
|
export * from './expect';
|
|
12
12
|
export * from './matchInformation';
|
|
13
13
|
export * from './matchInformationOtherwise';
|
|
14
|
+
export * from './rewriteInformation';
|
|
15
|
+
export * from './toMaybe';
|
|
14
16
|
export * from './unwrapSelection';
|
|
15
17
|
export * from './unwrapSelectionOrThrow';
|
|
16
18
|
export * from './forwardAssertsSelection';
|
|
17
19
|
export * from './hasInformation';
|
|
18
20
|
export * from './unwrapByInformation';
|
|
19
21
|
export * from './unwrapByInformationOrThrow';
|
|
22
|
+
export * from './unwrapOr';
|
|
23
|
+
export * from './unwrapOtherwise';
|
|
20
24
|
export * from './keepAsRightByInformation';
|
|
21
25
|
export * from './keepAsRightSelection';
|
package/dist/either/index.mjs
CHANGED
|
@@ -4,23 +4,25 @@ import { left, leftKind } from "./left/create.mjs";
|
|
|
4
4
|
import { error, errorKind } from "./left/error.mjs";
|
|
5
5
|
import { fail, failKind } from "./left/fail.mjs";
|
|
6
6
|
import { isLeft } from "./left/is.mjs";
|
|
7
|
+
import { right, rightKind } from "./right/create.mjs";
|
|
8
|
+
import { none, noneKind } from "./left/none.mjs";
|
|
9
|
+
import { unwrapLeft } from "./left/unwrap.mjs";
|
|
10
|
+
import { NotLeftError, unwrapLeftOrThrow } from "./left/unwrapOrThrow.mjs";
|
|
7
11
|
import { whenIsLeft } from "./left/when.mjs";
|
|
8
12
|
import { whenIsLeftOtherwise } from "./left/whenOtherwise.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import { unwrapLeft } from "./left/unwrap.mjs";
|
|
11
|
-
import { right, rightKind } from "./right/create.mjs";
|
|
13
|
+
import { asyncGroup } from "./right/asyncGroup.mjs";
|
|
12
14
|
import { success, successKind } from "./right/success.mjs";
|
|
13
15
|
import { isRight } from "./right/is.mjs";
|
|
14
16
|
import { rightAsyncPipe } from "./right/asyncPipe.mjs";
|
|
17
|
+
import { whenIsRight } from "./right/when.mjs";
|
|
18
|
+
import { group } from "./right/group.mjs";
|
|
15
19
|
import { ok, okKind } from "./right/ok.mjs";
|
|
16
20
|
import { rightPipe } from "./right/pipe.mjs";
|
|
17
|
-
import { whenIsRight } from "./right/when.mjs";
|
|
18
|
-
import { whenIsRightOtherwise } from "./right/whenOtherwise.mjs";
|
|
19
21
|
import { result, resultKind } from "./right/result.mjs";
|
|
20
|
-
import {
|
|
22
|
+
import { some, someKind } from "./right/some.mjs";
|
|
21
23
|
import { unwrapRight } from "./right/unwrap.mjs";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
+
import { NotRightError, unwrapRightOrThrow } from "./right/unwrapOrThrow.mjs";
|
|
25
|
+
import { whenIsRightOtherwise } from "./right/whenOtherwise.mjs";
|
|
24
26
|
import { whenHasInformation } from "./whenHasInformation.mjs";
|
|
25
27
|
import { whenHasInformationOtherwise } from "./whenHasInformationOtherwise.mjs";
|
|
26
28
|
import { whenIsSelected } from "./whenIsSelected.mjs";
|
|
@@ -30,12 +32,16 @@ import { asyncSafeCallback } from "./asyncSafeCallback.mjs";
|
|
|
30
32
|
import { expect } from "./expect.mjs";
|
|
31
33
|
import { matchInformation } from "./matchInformation.mjs";
|
|
32
34
|
import { matchInformationOtherwise } from "./matchInformationOtherwise.mjs";
|
|
35
|
+
import { rewriteInformation } from "./rewriteInformation.mjs";
|
|
36
|
+
import { toMaybe } from "./toMaybe.mjs";
|
|
33
37
|
import { unwrapSelection } from "./unwrapSelection.mjs";
|
|
34
38
|
import { HasNotSelectedInformationError, unwrapSelectionOrThrow } from "./unwrapSelectionOrThrow.mjs";
|
|
35
39
|
import { ForwardAssertsSelectionError, forwardAssertsSelection } from "./forwardAssertsSelection.mjs";
|
|
36
40
|
import { hasInformation } from "./hasInformation.mjs";
|
|
37
41
|
import { unwrapByInformation } from "./unwrapByInformation.mjs";
|
|
38
42
|
import { HasNotInformationError, unwrapByInformationOrThrow } from "./unwrapByInformationOrThrow.mjs";
|
|
43
|
+
import { unwrapOr } from "./unwrapOr.mjs";
|
|
44
|
+
import { unwrapOtherwise } from "./unwrapOtherwise.mjs";
|
|
39
45
|
import { keepAsRightByInformation } from "./keepAsRightByInformation.mjs";
|
|
40
46
|
import { keepAsRightSelection } from "./keepAsRightSelection.mjs";
|
|
41
47
|
//#region scripts/either/index.ts
|
|
@@ -65,21 +71,29 @@ var either_exports = /* @__PURE__ */ __exportAll({
|
|
|
65
71
|
leftKind: () => leftKind,
|
|
66
72
|
matchInformation: () => matchInformation,
|
|
67
73
|
matchInformationOtherwise: () => matchInformationOtherwise,
|
|
74
|
+
none: () => none,
|
|
75
|
+
noneKind: () => noneKind,
|
|
68
76
|
ok: () => ok,
|
|
69
77
|
okKind: () => okKind,
|
|
70
78
|
result: () => result,
|
|
71
79
|
resultKind: () => resultKind,
|
|
80
|
+
rewriteInformation: () => rewriteInformation,
|
|
72
81
|
right: () => right,
|
|
73
82
|
rightAsyncPipe: () => rightAsyncPipe,
|
|
74
83
|
rightKind: () => rightKind,
|
|
75
84
|
rightPipe: () => rightPipe,
|
|
76
85
|
safeCallback: () => safeCallback,
|
|
86
|
+
some: () => some,
|
|
87
|
+
someKind: () => someKind,
|
|
77
88
|
success: () => success,
|
|
78
89
|
successKind: () => successKind,
|
|
90
|
+
toMaybe: () => toMaybe,
|
|
79
91
|
unwrapByInformation: () => unwrapByInformation,
|
|
80
92
|
unwrapByInformationOrThrow: () => unwrapByInformationOrThrow,
|
|
81
93
|
unwrapLeft: () => unwrapLeft,
|
|
82
94
|
unwrapLeftOrThrow: () => unwrapLeftOrThrow,
|
|
95
|
+
unwrapOr: () => unwrapOr,
|
|
96
|
+
unwrapOtherwise: () => unwrapOtherwise,
|
|
83
97
|
unwrapRight: () => unwrapRight,
|
|
84
98
|
unwrapRightOrThrow: () => unwrapRightOrThrow,
|
|
85
99
|
unwrapSelection: () => unwrapSelection,
|
|
@@ -95,4 +109,4 @@ var either_exports = /* @__PURE__ */ __exportAll({
|
|
|
95
109
|
whenIsSelectedOtherwise: () => whenIsSelectedOtherwise
|
|
96
110
|
});
|
|
97
111
|
//#endregion
|
|
98
|
-
export { ForwardAssertsSelectionError, HasNotInformationError, HasNotSelectedInformationError, NotLeftError, NotRightError, asyncGroup, asyncSafeCallback, createKind, either_exports, error, errorKind, expect, fail, failKind, forwardAssertsSelection, group, hasInformation, informationKind, isLeft, isRight, keepAsRightByInformation, keepAsRightSelection, left, leftKind, matchInformation, matchInformationOtherwise, ok, okKind, result, resultKind, right, rightAsyncPipe, rightKind, rightPipe, safeCallback, success, successKind, unwrapByInformation, unwrapByInformationOrThrow, unwrapLeft, unwrapLeftOrThrow, unwrapRight, unwrapRightOrThrow, unwrapSelection, unwrapSelectionOrThrow, valueKind, whenHasInformation, whenHasInformationOtherwise, whenIsLeft, whenIsLeftOtherwise, whenIsRight, whenIsRightOtherwise, whenIsSelected, whenIsSelectedOtherwise };
|
|
112
|
+
export { ForwardAssertsSelectionError, HasNotInformationError, HasNotSelectedInformationError, NotLeftError, NotRightError, asyncGroup, asyncSafeCallback, createKind, either_exports, error, errorKind, expect, fail, failKind, forwardAssertsSelection, group, hasInformation, informationKind, isLeft, isRight, keepAsRightByInformation, keepAsRightSelection, left, leftKind, matchInformation, matchInformationOtherwise, none, noneKind, ok, okKind, result, resultKind, rewriteInformation, right, rightAsyncPipe, rightKind, rightPipe, safeCallback, some, someKind, success, successKind, toMaybe, unwrapByInformation, unwrapByInformationOrThrow, unwrapLeft, unwrapLeftOrThrow, unwrapOr, unwrapOtherwise, unwrapRight, unwrapRightOrThrow, unwrapSelection, unwrapSelectionOrThrow, valueKind, whenHasInformation, whenHasInformationOtherwise, whenIsLeft, whenIsLeftOtherwise, whenIsRight, whenIsRightOtherwise, whenIsSelected, whenIsSelectedOtherwise };
|
|
@@ -2,7 +2,8 @@ export * from './create';
|
|
|
2
2
|
export * from './error';
|
|
3
3
|
export * from './fail';
|
|
4
4
|
export * from './is';
|
|
5
|
+
export * from './none';
|
|
6
|
+
export * from './unwrap';
|
|
7
|
+
export * from './unwrapOrThrow';
|
|
5
8
|
export * from './when';
|
|
6
9
|
export * from './whenOtherwise';
|
|
7
|
-
export * from './unwrapOrThrow';
|
|
8
|
-
export * from './unwrap';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const require_kind = require("../kind.cjs");
|
|
2
|
+
const require_create = require("../right/create.cjs");
|
|
3
|
+
//#region scripts/either/left/none.ts
|
|
4
|
+
const noneKind = require_kind.createKind("none");
|
|
5
|
+
function none() {
|
|
6
|
+
return {
|
|
7
|
+
[require_create.rightKind.runTimeKey]: null,
|
|
8
|
+
[require_kind.informationKind.runTimeKey]: "none",
|
|
9
|
+
[require_kind.valueKind.runTimeKey]: null,
|
|
10
|
+
[noneKind.runTimeKey]: null
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.none = none;
|
|
15
|
+
exports.noneKind = noneKind;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Right } from '../right/create';
|
|
2
|
+
import type * as DKind from '../../kind';
|
|
3
|
+
import type * as DCommon from '../../common';
|
|
4
|
+
export declare const noneKind: DKind.Handler<DKind.Definition<"@DuplojsLangEither/none", unknown>>;
|
|
5
|
+
export interface None extends DCommon.Forward<DKind.Kind<typeof noneKind> & Right<"none", null>> {
|
|
6
|
+
}
|
|
7
|
+
export declare function none(): None;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createKind, informationKind, valueKind } from "../kind.mjs";
|
|
2
|
+
import { rightKind } from "../right/create.mjs";
|
|
3
|
+
//#region scripts/either/left/none.ts
|
|
4
|
+
const noneKind = createKind("none");
|
|
5
|
+
function none() {
|
|
6
|
+
return {
|
|
7
|
+
[rightKind.runTimeKey]: null,
|
|
8
|
+
[informationKind.runTimeKey]: "none",
|
|
9
|
+
[valueKind.runTimeKey]: null,
|
|
10
|
+
[noneKind.runTimeKey]: null
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { none, noneKind };
|
|
@@ -11,5 +11,5 @@ type ComputeMatcher<GenericEither extends Either> = Extract<{
|
|
|
11
11
|
}, any>;
|
|
12
12
|
type ForbiddenMoreKey<GenericInput extends unknown, GenericMatcher extends ComputeMatcher<Extract<GenericInput, Either>>> = DObject.ForbiddenKey<GenericMatcher, Extract<Exclude<keyof GenericMatcher, GetInformation<Extract<GenericInput, Either>>>, string>>;
|
|
13
13
|
export declare function matchInformationOtherwise<GenericInput extends unknown, GenericMatcher extends ComputeMatcher<Extract<GenericInput, Either>>, GenericOutput extends unknown, GenericError extends ForbiddenMoreKey<GenericInput, GenericMatcher>>(matcher: (ComputeMatcher<Extract<NoInfer<GenericInput>, Either>> & GenericMatcher & NoInfer<GenericError>), otherwise: (value: Exclude<GenericInput, DKind.Kind<typeof informationKind, Extract<DObject.GetPropsWithValueExtends<GenericMatcher, DCommon.AnyFunction>, string>>>) => GenericOutput): (input: GenericInput) => (ReturnType<NoInfer<Extract<GenericMatcher[keyof GenericMatcher], DCommon.AnyFunction>>> | GenericOutput);
|
|
14
|
-
export declare function matchInformationOtherwise<GenericInput extends unknown, GenericMatcher extends ComputeMatcher<Extract<GenericInput, Either>>, GenericOutput extends unknown>(input: GenericInput, matcher: DCommon.FixDeepFunctionInfer<ComputeMatcher<Extract<GenericInput, Either>>, GenericMatcher> & ForbiddenMoreKey<GenericInput, GenericMatcher
|
|
14
|
+
export declare function matchInformationOtherwise<GenericInput extends unknown, GenericMatcher extends ComputeMatcher<Extract<GenericInput, Either>>, GenericOutput extends unknown>(input: GenericInput, matcher: (DCommon.FixDeepFunctionInfer<ComputeMatcher<Extract<GenericInput, Either>>, GenericMatcher> & ForbiddenMoreKey<GenericInput, GenericMatcher> & DObject.ForbiddenUndefinedProps<GenericMatcher>), otherwise: (value: Exclude<GenericInput, DKind.Kind<typeof informationKind, Extract<DObject.GetPropsWithValueExtends<GenericMatcher, DCommon.AnyFunction>, string>>>) => GenericOutput): (ReturnType<NoInfer<Extract<GenericMatcher[keyof GenericMatcher], DCommon.AnyFunction>>> | GenericOutput);
|
|
15
15
|
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const require_kind = require("./kind.cjs");
|
|
2
|
+
const require_create = require("./left/create.cjs");
|
|
3
|
+
const require_is = require("./left/is.cjs");
|
|
4
|
+
const require_create$1 = require("./right/create.cjs");
|
|
5
|
+
const require_is$1 = require("./right/is.cjs");
|
|
6
|
+
//#region scripts/either/rewriteInformation.ts
|
|
7
|
+
function rewriteInformation(...args) {
|
|
8
|
+
if (args.length === 1) {
|
|
9
|
+
const [matcher] = args;
|
|
10
|
+
return (input) => rewriteInformation(input, matcher);
|
|
11
|
+
}
|
|
12
|
+
const [input, matcher] = args;
|
|
13
|
+
const inputIsRight = require_is$1.isRight(input);
|
|
14
|
+
if (!inputIsRight && !require_is.isLeft(input)) return input;
|
|
15
|
+
const information = matcher[require_kind.informationKind.getValue(input)];
|
|
16
|
+
if (information === void 0) return input;
|
|
17
|
+
const value = require_kind.valueKind.getValue(input);
|
|
18
|
+
if (inputIsRight) return require_create$1.right(information, value);
|
|
19
|
+
return require_create.left(information, value);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.rewriteInformation = rewriteInformation;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Left } from './left';
|
|
2
|
+
import { Right } from './right';
|
|
3
|
+
import { GetInformation, GetValue } from './types';
|
|
4
|
+
import type * as DCommon from '../common';
|
|
5
|
+
import type * as DObject from '../object';
|
|
6
|
+
type Either = Right | Left;
|
|
7
|
+
type ComputeMatcher<GenericInput extends unknown> = {
|
|
8
|
+
[Prop in GetInformation<Extract<GenericInput, Either>>]?: string;
|
|
9
|
+
};
|
|
10
|
+
type ForbiddenMoreKey<GenericInput extends unknown, GenericMatcher extends ComputeMatcher<GenericInput>> = DObject.ForbiddenKey<GenericMatcher, Extract<Exclude<keyof GenericMatcher, GetInformation<Extract<GenericInput, Either>>>, string>>;
|
|
11
|
+
type ComputeResult<GenericInput extends unknown, GenericMatcher extends ComputeMatcher<GenericInput>> = GenericInput extends Right ? GetInformation<GenericInput> extends keyof GenericMatcher ? Right<Extract<GenericMatcher[GetInformation<GenericInput>], string>, GetValue<GenericInput>> : GenericInput : GenericInput extends Left ? GetInformation<GenericInput> extends keyof GenericMatcher ? Left<Extract<GenericMatcher[GetInformation<GenericInput>], string>, GetValue<GenericInput>> : GenericInput : GenericInput;
|
|
12
|
+
export declare function rewriteInformation<GenericInput extends Either | DCommon.AnyValue, const GenericMatcher extends ComputeMatcher<GenericInput>>(matcher: (GenericMatcher & ForbiddenMoreKey<GenericInput, GenericMatcher> & DObject.ForbiddenUndefinedProps<GenericMatcher>)): (input: GenericInput) => ComputeResult<GenericInput, GenericMatcher>;
|
|
13
|
+
export declare function rewriteInformation<GenericInput extends Either | DCommon.AnyValue, const GenericMatcher extends ComputeMatcher<GenericInput>>(input: GenericInput, matcher: (GenericMatcher & ForbiddenMoreKey<GenericInput, GenericMatcher> & DObject.ForbiddenUndefinedProps<GenericMatcher>)): ComputeResult<GenericInput, GenericMatcher>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { informationKind, valueKind } from "./kind.mjs";
|
|
2
|
+
import { left } from "./left/create.mjs";
|
|
3
|
+
import { isLeft } from "./left/is.mjs";
|
|
4
|
+
import { right } from "./right/create.mjs";
|
|
5
|
+
import { isRight } from "./right/is.mjs";
|
|
6
|
+
//#region scripts/either/rewriteInformation.ts
|
|
7
|
+
function rewriteInformation(...args) {
|
|
8
|
+
if (args.length === 1) {
|
|
9
|
+
const [matcher] = args;
|
|
10
|
+
return (input) => rewriteInformation(input, matcher);
|
|
11
|
+
}
|
|
12
|
+
const [input, matcher] = args;
|
|
13
|
+
const inputIsRight = isRight(input);
|
|
14
|
+
if (!inputIsRight && !isLeft(input)) return input;
|
|
15
|
+
const information = matcher[informationKind.getValue(input)];
|
|
16
|
+
if (information === void 0) return input;
|
|
17
|
+
const value = valueKind.getValue(input);
|
|
18
|
+
if (inputIsRight) return right(information, value);
|
|
19
|
+
return left(information, value);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { rewriteInformation };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_asyncPipe = require("../../common/asyncPipe.cjs");
|
|
2
2
|
const require_entries = require("../../object/entries.cjs");
|
|
3
3
|
const require_is = require("../left/is.cjs");
|
|
4
|
-
const require_success = require("./success.cjs");
|
|
5
|
-
const require_when = require("./when.cjs");
|
|
6
4
|
const require_reduce = require("../../generator/reduce.cjs");
|
|
7
5
|
const require_asyncReduce = require("../../generator/asyncReduce.cjs");
|
|
6
|
+
const require_success = require("./success.cjs");
|
|
7
|
+
const require_when = require("./when.cjs");
|
|
8
8
|
const require_isType = require("../../common/isType.cjs");
|
|
9
9
|
const require_when$1 = require("../../common/when.cjs");
|
|
10
10
|
const require_whenNot = require("../../common/whenNot.cjs");
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { asyncPipe } from "../../common/asyncPipe.mjs";
|
|
2
2
|
import { entries } from "../../object/entries.mjs";
|
|
3
3
|
import { isLeft } from "../left/is.mjs";
|
|
4
|
-
import { success } from "./success.mjs";
|
|
5
|
-
import { whenIsRight } from "./when.mjs";
|
|
6
4
|
import { reduceFrom } from "../../generator/reduce.mjs";
|
|
7
5
|
import { asyncReduce } from "../../generator/asyncReduce.mjs";
|
|
6
|
+
import { success } from "./success.mjs";
|
|
7
|
+
import { whenIsRight } from "./when.mjs";
|
|
8
8
|
import { isType } from "../../common/isType.mjs";
|
|
9
9
|
import { when } from "../../common/when.mjs";
|
|
10
10
|
import { whenNot } from "../../common/whenNot.mjs";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_entries = require("../../object/entries.cjs");
|
|
2
2
|
const require_is = require("../left/is.cjs");
|
|
3
|
+
const require_reduce = require("../../array/reduce.cjs");
|
|
3
4
|
const require_success = require("./success.cjs");
|
|
4
5
|
const require_when = require("./when.cjs");
|
|
5
|
-
const require_reduce = require("../../array/reduce.cjs");
|
|
6
6
|
const require_isType = require("../../common/isType.cjs");
|
|
7
7
|
const require_pipe = require("../../common/pipe.cjs");
|
|
8
8
|
const require_when$1 = require("../../common/when.cjs");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { entries } from "../../object/entries.mjs";
|
|
2
2
|
import { isLeft } from "../left/is.mjs";
|
|
3
|
+
import { reduce, reduceFrom } from "../../array/reduce.mjs";
|
|
3
4
|
import { success } from "./success.mjs";
|
|
4
5
|
import { whenIsRight } from "./when.mjs";
|
|
5
|
-
import { reduce, reduceFrom } from "../../array/reduce.mjs";
|
|
6
6
|
import { isType } from "../../common/isType.mjs";
|
|
7
7
|
import { pipe } from "../../common/pipe.mjs";
|
|
8
8
|
import { when } from "../../common/when.mjs";
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
export * from './asyncGroup';
|
|
1
2
|
export * from './asyncPipe';
|
|
2
3
|
export * from './create';
|
|
4
|
+
export * from './group';
|
|
3
5
|
export * from './is';
|
|
4
6
|
export * from './ok';
|
|
5
7
|
export * from './pipe';
|
|
8
|
+
export * from './result';
|
|
9
|
+
export * from './some';
|
|
6
10
|
export * from './success';
|
|
11
|
+
export * from './unwrap';
|
|
12
|
+
export * from './unwrapOrThrow';
|
|
7
13
|
export * from './when';
|
|
8
14
|
export * from './whenOtherwise';
|
|
9
|
-
export * from './result';
|
|
10
|
-
export * from './unwrapOrThrow';
|
|
11
|
-
export * from './unwrap';
|
|
12
|
-
export * from './group';
|
|
13
|
-
export * from './asyncGroup';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const require_kind = require("../kind.cjs");
|
|
2
|
+
const require_create = require("./create.cjs");
|
|
3
|
+
//#region scripts/either/right/some.ts
|
|
4
|
+
const someKind = require_kind.createKind("some");
|
|
5
|
+
function some(value) {
|
|
6
|
+
return {
|
|
7
|
+
[require_create.rightKind.runTimeKey]: null,
|
|
8
|
+
[require_kind.informationKind.runTimeKey]: "some",
|
|
9
|
+
[require_kind.valueKind.runTimeKey]: value,
|
|
10
|
+
[someKind.runTimeKey]: null
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.some = some;
|
|
15
|
+
exports.someKind = someKind;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Right } from './create';
|
|
2
|
+
import type * as DKind from '../../kind';
|
|
3
|
+
import type * as DCommon from '../../common';
|
|
4
|
+
export declare const someKind: DKind.Handler<DKind.Definition<"@DuplojsLangEither/some", unknown>>;
|
|
5
|
+
export interface Some<GenericValue extends unknown> extends DCommon.Forward<DKind.Kind<typeof someKind> & Right<"some", GenericValue>> {
|
|
6
|
+
}
|
|
7
|
+
export declare function some<GenericValue extends unknown>(value: GenericValue): Some<GenericValue>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createKind, informationKind, valueKind } from "../kind.mjs";
|
|
2
|
+
import { rightKind } from "./create.mjs";
|
|
3
|
+
//#region scripts/either/right/some.ts
|
|
4
|
+
const someKind = createKind("some");
|
|
5
|
+
function some(value) {
|
|
6
|
+
return {
|
|
7
|
+
[rightKind.runTimeKey]: null,
|
|
8
|
+
[informationKind.runTimeKey]: "some",
|
|
9
|
+
[valueKind.runTimeKey]: value,
|
|
10
|
+
[someKind.runTimeKey]: null
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { some, someKind };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const require_is = require("./left/is.cjs");
|
|
2
|
+
const require_none = require("./left/none.cjs");
|
|
3
|
+
const require_is$1 = require("./right/is.cjs");
|
|
4
|
+
const require_some = require("./right/some.cjs");
|
|
5
|
+
//#region scripts/either/toMaybe.ts
|
|
6
|
+
function toMaybe(input) {
|
|
7
|
+
if (require_is$1.isRight(input) || require_is.isLeft(input)) return input;
|
|
8
|
+
if (input === null || input === void 0) return require_none.none();
|
|
9
|
+
return require_some.some(input);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.toMaybe = toMaybe;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Left, None } from './left';
|
|
2
|
+
import { Some, Right } from './right';
|
|
3
|
+
type Either = Right | Left;
|
|
4
|
+
export declare function toMaybe<GenericInput extends unknown>(input: GenericInput): (GenericInput extends Either ? GenericInput : GenericInput extends null | undefined ? None : Some<GenericInput>);
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isLeft } from "./left/is.mjs";
|
|
2
|
+
import { none } from "./left/none.mjs";
|
|
3
|
+
import { isRight } from "./right/is.mjs";
|
|
4
|
+
import { some } from "./right/some.mjs";
|
|
5
|
+
//#region scripts/either/toMaybe.ts
|
|
6
|
+
function toMaybe(input) {
|
|
7
|
+
if (isRight(input) || isLeft(input)) return input;
|
|
8
|
+
if (input === null || input === void 0) return none();
|
|
9
|
+
return some(input);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { toMaybe };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const require_kind = require("./kind.cjs");
|
|
2
|
+
const require_is = require("./right/is.cjs");
|
|
3
|
+
//#region scripts/either/unwrapOr.ts
|
|
4
|
+
function unwrapOr(...args) {
|
|
5
|
+
if (args.length === 1) {
|
|
6
|
+
const [value] = args;
|
|
7
|
+
return (input) => unwrapOr(input, value);
|
|
8
|
+
}
|
|
9
|
+
const [input, value] = args;
|
|
10
|
+
if (require_is.isRight(input)) return require_kind.valueKind.getValue(input);
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.unwrapOr = unwrapOr;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Left } from './left';
|
|
2
|
+
import { Right } from './right';
|
|
3
|
+
import { GetValue } from './types';
|
|
4
|
+
import type * as DCommon from '../common';
|
|
5
|
+
type Either = Right | Left;
|
|
6
|
+
export declare function unwrapOr<GenericInput extends Either | DCommon.AnyValue, const GenericValue extends unknown>(input: GenericInput, value: GenericValue): (GetValue<Extract<GenericInput, Right>> | GenericValue);
|
|
7
|
+
export declare function unwrapOr<GenericInput extends Either | DCommon.AnyValue, const GenericValue extends unknown>(value: GenericValue): (input: GenericInput) => (GetValue<Extract<GenericInput, Right>> | GenericValue);
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { valueKind } from "./kind.mjs";
|
|
2
|
+
import { isRight } from "./right/is.mjs";
|
|
3
|
+
//#region scripts/either/unwrapOr.ts
|
|
4
|
+
function unwrapOr(...args) {
|
|
5
|
+
if (args.length === 1) {
|
|
6
|
+
const [value] = args;
|
|
7
|
+
return (input) => unwrapOr(input, value);
|
|
8
|
+
}
|
|
9
|
+
const [input, value] = args;
|
|
10
|
+
if (isRight(input)) return valueKind.getValue(input);
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { unwrapOr };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const require_kind = require("./kind.cjs");
|
|
2
|
+
const require_is = require("./right/is.cjs");
|
|
3
|
+
//#region scripts/either/unwrapOtherwise.ts
|
|
4
|
+
function unwrapOtherwise(...args) {
|
|
5
|
+
if (args.length === 1) {
|
|
6
|
+
const [value] = args;
|
|
7
|
+
return (input) => unwrapOtherwise(input, value);
|
|
8
|
+
}
|
|
9
|
+
const [input, value] = args;
|
|
10
|
+
if (require_is.isRight(input)) return require_kind.valueKind.getValue(input);
|
|
11
|
+
return value();
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.unwrapOtherwise = unwrapOtherwise;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Left } from './left';
|
|
2
|
+
import { Right } from './right';
|
|
3
|
+
import { GetValue } from './types';
|
|
4
|
+
import type * as DCommon from '../common';
|
|
5
|
+
type Either = Right | Left;
|
|
6
|
+
export declare function unwrapOtherwise<GenericInput extends Either | DCommon.AnyValue, const GenericValue extends unknown>(input: GenericInput, value: () => GenericValue): (GetValue<Extract<GenericInput, Right>> | GenericValue);
|
|
7
|
+
export declare function unwrapOtherwise<GenericInput extends Either | DCommon.AnyValue, const GenericValue extends unknown>(value: () => GenericValue): (input: GenericInput) => (GetValue<Extract<GenericInput, Right>> | GenericValue);
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { valueKind } from "./kind.mjs";
|
|
2
|
+
import { isRight } from "./right/is.mjs";
|
|
3
|
+
//#region scripts/either/unwrapOtherwise.ts
|
|
4
|
+
function unwrapOtherwise(...args) {
|
|
5
|
+
if (args.length === 1) {
|
|
6
|
+
const [value] = args;
|
|
7
|
+
return (input) => unwrapOtherwise(input, value);
|
|
8
|
+
}
|
|
9
|
+
const [input, value] = args;
|
|
10
|
+
if (isRight(input)) return valueKind.getValue(input);
|
|
11
|
+
return value();
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { unwrapOtherwise };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
const require_kind = require("./kind.cjs");
|
|
1
2
|
const require_reduce = require("../array/reduce.cjs");
|
|
2
3
|
//#region scripts/generator/reduce.ts
|
|
3
|
-
const reduceKind =
|
|
4
|
+
const reduceKind = require_kind.createKind("reduce");
|
|
4
5
|
function reduceFrom(value) {
|
|
5
6
|
return { [reduceKind.runTimeKey]: value };
|
|
6
7
|
}
|