@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.
- 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/parsers/empty.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/package.json +1 -1
|
@@ -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 { type
|
|
4
|
-
import { type
|
|
3
|
+
import { type Left } from "../left";
|
|
4
|
+
import { type Right } from "../right";
|
|
5
5
|
import { nullable } from "./create";
|
|
6
|
-
import {
|
|
6
|
+
import { nullableKind } from "./base";
|
|
7
|
+
export declare const nullableFilledKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/nullable-filled", unknown>>;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use nullableFilledKind
|
|
10
|
+
*/
|
|
7
11
|
export declare const eitherNullableFilledKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/nullable-filled", unknown>>;
|
|
8
|
-
type
|
|
9
|
-
export interface
|
|
12
|
+
type _NullableFilled<GenericValue extends unknown = unknown> = (Right<"nullable", GenericValue> & Kind<typeof nullableKind.definition> & Kind<typeof nullableFilledKind.definition>);
|
|
13
|
+
export interface NullableFilled<GenericValue extends unknown = unknown> extends _NullableFilled<GenericValue> {
|
|
10
14
|
}
|
|
11
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated use NullableFilled
|
|
17
|
+
*/
|
|
18
|
+
export type EitherNullableFilled<GenericValue extends unknown = unknown> = NullableFilled<GenericValue>;
|
|
19
|
+
type Either = Right | Left;
|
|
12
20
|
/**
|
|
13
21
|
* Type guard that checks that the nullable Either actually contains a value.
|
|
14
22
|
*
|
|
@@ -20,7 +28,7 @@ type Either = EitherRight | EitherLeft;
|
|
|
20
28
|
* const maybeValue = E.nullable(true ? "value" : null);
|
|
21
29
|
*
|
|
22
30
|
* if (E.isNullableFilled(maybeValue)) {
|
|
23
|
-
* // type: E.
|
|
31
|
+
* // type: E.NullableFilled<"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<"nullable"> for a non-null value.
|
|
34
42
|
*
|
|
35
43
|
* Signature: `nullableFilled(value)` → returns a value
|
|
36
44
|
*
|
|
@@ -39,7 +47,7 @@ type Either = EitherRight | EitherLeft;
|
|
|
39
47
|
* ```ts
|
|
40
48
|
* const result = E.nullableFilled("value");
|
|
41
49
|
*
|
|
42
|
-
* // type: E.
|
|
50
|
+
* // type: E.NullableFilled<"value">
|
|
43
51
|
* ```
|
|
44
52
|
*
|
|
45
53
|
* @see https://utils.duplojs.dev/en/v1/api/either/nullableFilled
|
|
@@ -62,7 +70,7 @@ type Either = EitherRight | EitherLeft;
|
|
|
62
70
|
* E.whenIsNullableFilled(S.capitalize),
|
|
63
71
|
* );
|
|
64
72
|
*
|
|
65
|
-
* // type: E.
|
|
73
|
+
* // type: E.NullableEmpty | "Value"
|
|
66
74
|
* ```
|
|
67
75
|
*
|
|
68
76
|
* @see https://utils.duplojs.dev/en/v1/api/either/whenIsNullableFilled
|
|
@@ -70,9 +78,9 @@ type Either = EitherRight | EitherLeft;
|
|
|
70
78
|
* @namespace E
|
|
71
79
|
*
|
|
72
80
|
*/
|
|
73
|
-
export declare function nullableFilled<const GenericValue extends unknown>(value: GenericValue):
|
|
74
|
-
export declare function isNullableFilled<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput,
|
|
81
|
+
export declare function nullableFilled<const GenericValue extends unknown>(value: GenericValue): NullableFilled<GenericValue>;
|
|
82
|
+
export declare function isNullableFilled<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, NullableFilled>;
|
|
75
83
|
type ToEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof nullable<GenericValue>>;
|
|
76
|
-
export declare function whenIsNullableFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>,
|
|
77
|
-
export declare function whenIsNullableFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>,
|
|
84
|
+
export declare function whenIsNullableFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, NullableFilled>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<BreakGenericLink<GenericInput>>, NullableFilled>;
|
|
85
|
+
export declare function whenIsNullableFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, NullableFilled>>) => GenericOutput): GenericOutput | Exclude<ToEither<GenericInput>, NullableFilled>;
|
|
78
86
|
export {};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { nullable } from './create.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { nullableKind } from './base.mjs';
|
|
3
3
|
import { createEitherKind } from '../kind.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 nullableFilledKind = createEitherKind("nullable-filled");
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use nullableFilledKind
|
|
12
|
+
*/
|
|
13
|
+
const eitherNullableFilledKind = nullableFilledKind;
|
|
10
14
|
/**
|
|
11
15
|
* {@include either/isNullableFilled/index.md}
|
|
12
16
|
*/
|
|
@@ -17,12 +21,12 @@ const eitherNullableFilledKind = createEitherKind("nullable-filled");
|
|
|
17
21
|
* {@include either/whenIsNullableFilled/index.md}
|
|
18
22
|
*/
|
|
19
23
|
function nullableFilled(value) {
|
|
20
|
-
return
|
|
24
|
+
return nullableKind.setTo(nullableFilledKind.setTo(right("nullable", value)));
|
|
21
25
|
}
|
|
22
26
|
function isNullableFilled(input) {
|
|
23
27
|
return isRight(input)
|
|
24
|
-
&&
|
|
25
|
-
&&
|
|
28
|
+
&& nullableKind.has(input)
|
|
29
|
+
&& nullableFilledKind.has(input);
|
|
26
30
|
}
|
|
27
31
|
function whenIsNullableFilled(...args) {
|
|
28
32
|
if (args.length === 1) {
|
|
@@ -45,4 +49,4 @@ function whenIsNullableFilled(...args) {
|
|
|
45
49
|
return either;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
export { eitherNullableFilledKind, isNullableFilled, nullableFilled, whenIsNullableFilled };
|
|
52
|
+
export { eitherNullableFilledKind, isNullableFilled, nullableFilled, nullableFilledKind, whenIsNullableFilled };
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var kind = require('../kind.cjs');
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const nullishKind = kind.createEitherKind("nullish");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use nullishKind
|
|
8
|
+
*/
|
|
9
|
+
const eitherNullishKind = nullishKind;
|
|
6
10
|
|
|
7
11
|
exports.eitherNullishKind = eitherNullishKind;
|
|
12
|
+
exports.nullishKind = nullishKind;
|
|
@@ -1 +1,5 @@
|
|
|
1
|
+
export declare const nullishKind: import("../..").KindHandler<import("../..").KindDefinition<"@DuplojsUtilsEither/nullish", unknown>>;
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated use nullishKind
|
|
4
|
+
*/
|
|
1
5
|
export declare const eitherNullishKind: import("../..").KindHandler<import("../..").KindDefinition<"@DuplojsUtilsEither/nullish", unknown>>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { createEitherKind } from '../kind.mjs';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const nullishKind = createEitherKind("nullish");
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated use nullishKind
|
|
6
|
+
*/
|
|
7
|
+
const eitherNullishKind = nullishKind;
|
|
4
8
|
|
|
5
|
-
export { eitherNullishKind };
|
|
9
|
+
export { eitherNullishKind, nullishKind };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
1
|
+
import { type NullishEmpty, type NullishValue } from "./empty";
|
|
2
|
+
import { type NullishFilled } from "./filled";
|
|
3
3
|
/**
|
|
4
4
|
* Transforms a potentially null/undefined value into an Either. Allows propagating presence/absence in a type-safe way.
|
|
5
5
|
*
|
|
@@ -12,7 +12,7 @@ import { type EitherNullishFilled } from "./filled";
|
|
|
12
12
|
*
|
|
13
13
|
* const result = E.nullish(mayBeInput);
|
|
14
14
|
*
|
|
15
|
-
* // type: E.
|
|
15
|
+
* // type: E.NullishEmpty<undefined> | E.NullishFilled<true>
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
18
|
* @see https://utils.duplojs.dev/en/v1/api/either/nullish
|
|
@@ -20,5 +20,5 @@ import { type EitherNullishFilled } from "./filled";
|
|
|
20
20
|
* @namespace E
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
export declare function nullish<const GenericValue extends unknown = undefined>(value: GenericValue): GenericValue extends NullishValue ?
|
|
24
|
-
export type Nullish<GenericValue extends unknown> =
|
|
23
|
+
export declare function nullish<const GenericValue extends unknown = undefined>(value: GenericValue): GenericValue extends NullishValue ? NullishEmpty<GenericValue> : NullishFilled<GenericValue>;
|
|
24
|
+
export type Nullish<GenericValue extends unknown> = NullishFilled<GenericValue> | NullishEmpty;
|
|
@@ -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
|
|
11
|
+
const nullishEmptyKind = kind.createEitherKind("nullish-empty");
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated use nullishEmptyKind
|
|
14
|
+
*/
|
|
15
|
+
const eitherNullishEmptyKind = nullishEmptyKind;
|
|
12
16
|
/**
|
|
13
17
|
* {@include either/isNullishEmpty/index.md}
|
|
14
18
|
*/
|
|
@@ -19,12 +23,12 @@ const eitherNullishEmptyKind = kind.createEitherKind("nullish-empty");
|
|
|
19
23
|
* {@include either/whenIsNullishEmpty/index.md}
|
|
20
24
|
*/
|
|
21
25
|
function nullishEmpty(value = undefined) {
|
|
22
|
-
return base.
|
|
26
|
+
return base.nullishKind.setTo(nullishEmptyKind.setTo(create.left("nullish", value)));
|
|
23
27
|
}
|
|
24
28
|
function isNullishEmpty(input) {
|
|
25
29
|
return is.isLeft(input)
|
|
26
|
-
&& base.
|
|
27
|
-
&&
|
|
30
|
+
&& base.nullishKind.has(input)
|
|
31
|
+
&& nullishEmptyKind.has(input);
|
|
28
32
|
}
|
|
29
33
|
function whenIsNullishEmpty(...args) {
|
|
30
34
|
if (args.length === 1) {
|
|
@@ -50,4 +54,5 @@ function whenIsNullishEmpty(...args) {
|
|
|
50
54
|
exports.eitherNullishEmptyKind = eitherNullishEmptyKind;
|
|
51
55
|
exports.isNullishEmpty = isNullishEmpty;
|
|
52
56
|
exports.nullishEmpty = nullishEmpty;
|
|
57
|
+
exports.nullishEmptyKind = nullishEmptyKind;
|
|
53
58
|
exports.whenIsNullishEmpty = whenIsNullishEmpty;
|
|
@@ -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 { type
|
|
4
|
-
import { type
|
|
3
|
+
import { type Left } from "../left";
|
|
4
|
+
import { type Right } from "../right";
|
|
5
5
|
import { nullish } from "./create";
|
|
6
|
-
import {
|
|
6
|
+
import { nullishKind } from "./base";
|
|
7
7
|
export type NullishValue = null | undefined;
|
|
8
|
+
export declare const nullishEmptyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/nullish-empty", unknown>>;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated use nullishEmptyKind
|
|
11
|
+
*/
|
|
8
12
|
export declare const eitherNullishEmptyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/nullish-empty", unknown>>;
|
|
9
|
-
type
|
|
10
|
-
export interface
|
|
13
|
+
type _NullishEmpty<GenericValue extends NullishValue = NullishValue> = (Left<"nullish", GenericValue> & Kind<typeof nullishKind.definition> & Kind<typeof nullishEmptyKind.definition>);
|
|
14
|
+
export interface NullishEmpty<GenericValue extends NullishValue = NullishValue> extends _NullishEmpty<GenericValue> {
|
|
11
15
|
}
|
|
12
16
|
/**
|
|
13
|
-
*
|
|
17
|
+
* @deprecated use NullishEmpty
|
|
18
|
+
*/
|
|
19
|
+
export type EitherNullishEmpty<GenericValue extends NullishValue = NullishValue> = NullishEmpty<GenericValue>;
|
|
20
|
+
/**
|
|
21
|
+
* Type guard detecting an NullishEmpty.
|
|
14
22
|
*
|
|
15
23
|
* Signature: `isNullishEmpty(input)` → returns a value
|
|
16
24
|
*
|
|
@@ -20,7 +28,7 @@ export interface EitherNullishEmpty<GenericValue extends NullishValue = NullishV
|
|
|
20
28
|
* const maybeValue = E.nullish(true ? "value" : null);
|
|
21
29
|
*
|
|
22
30
|
* if (E.isNullishEmpty(maybeValue)) {
|
|
23
|
-
* // type: E.
|
|
31
|
+
* // type: E.NullishEmpty<null>
|
|
24
32
|
* }
|
|
25
33
|
* ```
|
|
26
34
|
*
|
|
@@ -30,7 +38,7 @@ export interface EitherNullishEmpty<GenericValue extends NullishValue = NullishV
|
|
|
30
38
|
*
|
|
31
39
|
*/
|
|
32
40
|
/**
|
|
33
|
-
* Explicitly builds an
|
|
41
|
+
* Explicitly builds an Left<"nullish"> with null or undefined.
|
|
34
42
|
*
|
|
35
43
|
* Signature: `nullishEmpty(value)` → returns a value
|
|
36
44
|
*
|
|
@@ -39,7 +47,7 @@ export interface EitherNullishEmpty<GenericValue extends NullishValue = NullishV
|
|
|
39
47
|
* ```ts
|
|
40
48
|
* const result = E.nullishEmpty();
|
|
41
49
|
*
|
|
42
|
-
* // type: E.
|
|
50
|
+
* // type: E.NullishEmpty<undefined>
|
|
43
51
|
* ```
|
|
44
52
|
*
|
|
45
53
|
* @see https://utils.duplojs.dev/en/v1/api/either/nullishEmpty
|
|
@@ -62,7 +70,7 @@ export interface EitherNullishEmpty<GenericValue extends NullishValue = NullishV
|
|
|
62
70
|
* E.whenIsNullishEmpty(() => "nullish"),
|
|
63
71
|
* );
|
|
64
72
|
*
|
|
65
|
-
* // type: "nullish" | E.
|
|
73
|
+
* // type: "nullish" | E.NullishFilled<"value">
|
|
66
74
|
* ```
|
|
67
75
|
*
|
|
68
76
|
* @see https://utils.duplojs.dev/en/v1/api/either/whenIsNullishEmpty
|
|
@@ -70,10 +78,10 @@ export interface EitherNullishEmpty<GenericValue extends NullishValue = NullishV
|
|
|
70
78
|
* @namespace E
|
|
71
79
|
*
|
|
72
80
|
*/
|
|
73
|
-
export declare function nullishEmpty<const GenericValue extends NullishValue = undefined>(value?: GenericValue):
|
|
74
|
-
type Either =
|
|
75
|
-
export declare function isNullishEmpty<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput,
|
|
81
|
+
export declare function nullishEmpty<const GenericValue extends NullishValue = undefined>(value?: GenericValue): NullishEmpty<GenericValue>;
|
|
82
|
+
type Either = Right | Left;
|
|
83
|
+
export declare function isNullishEmpty<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, NullishEmpty>;
|
|
76
84
|
type ToEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof nullish<GenericValue>>;
|
|
77
|
-
export declare function whenIsNullishEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>,
|
|
78
|
-
export declare function whenIsNullishEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>,
|
|
85
|
+
export declare function whenIsNullishEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, NullishEmpty>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<BreakGenericLink<GenericInput>>, NullishEmpty>;
|
|
86
|
+
export declare function whenIsNullishEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, NullishEmpty>>) => GenericOutput): GenericOutput | Exclude<ToEither<GenericInput>, NullishEmpty>;
|
|
79
87
|
export {};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { createEitherKind } from '../kind.mjs';
|
|
2
2
|
import { nullish } from './create.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { nullishKind } from './base.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
|
|
9
|
+
const nullishEmptyKind = createEitherKind("nullish-empty");
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use nullishEmptyKind
|
|
12
|
+
*/
|
|
13
|
+
const eitherNullishEmptyKind = nullishEmptyKind;
|
|
10
14
|
/**
|
|
11
15
|
* {@include either/isNullishEmpty/index.md}
|
|
12
16
|
*/
|
|
@@ -17,12 +21,12 @@ const eitherNullishEmptyKind = createEitherKind("nullish-empty");
|
|
|
17
21
|
* {@include either/whenIsNullishEmpty/index.md}
|
|
18
22
|
*/
|
|
19
23
|
function nullishEmpty(value = undefined) {
|
|
20
|
-
return
|
|
24
|
+
return nullishKind.setTo(nullishEmptyKind.setTo(left("nullish", value)));
|
|
21
25
|
}
|
|
22
26
|
function isNullishEmpty(input) {
|
|
23
27
|
return isLeft(input)
|
|
24
|
-
&&
|
|
25
|
-
&&
|
|
28
|
+
&& nullishKind.has(input)
|
|
29
|
+
&& nullishEmptyKind.has(input);
|
|
26
30
|
}
|
|
27
31
|
function whenIsNullishEmpty(...args) {
|
|
28
32
|
if (args.length === 1) {
|
|
@@ -45,4 +49,4 @@ function whenIsNullishEmpty(...args) {
|
|
|
45
49
|
return either;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
export { eitherNullishEmptyKind, isNullishEmpty, nullishEmpty, whenIsNullishEmpty };
|
|
52
|
+
export { eitherNullishEmptyKind, isNullishEmpty, nullishEmpty, nullishEmptyKind, whenIsNullishEmpty };
|
|
@@ -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 nullishFilledKind = kind.createEitherKind("nullish-filled");
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated use nullishFilledKind
|
|
14
|
+
*/
|
|
15
|
+
const eitherNullishFilledKind = nullishFilledKind;
|
|
12
16
|
/**
|
|
13
17
|
* {@include either/isNullishFilled/index.md}
|
|
14
18
|
*/
|
|
@@ -19,12 +23,12 @@ const eitherNullishFilledKind = kind.createEitherKind("nullish-filled");
|
|
|
19
23
|
* {@include either/whenIsNullishFilled/index.md}
|
|
20
24
|
*/
|
|
21
25
|
function nullishFilled(value) {
|
|
22
|
-
return base.
|
|
26
|
+
return base.nullishKind.setTo(nullishFilledKind.setTo(create.right("nullish", value)));
|
|
23
27
|
}
|
|
24
28
|
function isNullishFilled(input) {
|
|
25
29
|
return is.isRight(input)
|
|
26
|
-
&& base.
|
|
27
|
-
&&
|
|
30
|
+
&& base.nullishKind.has(input)
|
|
31
|
+
&& nullishFilledKind.has(input);
|
|
28
32
|
}
|
|
29
33
|
function whenIsNullishFilled(...args) {
|
|
30
34
|
if (args.length === 1) {
|
|
@@ -50,4 +54,5 @@ function whenIsNullishFilled(...args) {
|
|
|
50
54
|
exports.eitherNullishFilledKind = eitherNullishFilledKind;
|
|
51
55
|
exports.isNullishFilled = isNullishFilled;
|
|
52
56
|
exports.nullishFilled = nullishFilled;
|
|
57
|
+
exports.nullishFilledKind = nullishFilledKind;
|
|
53
58
|
exports.whenIsNullishFilled = whenIsNullishFilled;
|
|
@@ -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;
|