@duplojs/utils 1.4.44 → 1.4.46
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/clean/constraint/base.d.ts +5 -5
- package/dist/clean/constraint/defaultConstraint/number.d.ts +3 -3
- package/dist/clean/constraint/defaultConstraint/string.d.ts +2 -2
- package/dist/clean/entity.d.ts +2 -2
- package/dist/clean/flag.d.ts +1 -1
- package/dist/clean/newType.d.ts +5 -5
- package/dist/clean/primitive/base.d.ts +10 -10
- package/dist/clean/repository.d.ts +1 -1
- package/dist/clean/useCase.d.ts +1 -1
- package/dist/common/hasKinds.d.ts +3 -3
- package/dist/common/hasSomeKinds.d.ts +3 -3
- package/dist/common/path/resolveFrom.d.ts +1 -1
- package/dist/dataParser/base.d.ts +2 -2
- package/dist/dataParser/baseExtended.d.ts +2 -2
- package/dist/dataParser/extended/empty.d.ts +1 -1
- package/dist/dataParser/extended/nullable.d.ts +1 -1
- package/dist/dataParser/extended/optional.d.ts +1 -1
- package/dist/dataParser/extended/recover.d.ts +1 -1
- package/dist/dataParser/parsers/array/index.d.ts +1 -1
- package/dist/dataParser/parsers/empty.d.ts +1 -1
- package/dist/dataParser/parsers/lazy.d.ts +1 -1
- package/dist/dataParser/parsers/literal.d.ts +1 -1
- package/dist/dataParser/parsers/nullable.d.ts +2 -2
- package/dist/dataParser/parsers/object/index.d.ts +3 -3
- package/dist/dataParser/parsers/optional.d.ts +3 -3
- package/dist/dataParser/parsers/pipe.d.ts +1 -1
- package/dist/dataParser/parsers/record/index.d.ts +1 -1
- package/dist/dataParser/parsers/recover.d.ts +3 -3
- package/dist/dataParser/parsers/templateLiteral/index.d.ts +1 -1
- package/dist/dataParser/parsers/transform.d.ts +1 -1
- package/dist/dataParser/parsers/tuple.d.ts +1 -1
- package/dist/dataParser/parsers/union.d.ts +1 -1
- package/dist/date/create.d.ts +1 -1
- package/dist/date/createTime.d.ts +1 -1
- package/dist/either/bool/base.cjs +6 -1
- package/dist/either/bool/base.d.ts +4 -0
- package/dist/either/bool/base.mjs +6 -2
- package/dist/either/bool/create.d.ts +6 -6
- package/dist/either/bool/falsy.cjs +9 -4
- package/dist/either/bool/falsy.d.ts +23 -15
- package/dist/either/bool/falsy.mjs +10 -6
- package/dist/either/bool/truthy.cjs +9 -4
- package/dist/either/bool/truthy.d.ts +23 -15
- package/dist/either/bool/truthy.mjs +10 -6
- package/dist/either/future/base.cjs +6 -1
- package/dist/either/future/base.d.ts +4 -0
- package/dist/either/future/base.mjs +6 -2
- package/dist/either/future/create.d.ts +8 -8
- package/dist/either/future/error.cjs +7 -2
- package/dist/either/future/error.d.ts +15 -7
- package/dist/either/future/error.mjs +8 -4
- package/dist/either/future/success.cjs +7 -2
- package/dist/either/future/success.d.ts +15 -7
- package/dist/either/future/success.mjs +8 -4
- package/dist/either/hasInformation.cjs +2 -2
- package/dist/either/hasInformation.d.ts +8 -8
- package/dist/either/hasInformation.mjs +3 -3
- package/dist/either/index.cjs +24 -0
- package/dist/either/index.mjs +23 -23
- package/dist/either/kind.cjs +6 -1
- package/dist/either/kind.d.ts +4 -0
- package/dist/either/kind.mjs +6 -2
- package/dist/either/left/create.cjs +7 -2
- package/dist/either/left/create.d.ts +14 -6
- package/dist/either/left/create.mjs +8 -4
- package/dist/either/left/error.cjs +7 -2
- package/dist/either/left/error.d.ts +14 -6
- package/dist/either/left/error.mjs +7 -3
- package/dist/either/left/fail.cjs +7 -2
- package/dist/either/left/fail.d.ts +14 -6
- package/dist/either/left/fail.mjs +7 -3
- package/dist/either/left/is.cjs +2 -2
- package/dist/either/left/is.d.ts +4 -4
- package/dist/either/left/is.mjs +4 -4
- package/dist/either/left/when.d.ts +4 -4
- package/dist/either/nullable/base.cjs +6 -1
- package/dist/either/nullable/base.d.ts +4 -0
- package/dist/either/nullable/base.mjs +6 -2
- package/dist/either/nullable/create.d.ts +5 -5
- package/dist/either/nullable/empty.cjs +9 -4
- package/dist/either/nullable/empty.d.ts +23 -15
- package/dist/either/nullable/empty.mjs +10 -6
- package/dist/either/nullable/filled.cjs +9 -4
- package/dist/either/nullable/filled.d.ts +22 -14
- package/dist/either/nullable/filled.mjs +10 -6
- package/dist/either/nullish/base.cjs +6 -1
- package/dist/either/nullish/base.d.ts +4 -0
- package/dist/either/nullish/base.mjs +6 -2
- package/dist/either/nullish/create.d.ts +5 -5
- package/dist/either/nullish/empty.cjs +9 -4
- package/dist/either/nullish/empty.d.ts +23 -15
- package/dist/either/nullish/empty.mjs +10 -6
- package/dist/either/nullish/filled.cjs +9 -4
- package/dist/either/nullish/filled.d.ts +23 -15
- package/dist/either/nullish/filled.mjs +10 -6
- package/dist/either/optional/base.cjs +6 -1
- package/dist/either/optional/base.d.ts +4 -0
- package/dist/either/optional/base.mjs +6 -2
- package/dist/either/optional/create.d.ts +5 -5
- package/dist/either/optional/empty.cjs +9 -4
- package/dist/either/optional/empty.d.ts +23 -15
- package/dist/either/optional/empty.mjs +10 -6
- package/dist/either/optional/filled.cjs +9 -4
- package/dist/either/optional/filled.d.ts +22 -14
- package/dist/either/optional/filled.mjs +10 -6
- package/dist/either/right/asyncGroup.d.ts +7 -7
- package/dist/either/right/asyncPipe.d.ts +33 -25
- package/dist/either/right/create.cjs +7 -2
- package/dist/either/right/create.d.ts +15 -7
- package/dist/either/right/create.mjs +8 -4
- package/dist/either/right/group.d.ts +8 -8
- package/dist/either/right/is.cjs +2 -2
- package/dist/either/right/is.d.ts +4 -4
- package/dist/either/right/is.mjs +4 -4
- package/dist/either/right/ok.cjs +7 -2
- package/dist/either/right/ok.d.ts +14 -6
- package/dist/either/right/ok.mjs +7 -3
- package/dist/either/right/pipe.d.ts +32 -24
- package/dist/either/right/success.cjs +7 -2
- package/dist/either/right/success.d.ts +14 -6
- package/dist/either/right/success.mjs +7 -3
- package/dist/either/right/when.d.ts +4 -4
- package/dist/either/safeCallback.cjs +14 -4
- package/dist/either/safeCallback.d.ts +33 -17
- package/dist/either/safeCallback.mjs +13 -5
- package/dist/either/whenHasInformation.cjs +1 -1
- package/dist/either/whenHasInformation.d.ts +7 -7
- package/dist/either/whenHasInformation.mjs +2 -2
- package/dist/string/isIn.d.ts +2 -2
- package/dist/string/slice.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
1
|
+
import { type Right } from "../right";
|
|
2
|
+
import { type Left } from "../left";
|
|
3
3
|
import { nullish } from "./create";
|
|
4
4
|
import { type Kind } from "../../common/kind";
|
|
5
5
|
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
6
|
-
import {
|
|
6
|
+
import { nullishKind } from "./base";
|
|
7
|
+
export declare const nullishFilledKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/nullish-filled", unknown>>;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use nullishFilledKind
|
|
10
|
+
*/
|
|
7
11
|
export declare const eitherNullishFilledKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/nullish-filled", unknown>>;
|
|
8
|
-
type
|
|
9
|
-
export interface
|
|
12
|
+
type _NullishFilled<GenericValue extends unknown = unknown> = (Right<"nullish", GenericValue> & Kind<typeof nullishKind.definition> & Kind<typeof nullishFilledKind.definition>);
|
|
13
|
+
export interface NullishFilled<GenericValue extends unknown = unknown> extends _NullishFilled<GenericValue> {
|
|
10
14
|
}
|
|
11
15
|
/**
|
|
12
|
-
*
|
|
16
|
+
* @deprecated use NullishFilled
|
|
17
|
+
*/
|
|
18
|
+
export type EitherNullishFilled<GenericValue extends unknown = unknown> = NullishFilled<GenericValue>;
|
|
19
|
+
/**
|
|
20
|
+
* Type guard that detects an NullishFilled.
|
|
13
21
|
*
|
|
14
22
|
* Signature: `isNullishFilled(input)` → returns a value
|
|
15
23
|
*
|
|
@@ -19,7 +27,7 @@ export interface EitherNullishFilled<GenericValue extends unknown = unknown> ext
|
|
|
19
27
|
* const maybeValue = E.nullish(true ? "value" : null);
|
|
20
28
|
*
|
|
21
29
|
* if (E.isNullishFilled(maybeValue)) {
|
|
22
|
-
* // type: E.
|
|
30
|
+
* // type: E.NullishFilled<"value">
|
|
23
31
|
* }
|
|
24
32
|
* ```
|
|
25
33
|
*
|
|
@@ -29,7 +37,7 @@ export interface EitherNullishFilled<GenericValue extends unknown = unknown> ext
|
|
|
29
37
|
*
|
|
30
38
|
*/
|
|
31
39
|
/**
|
|
32
|
-
* Builds an
|
|
40
|
+
* Builds an Right<"nullish"> with a non-null/non-undefined value.
|
|
33
41
|
*
|
|
34
42
|
* Signature: `nullishFilled(value)` → returns a value
|
|
35
43
|
*
|
|
@@ -38,7 +46,7 @@ export interface EitherNullishFilled<GenericValue extends unknown = unknown> ext
|
|
|
38
46
|
* ```ts
|
|
39
47
|
* const result = E.nullishFilled("string");
|
|
40
48
|
*
|
|
41
|
-
* // type: E.
|
|
49
|
+
* // type: E.NullishFilled<"string">
|
|
42
50
|
* ```
|
|
43
51
|
*
|
|
44
52
|
* @see https://utils.duplojs.dev/en/v1/api/either/nullishFilled
|
|
@@ -61,7 +69,7 @@ export interface EitherNullishFilled<GenericValue extends unknown = unknown> ext
|
|
|
61
69
|
* E.whenIsNullishFilled(S.toUpperCase),
|
|
62
70
|
* );
|
|
63
71
|
*
|
|
64
|
-
* // type: E.
|
|
72
|
+
* // type: E.NullishEmpty<null> | "VALUE"
|
|
65
73
|
* ```
|
|
66
74
|
*
|
|
67
75
|
* @see https://utils.duplojs.dev/en/v1/api/either/whenIsNullishFilled
|
|
@@ -69,10 +77,10 @@ export interface EitherNullishFilled<GenericValue extends unknown = unknown> ext
|
|
|
69
77
|
* @namespace E
|
|
70
78
|
*
|
|
71
79
|
*/
|
|
72
|
-
export declare function nullishFilled<const GenericValue extends unknown>(value: GenericValue):
|
|
73
|
-
type Either =
|
|
74
|
-
export declare function isNullishFilled<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput,
|
|
80
|
+
export declare function nullishFilled<const GenericValue extends unknown>(value: GenericValue): NullishFilled<GenericValue>;
|
|
81
|
+
type Either = Right | Left;
|
|
82
|
+
export declare function isNullishFilled<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, NullishFilled>;
|
|
75
83
|
type ToEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof nullish<GenericValue>>;
|
|
76
|
-
export declare function whenIsNullishFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>,
|
|
77
|
-
export declare function whenIsNullishFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>,
|
|
84
|
+
export declare function whenIsNullishFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, NullishFilled>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<BreakGenericLink<GenericInput>>, NullishFilled>;
|
|
85
|
+
export declare function whenIsNullishFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, NullishFilled>>) => GenericOutput): GenericOutput | Exclude<ToEither<GenericInput>, NullishFilled>;
|
|
78
86
|
export {};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { nullish } from './create.mjs';
|
|
2
2
|
import { createEitherKind } from '../kind.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { nullishKind } from './base.mjs';
|
|
4
4
|
import { right } from '../right/create.mjs';
|
|
5
5
|
import { isRight } from '../right/is.mjs';
|
|
6
6
|
import { isLeft } from '../left/is.mjs';
|
|
7
7
|
import { unwrap } from '../../common/unwrap.mjs';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const nullishFilledKind = createEitherKind("nullish-filled");
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use nullishFilledKind
|
|
12
|
+
*/
|
|
13
|
+
const eitherNullishFilledKind = nullishFilledKind;
|
|
10
14
|
/**
|
|
11
15
|
* {@include either/isNullishFilled/index.md}
|
|
12
16
|
*/
|
|
@@ -17,12 +21,12 @@ const eitherNullishFilledKind = createEitherKind("nullish-filled");
|
|
|
17
21
|
* {@include either/whenIsNullishFilled/index.md}
|
|
18
22
|
*/
|
|
19
23
|
function nullishFilled(value) {
|
|
20
|
-
return
|
|
24
|
+
return nullishKind.setTo(nullishFilledKind.setTo(right("nullish", value)));
|
|
21
25
|
}
|
|
22
26
|
function isNullishFilled(input) {
|
|
23
27
|
return isRight(input)
|
|
24
|
-
&&
|
|
25
|
-
&&
|
|
28
|
+
&& nullishKind.has(input)
|
|
29
|
+
&& nullishFilledKind.has(input);
|
|
26
30
|
}
|
|
27
31
|
function whenIsNullishFilled(...args) {
|
|
28
32
|
if (args.length === 1) {
|
|
@@ -45,4 +49,4 @@ function whenIsNullishFilled(...args) {
|
|
|
45
49
|
return either;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
export { eitherNullishFilledKind, isNullishFilled, nullishFilled, whenIsNullishFilled };
|
|
52
|
+
export { eitherNullishFilledKind, isNullishFilled, nullishFilled, nullishFilledKind, whenIsNullishFilled };
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var kind = require('../kind.cjs');
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const optionalKind = kind.createEitherKind("optional");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use optionalKind
|
|
8
|
+
*/
|
|
9
|
+
const eitherOptionalKind = optionalKind;
|
|
6
10
|
|
|
7
11
|
exports.eitherOptionalKind = eitherOptionalKind;
|
|
12
|
+
exports.optionalKind = optionalKind;
|
|
@@ -1 +1,5 @@
|
|
|
1
|
+
export declare const optionalKind: import("../..").KindHandler<import("../..").KindDefinition<"@DuplojsUtilsEither/optional", unknown>>;
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated use optionalKind
|
|
4
|
+
*/
|
|
1
5
|
export declare const eitherOptionalKind: import("../..").KindHandler<import("../..").KindDefinition<"@DuplojsUtilsEither/optional", unknown>>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { createEitherKind } from '../kind.mjs';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const optionalKind = createEitherKind("optional");
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated use optionalKind
|
|
6
|
+
*/
|
|
7
|
+
const eitherOptionalKind = optionalKind;
|
|
4
8
|
|
|
5
|
-
export { eitherOptionalKind };
|
|
9
|
+
export { eitherOptionalKind, optionalKind };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
1
|
+
import { type OptionalEmpty } from "./empty";
|
|
2
|
+
import { type OptionalFilled } from "./filled";
|
|
3
3
|
/**
|
|
4
4
|
* Wraps an undefined/defined value in an Either, useful for propagating optional fields.
|
|
5
5
|
*
|
|
@@ -10,7 +10,7 @@ import { type EitherOptionalFilled } from "./filled";
|
|
|
10
10
|
* ```ts
|
|
11
11
|
* const result = E.optional(true ? "value" : undefined);
|
|
12
12
|
*
|
|
13
|
-
* // type: E.
|
|
13
|
+
* // type: E.OptionalEmpty | E.OptionalFilled<"value">
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
16
|
* @see https://utils.duplojs.dev/en/v1/api/either/optional
|
|
@@ -18,5 +18,5 @@ import { type EitherOptionalFilled } from "./filled";
|
|
|
18
18
|
* @namespace E
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
-
export declare function optional<const GenericValue extends unknown = undefined>(value: GenericValue): GenericValue extends undefined ?
|
|
22
|
-
export type Optional<GenericValue extends unknown> =
|
|
21
|
+
export declare function optional<const GenericValue extends unknown = undefined>(value: GenericValue): GenericValue extends undefined ? OptionalEmpty : OptionalFilled<GenericValue>;
|
|
22
|
+
export type Optional<GenericValue extends unknown> = OptionalFilled<GenericValue> | OptionalEmpty;
|
|
@@ -7,7 +7,11 @@ var create = require('../left/create.cjs');
|
|
|
7
7
|
var is = require('../left/is.cjs');
|
|
8
8
|
var is$1 = require('../right/is.cjs');
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const optionalEmptyKind = kind.createEitherKind("optional-empty");
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated use optionalEmptyKind
|
|
13
|
+
*/
|
|
14
|
+
const eitherOptionalEmptyKind = optionalEmptyKind;
|
|
11
15
|
/**
|
|
12
16
|
* {@include either/isOptionalEmpty/index.md}
|
|
13
17
|
*/
|
|
@@ -18,12 +22,12 @@ const eitherOptionalEmptyKind = kind.createEitherKind("optional-empty");
|
|
|
18
22
|
* {@include either/whenIsOptionalEmpty/index.md}
|
|
19
23
|
*/
|
|
20
24
|
function optionalEmpty() {
|
|
21
|
-
return base.
|
|
25
|
+
return base.optionalKind.setTo(optionalEmptyKind.setTo(create.left("optional", undefined)));
|
|
22
26
|
}
|
|
23
27
|
function isOptionalEmpty(input) {
|
|
24
28
|
return is.isLeft(input)
|
|
25
|
-
&& base.
|
|
26
|
-
&&
|
|
29
|
+
&& base.optionalKind.has(input)
|
|
30
|
+
&& optionalEmptyKind.has(input);
|
|
27
31
|
}
|
|
28
32
|
function whenIsOptionalEmpty(...args) {
|
|
29
33
|
if (args.length === 1) {
|
|
@@ -49,4 +53,5 @@ function whenIsOptionalEmpty(...args) {
|
|
|
49
53
|
exports.eitherOptionalEmptyKind = eitherOptionalEmptyKind;
|
|
50
54
|
exports.isOptionalEmpty = isOptionalEmpty;
|
|
51
55
|
exports.optionalEmpty = optionalEmpty;
|
|
56
|
+
exports.optionalEmptyKind = optionalEmptyKind;
|
|
52
57
|
exports.whenIsOptionalEmpty = whenIsOptionalEmpty;
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
2
2
|
import { type Kind } from "../../common/kind";
|
|
3
|
-
import {
|
|
3
|
+
import { optionalKind } from "./base";
|
|
4
4
|
import { optional } from "./create";
|
|
5
|
-
import { type
|
|
6
|
-
import { type
|
|
5
|
+
import { type Left } from "../left";
|
|
6
|
+
import { type Right } from "../right";
|
|
7
|
+
export declare const optionalEmptyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/optional-empty", unknown>>;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use optionalEmptyKind
|
|
10
|
+
*/
|
|
7
11
|
export declare const eitherOptionalEmptyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/optional-empty", unknown>>;
|
|
8
|
-
type
|
|
9
|
-
export interface
|
|
12
|
+
type _OptionalEmpty = (Left<"optional", undefined> & Kind<typeof optionalKind.definition> & Kind<typeof optionalEmptyKind.definition>);
|
|
13
|
+
export interface OptionalEmpty extends _OptionalEmpty {
|
|
10
14
|
}
|
|
11
|
-
type Either = EitherRight | EitherLeft;
|
|
12
15
|
/**
|
|
13
|
-
*
|
|
16
|
+
* @deprecated use OptionalEmpty
|
|
17
|
+
*/
|
|
18
|
+
export type EitherOptionalEmpty = OptionalEmpty;
|
|
19
|
+
type Either = Right | Left;
|
|
20
|
+
/**
|
|
21
|
+
* Type guard that detects an OptionalEmpty.
|
|
14
22
|
*
|
|
15
23
|
* Signature: `isOptionalEmpty(input)` → returns a value
|
|
16
24
|
*
|
|
@@ -20,7 +28,7 @@ type Either = EitherRight | EitherLeft;
|
|
|
20
28
|
* const maybeValue = E.optional(true ? "value" : undefined);
|
|
21
29
|
*
|
|
22
30
|
* if (E.isOptionalEmpty(maybeValue)) {
|
|
23
|
-
* // type: E.
|
|
31
|
+
* // type: E.OptionalEmpty
|
|
24
32
|
* }
|
|
25
33
|
* ```
|
|
26
34
|
*
|
|
@@ -30,14 +38,14 @@ type Either = EitherRight | EitherLeft;
|
|
|
30
38
|
*
|
|
31
39
|
*/
|
|
32
40
|
/**
|
|
33
|
-
* Builds an
|
|
41
|
+
* Builds an Left<"optional"> containing undefined.
|
|
34
42
|
*
|
|
35
43
|
* Signature: `optionalEmpty()` → returns a value
|
|
36
44
|
*
|
|
37
45
|
* ```ts
|
|
38
46
|
* const result = E.optionalEmpty();
|
|
39
47
|
*
|
|
40
|
-
* // type: E.
|
|
48
|
+
* // type: E.OptionalEmpty
|
|
41
49
|
* ```
|
|
42
50
|
*
|
|
43
51
|
* @see https://utils.duplojs.dev/en/v1/api/either/optionalEmpty
|
|
@@ -60,7 +68,7 @@ type Either = EitherRight | EitherLeft;
|
|
|
60
68
|
* E.whenIsOptionalEmpty(() => "empty"),
|
|
61
69
|
* );
|
|
62
70
|
*
|
|
63
|
-
* // type: E.
|
|
71
|
+
* // type: E.OptionalFilled<"value"> | "empty"
|
|
64
72
|
* ```
|
|
65
73
|
*
|
|
66
74
|
* @see https://utils.duplojs.dev/en/v1/api/either/whenIsOptionalEmpty
|
|
@@ -68,9 +76,9 @@ type Either = EitherRight | EitherLeft;
|
|
|
68
76
|
* @namespace E
|
|
69
77
|
*
|
|
70
78
|
*/
|
|
71
|
-
export declare function optionalEmpty():
|
|
72
|
-
export declare function isOptionalEmpty<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput,
|
|
79
|
+
export declare function optionalEmpty(): OptionalEmpty;
|
|
80
|
+
export declare function isOptionalEmpty<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, OptionalEmpty>;
|
|
73
81
|
type ToOptionalEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof optional<GenericValue>>;
|
|
74
|
-
export declare function whenIsOptionalEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<BreakGenericLink<GenericInput>>,
|
|
75
|
-
export declare function whenIsOptionalEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<BreakGenericLink<GenericInput>>,
|
|
82
|
+
export declare function whenIsOptionalEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<BreakGenericLink<GenericInput>>, OptionalEmpty>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToOptionalEither<BreakGenericLink<GenericInput>>, OptionalEmpty>;
|
|
83
|
+
export declare function whenIsOptionalEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<BreakGenericLink<GenericInput>>, OptionalEmpty>>) => GenericOutput): GenericOutput | Exclude<ToOptionalEither<GenericInput>, OptionalEmpty>;
|
|
76
84
|
export {};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { createEitherKind } from '../kind.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { optionalKind } from './base.mjs';
|
|
3
3
|
import { optional } 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
|
|
|
8
|
-
const
|
|
8
|
+
const optionalEmptyKind = createEitherKind("optional-empty");
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated use optionalEmptyKind
|
|
11
|
+
*/
|
|
12
|
+
const eitherOptionalEmptyKind = optionalEmptyKind;
|
|
9
13
|
/**
|
|
10
14
|
* {@include either/isOptionalEmpty/index.md}
|
|
11
15
|
*/
|
|
@@ -16,12 +20,12 @@ const eitherOptionalEmptyKind = createEitherKind("optional-empty");
|
|
|
16
20
|
* {@include either/whenIsOptionalEmpty/index.md}
|
|
17
21
|
*/
|
|
18
22
|
function optionalEmpty() {
|
|
19
|
-
return
|
|
23
|
+
return optionalKind.setTo(optionalEmptyKind.setTo(left("optional", undefined)));
|
|
20
24
|
}
|
|
21
25
|
function isOptionalEmpty(input) {
|
|
22
26
|
return isLeft(input)
|
|
23
|
-
&&
|
|
24
|
-
&&
|
|
27
|
+
&& optionalKind.has(input)
|
|
28
|
+
&& optionalEmptyKind.has(input);
|
|
25
29
|
}
|
|
26
30
|
function whenIsOptionalEmpty(...args) {
|
|
27
31
|
if (args.length === 1) {
|
|
@@ -44,4 +48,4 @@ function whenIsOptionalEmpty(...args) {
|
|
|
44
48
|
return either;
|
|
45
49
|
}
|
|
46
50
|
|
|
47
|
-
export { eitherOptionalEmptyKind, isOptionalEmpty, optionalEmpty, whenIsOptionalEmpty };
|
|
51
|
+
export { eitherOptionalEmptyKind, isOptionalEmpty, optionalEmpty, optionalEmptyKind, whenIsOptionalEmpty };
|
|
@@ -8,7 +8,11 @@ var is = require('../right/is.cjs');
|
|
|
8
8
|
var is$1 = require('../left/is.cjs');
|
|
9
9
|
var unwrap = require('../../common/unwrap.cjs');
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const optionalFilledKind = kind.createEitherKind("optional-filled");
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated use optionalFilledKind
|
|
14
|
+
*/
|
|
15
|
+
const eitherOptionalFilledKind = optionalFilledKind;
|
|
12
16
|
/**
|
|
13
17
|
* {@include either/isOptionalFilled/index.md}
|
|
14
18
|
*/
|
|
@@ -19,12 +23,12 @@ const eitherOptionalFilledKind = kind.createEitherKind("optional-filled");
|
|
|
19
23
|
* {@include either/whenIsOptionalFilled/index.md}
|
|
20
24
|
*/
|
|
21
25
|
function optionalFilled(value) {
|
|
22
|
-
return base.
|
|
26
|
+
return base.optionalKind.setTo(optionalFilledKind.setTo(create.right("optional", value)));
|
|
23
27
|
}
|
|
24
28
|
function isOptionalFilled(input) {
|
|
25
29
|
return is.isRight(input)
|
|
26
|
-
&& base.
|
|
27
|
-
&&
|
|
30
|
+
&& base.optionalKind.has(input)
|
|
31
|
+
&& optionalFilledKind.has(input);
|
|
28
32
|
}
|
|
29
33
|
function whenIsOptionalFilled(...args) {
|
|
30
34
|
if (args.length === 1) {
|
|
@@ -50,4 +54,5 @@ function whenIsOptionalFilled(...args) {
|
|
|
50
54
|
exports.eitherOptionalFilledKind = eitherOptionalFilledKind;
|
|
51
55
|
exports.isOptionalFilled = isOptionalFilled;
|
|
52
56
|
exports.optionalFilled = optionalFilled;
|
|
57
|
+
exports.optionalFilledKind = optionalFilledKind;
|
|
53
58
|
exports.whenIsOptionalFilled = whenIsOptionalFilled;
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
2
2
|
import { type Kind } from "../../common/kind";
|
|
3
|
-
import {
|
|
3
|
+
import { optionalKind } from "./base";
|
|
4
4
|
import { optional } from "./create";
|
|
5
|
-
import { type
|
|
6
|
-
import { type
|
|
5
|
+
import { type Left } from "../left";
|
|
6
|
+
import { type Right } from "../right";
|
|
7
|
+
export declare const optionalFilledKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/optional-filled", unknown>>;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use optionalFilledKind
|
|
10
|
+
*/
|
|
7
11
|
export declare const eitherOptionalFilledKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/optional-filled", unknown>>;
|
|
8
|
-
type
|
|
9
|
-
export interface
|
|
12
|
+
type _OptionalFilled<GenericValue extends unknown = unknown> = (Right<"optional", GenericValue> & Kind<typeof optionalKind.definition> & Kind<typeof optionalFilledKind.definition>);
|
|
13
|
+
export interface OptionalFilled<GenericValue extends unknown = unknown> extends _OptionalFilled<GenericValue> {
|
|
10
14
|
}
|
|
11
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated use OptionalFilled
|
|
17
|
+
*/
|
|
18
|
+
export type EitherOptionalFilled<GenericValue extends unknown = unknown> = OptionalFilled<GenericValue>;
|
|
19
|
+
type Either = Right | Left;
|
|
12
20
|
/**
|
|
13
21
|
* Type guard that checks that an optional contains a value.
|
|
14
22
|
*
|
|
@@ -20,7 +28,7 @@ type Either = EitherRight | EitherLeft;
|
|
|
20
28
|
* const maybeValue = E.optional(true ? "value" : undefined);
|
|
21
29
|
*
|
|
22
30
|
* if (E.isOptionalFilled(maybeValue)) {
|
|
23
|
-
* // type: E.
|
|
31
|
+
* // type: E.OptionalFilled<"value">
|
|
24
32
|
* }
|
|
25
33
|
* ```
|
|
26
34
|
*
|
|
@@ -30,7 +38,7 @@ type Either = EitherRight | EitherLeft;
|
|
|
30
38
|
*
|
|
31
39
|
*/
|
|
32
40
|
/**
|
|
33
|
-
* Builds an
|
|
41
|
+
* Builds an Right<"optional"> when the value is defined.
|
|
34
42
|
*
|
|
35
43
|
* Signature: `optionalFilled(value)` → returns a value
|
|
36
44
|
*
|
|
@@ -39,7 +47,7 @@ type Either = EitherRight | EitherLeft;
|
|
|
39
47
|
* ```ts
|
|
40
48
|
* const result = E.optionalFilled("value");
|
|
41
49
|
*
|
|
42
|
-
* // type: E.
|
|
50
|
+
* // type: E.OptionalFilled<"value">
|
|
43
51
|
* ```
|
|
44
52
|
*
|
|
45
53
|
* @see https://utils.duplojs.dev/en/v1/api/either/optionalFilled
|
|
@@ -62,7 +70,7 @@ type Either = EitherRight | EitherLeft;
|
|
|
62
70
|
* E.whenIsOptionalFilled(S.capitalize),
|
|
63
71
|
* );
|
|
64
72
|
*
|
|
65
|
-
* // type: E.
|
|
73
|
+
* // type: E.OptionalEmpty | "Value"
|
|
66
74
|
* ```
|
|
67
75
|
*
|
|
68
76
|
* @see https://utils.duplojs.dev/en/v1/api/either/whenIsOptionalFilled
|
|
@@ -70,9 +78,9 @@ type Either = EitherRight | EitherLeft;
|
|
|
70
78
|
* @namespace E
|
|
71
79
|
*
|
|
72
80
|
*/
|
|
73
|
-
export declare function optionalFilled<const GenericValue extends unknown>(value: GenericValue):
|
|
74
|
-
export declare function isOptionalFilled<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput,
|
|
81
|
+
export declare function optionalFilled<const GenericValue extends unknown>(value: GenericValue): OptionalFilled<GenericValue>;
|
|
82
|
+
export declare function isOptionalFilled<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, OptionalFilled>;
|
|
75
83
|
type ToOptionalEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof optional<GenericValue>>;
|
|
76
|
-
export declare function whenIsOptionalFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<BreakGenericLink<GenericInput>>,
|
|
77
|
-
export declare function whenIsOptionalFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<BreakGenericLink<GenericInput>>,
|
|
84
|
+
export declare function whenIsOptionalFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<BreakGenericLink<GenericInput>>, OptionalFilled>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToOptionalEither<BreakGenericLink<GenericInput>>, OptionalFilled>;
|
|
85
|
+
export declare function whenIsOptionalFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<BreakGenericLink<GenericInput>>, OptionalFilled>>) => GenericOutput): GenericOutput | Exclude<ToOptionalEither<GenericInput>, OptionalFilled>;
|
|
78
86
|
export {};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { createEitherKind } from '../kind.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { optionalKind } from './base.mjs';
|
|
3
3
|
import { optional } from './create.mjs';
|
|
4
4
|
import { right } from '../right/create.mjs';
|
|
5
5
|
import { isRight } from '../right/is.mjs';
|
|
6
6
|
import { isLeft } from '../left/is.mjs';
|
|
7
7
|
import { unwrap } from '../../common/unwrap.mjs';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const optionalFilledKind = createEitherKind("optional-filled");
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use optionalFilledKind
|
|
12
|
+
*/
|
|
13
|
+
const eitherOptionalFilledKind = optionalFilledKind;
|
|
10
14
|
/**
|
|
11
15
|
* {@include either/isOptionalFilled/index.md}
|
|
12
16
|
*/
|
|
@@ -17,12 +21,12 @@ const eitherOptionalFilledKind = createEitherKind("optional-filled");
|
|
|
17
21
|
* {@include either/whenIsOptionalFilled/index.md}
|
|
18
22
|
*/
|
|
19
23
|
function optionalFilled(value) {
|
|
20
|
-
return
|
|
24
|
+
return optionalKind.setTo(optionalFilledKind.setTo(right("optional", value)));
|
|
21
25
|
}
|
|
22
26
|
function isOptionalFilled(input) {
|
|
23
27
|
return isRight(input)
|
|
24
|
-
&&
|
|
25
|
-
&&
|
|
28
|
+
&& optionalKind.has(input)
|
|
29
|
+
&& optionalFilledKind.has(input);
|
|
26
30
|
}
|
|
27
31
|
function whenIsOptionalFilled(...args) {
|
|
28
32
|
if (args.length === 1) {
|
|
@@ -45,4 +49,4 @@ function whenIsOptionalFilled(...args) {
|
|
|
45
49
|
return either;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
export { eitherOptionalFilledKind, isOptionalFilled, optionalFilled, whenIsOptionalFilled };
|
|
52
|
+
export { eitherOptionalFilledKind, isOptionalFilled, optionalFilled, optionalFilledKind, whenIsOptionalFilled };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type AnyFunction, type SimplifyTopLevel, type MayBeGetter, type Unwrap, type MaybePromise } from "../../common";
|
|
2
|
-
import { type
|
|
3
|
-
import { type
|
|
2
|
+
import { type Left } from "../left";
|
|
3
|
+
import { type Right } from "./create";
|
|
4
4
|
import * as DEither from "..";
|
|
5
|
-
type Either = MaybePromise<
|
|
6
|
-
type ComputeResult<GenericGroup extends Record<string, MayBeGetter<Either>>> = Promise<DEither.
|
|
7
|
-
[Prop in keyof GenericGroup]: GenericGroup[Prop] extends AnyFunction ? Unwrap<Extract<Awaited<ReturnType<GenericGroup[Prop]>>,
|
|
5
|
+
type Either = MaybePromise<Right | Left>;
|
|
6
|
+
type ComputeResult<GenericGroup extends Record<string, MayBeGetter<Either>>> = Promise<DEither.Success<SimplifyTopLevel<{
|
|
7
|
+
[Prop in keyof GenericGroup]: GenericGroup[Prop] extends AnyFunction ? Unwrap<Extract<Awaited<ReturnType<GenericGroup[Prop]>>, Right>> : Unwrap<Extract<Awaited<GenericGroup[Prop]>, Right>>;
|
|
8
8
|
}>> | {
|
|
9
|
-
[Prop in keyof GenericGroup]: GenericGroup[Prop] extends AnyFunction ? Extract<Awaited<ReturnType<GenericGroup[Prop]>>,
|
|
9
|
+
[Prop in keyof GenericGroup]: GenericGroup[Prop] extends AnyFunction ? Extract<Awaited<ReturnType<GenericGroup[Prop]>>, Left> : Extract<Awaited<GenericGroup[Prop]>, Left>;
|
|
10
10
|
}[keyof GenericGroup]>;
|
|
11
11
|
/**
|
|
12
12
|
* The asyncGroup() function runs synchronous or asynchronous Either values in parallel (promises, Future) and returns the first Left encountered. If all are Right, it aggregates their values into a typed object.
|
|
@@ -26,7 +26,7 @@ type ComputeResult<GenericGroup extends Record<string, MayBeGetter<Either>>> = P
|
|
|
26
26
|
* profile: promiseProfile,
|
|
27
27
|
* });
|
|
28
28
|
*
|
|
29
|
-
* // type: E.
|
|
29
|
+
* // type: E.FutureError
|
|
30
30
|
* ```
|
|
31
31
|
*
|
|
32
32
|
* @remarks
|