@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,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
1
|
+
import { type NullableEmpty } from "./empty";
|
|
2
|
+
import { type NullableFilled } from "./filled";
|
|
3
3
|
/**
|
|
4
4
|
* Wraps a null or non-null value in an Either, while keeping the information on whether it is filled or empty.
|
|
5
5
|
*
|
|
@@ -10,7 +10,7 @@ import { type EitherNullableFilled } from "./filled";
|
|
|
10
10
|
* ```ts
|
|
11
11
|
* const result = E.nullable(true ? "value" : null);
|
|
12
12
|
*
|
|
13
|
-
* // type: E.
|
|
13
|
+
* // type: E.NullableEmpty | E.NullableFilled<"value">
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
16
|
* @see https://utils.duplojs.dev/en/v1/api/either/nullable
|
|
@@ -18,5 +18,5 @@ import { type EitherNullableFilled } from "./filled";
|
|
|
18
18
|
* @namespace E
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
-
export declare function nullable<const GenericValue extends unknown = null>(value: GenericValue): GenericValue extends null ?
|
|
22
|
-
export type Nullable<GenericValue extends unknown> =
|
|
21
|
+
export declare function nullable<const GenericValue extends unknown = null>(value: GenericValue): GenericValue extends null ? NullableEmpty : NullableFilled<GenericValue>;
|
|
22
|
+
export type Nullable<GenericValue extends unknown> = NullableFilled<GenericValue> | NullableEmpty;
|
|
@@ -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 nullableEmptyKind = kind.createEitherKind("nullable-empty");
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated use nullableEmptyKind
|
|
14
|
+
*/
|
|
15
|
+
const eitherNullableEmptyKind = nullableEmptyKind;
|
|
12
16
|
/**
|
|
13
17
|
* {@include either/isNullableEmpty/index.md}
|
|
14
18
|
*/
|
|
@@ -19,12 +23,12 @@ const eitherNullableEmptyKind = kind.createEitherKind("nullable-empty");
|
|
|
19
23
|
* {@include either/whenIsNullableEmpty/index.md}
|
|
20
24
|
*/
|
|
21
25
|
function nullableEmpty() {
|
|
22
|
-
return base.
|
|
26
|
+
return base.nullableKind.setTo(nullableEmptyKind.setTo(create.left("nullable", null)));
|
|
23
27
|
}
|
|
24
28
|
function isNullableEmpty(input) {
|
|
25
29
|
return is.isLeft(input)
|
|
26
|
-
&& base.
|
|
27
|
-
&&
|
|
30
|
+
&& base.nullableKind.has(input)
|
|
31
|
+
&& nullableEmptyKind.has(input);
|
|
28
32
|
}
|
|
29
33
|
function whenIsNullableEmpty(...args) {
|
|
30
34
|
if (args.length === 1) {
|
|
@@ -50,4 +54,5 @@ function whenIsNullableEmpty(...args) {
|
|
|
50
54
|
exports.eitherNullableEmptyKind = eitherNullableEmptyKind;
|
|
51
55
|
exports.isNullableEmpty = isNullableEmpty;
|
|
52
56
|
exports.nullableEmpty = nullableEmpty;
|
|
57
|
+
exports.nullableEmptyKind = nullableEmptyKind;
|
|
53
58
|
exports.whenIsNullableEmpty = whenIsNullableEmpty;
|
|
@@ -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 { nullable } from "./create";
|
|
6
|
-
import {
|
|
6
|
+
import { nullableKind } from "./base";
|
|
7
|
+
export declare const nullableEmptyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/nullable-empty", unknown>>;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use nullableEmptyKind
|
|
10
|
+
*/
|
|
7
11
|
export declare const eitherNullableEmptyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/nullable-empty", unknown>>;
|
|
8
|
-
type
|
|
9
|
-
export interface
|
|
12
|
+
type _NullableEmpty = (Left<"nullable", null> & Kind<typeof nullableKind.definition> & Kind<typeof nullableEmptyKind.definition>);
|
|
13
|
+
export interface NullableEmpty extends _NullableEmpty {
|
|
10
14
|
}
|
|
11
|
-
type Either = EitherRight | EitherLeft;
|
|
12
15
|
/**
|
|
13
|
-
*
|
|
16
|
+
* @deprecated use NullableEmpty
|
|
17
|
+
*/
|
|
18
|
+
export type EitherNullableEmpty = NullableEmpty;
|
|
19
|
+
type Either = Right | Left;
|
|
20
|
+
/**
|
|
21
|
+
* Type guard that detects an NullableEmpty.
|
|
14
22
|
*
|
|
15
23
|
* Signature: `isNullableEmpty(input)` → returns a value
|
|
16
24
|
*
|
|
@@ -20,7 +28,7 @@ type Either = EitherRight | EitherLeft;
|
|
|
20
28
|
* const maybeValue = E.nullable(true ? "value" : null);
|
|
21
29
|
*
|
|
22
30
|
* if (E.isNullableEmpty(maybeValue)) {
|
|
23
|
-
* // type: E.
|
|
31
|
+
* // type: E.NullableEmpty
|
|
24
32
|
* }
|
|
25
33
|
* ```
|
|
26
34
|
*
|
|
@@ -30,14 +38,14 @@ type Either = EitherRight | EitherLeft;
|
|
|
30
38
|
*
|
|
31
39
|
*/
|
|
32
40
|
/**
|
|
33
|
-
* Explicitly builds an
|
|
41
|
+
* Explicitly builds an Left<"nullable"> containing null.
|
|
34
42
|
*
|
|
35
43
|
* Signature: `nullableEmpty()` → returns a value
|
|
36
44
|
*
|
|
37
45
|
* ```ts
|
|
38
46
|
* const result = E.nullableEmpty();
|
|
39
47
|
*
|
|
40
|
-
* // type: E.
|
|
48
|
+
* // type: E.NullableEmpty
|
|
41
49
|
* ```
|
|
42
50
|
*
|
|
43
51
|
* @see https://utils.duplojs.dev/en/v1/api/either/nullableEmpty
|
|
@@ -60,7 +68,7 @@ type Either = EitherRight | EitherLeft;
|
|
|
60
68
|
* E.whenIsNullableEmpty(() => "nullable"),
|
|
61
69
|
* );
|
|
62
70
|
*
|
|
63
|
-
* // type: "nullable" | E.
|
|
71
|
+
* // type: "nullable" | E.NullableFilled<"value">
|
|
64
72
|
* ```
|
|
65
73
|
*
|
|
66
74
|
* @see https://utils.duplojs.dev/en/v1/api/either/whenIsNullableEmpty
|
|
@@ -68,9 +76,9 @@ type Either = EitherRight | EitherLeft;
|
|
|
68
76
|
* @namespace E
|
|
69
77
|
*
|
|
70
78
|
*/
|
|
71
|
-
export declare function nullableEmpty():
|
|
72
|
-
export declare function isNullableEmpty<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput,
|
|
79
|
+
export declare function nullableEmpty(): NullableEmpty;
|
|
80
|
+
export declare function isNullableEmpty<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, NullableEmpty>;
|
|
73
81
|
type ToEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof nullable<GenericValue>>;
|
|
74
|
-
export declare function whenIsNullableEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>,
|
|
75
|
-
export declare function whenIsNullableEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>,
|
|
82
|
+
export declare function whenIsNullableEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, NullableEmpty>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<GenericInput>, NullableEmpty>;
|
|
83
|
+
export declare function whenIsNullableEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, NullableEmpty>>) => GenericOutput): GenericOutput | Exclude<ToEither<BreakGenericLink<GenericInput>>, NullableEmpty>;
|
|
76
84
|
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 { 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 nullableEmptyKind = createEitherKind("nullable-empty");
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use nullableEmptyKind
|
|
12
|
+
*/
|
|
13
|
+
const eitherNullableEmptyKind = nullableEmptyKind;
|
|
10
14
|
/**
|
|
11
15
|
* {@include either/isNullableEmpty/index.md}
|
|
12
16
|
*/
|
|
@@ -17,12 +21,12 @@ const eitherNullableEmptyKind = createEitherKind("nullable-empty");
|
|
|
17
21
|
* {@include either/whenIsNullableEmpty/index.md}
|
|
18
22
|
*/
|
|
19
23
|
function nullableEmpty() {
|
|
20
|
-
return
|
|
24
|
+
return nullableKind.setTo(nullableEmptyKind.setTo(left("nullable", null)));
|
|
21
25
|
}
|
|
22
26
|
function isNullableEmpty(input) {
|
|
23
27
|
return isLeft(input)
|
|
24
|
-
&&
|
|
25
|
-
&&
|
|
28
|
+
&& nullableKind.has(input)
|
|
29
|
+
&& nullableEmptyKind.has(input);
|
|
26
30
|
}
|
|
27
31
|
function whenIsNullableEmpty(...args) {
|
|
28
32
|
if (args.length === 1) {
|
|
@@ -45,4 +49,4 @@ function whenIsNullableEmpty(...args) {
|
|
|
45
49
|
return either;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
export { eitherNullableEmptyKind, isNullableEmpty, nullableEmpty, whenIsNullableEmpty };
|
|
52
|
+
export { eitherNullableEmptyKind, isNullableEmpty, nullableEmpty, nullableEmptyKind, whenIsNullableEmpty };
|
|
@@ -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 nullableFilledKind = kind.createEitherKind("nullable-filled");
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated use nullableFilledKind
|
|
14
|
+
*/
|
|
15
|
+
const eitherNullableFilledKind = nullableFilledKind;
|
|
12
16
|
/**
|
|
13
17
|
* {@include either/isNullableFilled/index.md}
|
|
14
18
|
*/
|
|
@@ -19,12 +23,12 @@ const eitherNullableFilledKind = kind.createEitherKind("nullable-filled");
|
|
|
19
23
|
* {@include either/whenIsNullableFilled/index.md}
|
|
20
24
|
*/
|
|
21
25
|
function nullableFilled(value) {
|
|
22
|
-
return base.
|
|
26
|
+
return base.nullableKind.setTo(nullableFilledKind.setTo(create.right("nullable", value)));
|
|
23
27
|
}
|
|
24
28
|
function isNullableFilled(input) {
|
|
25
29
|
return is.isRight(input)
|
|
26
|
-
&& base.
|
|
27
|
-
&&
|
|
30
|
+
&& base.nullableKind.has(input)
|
|
31
|
+
&& nullableFilledKind.has(input);
|
|
28
32
|
}
|
|
29
33
|
function whenIsNullableFilled(...args) {
|
|
30
34
|
if (args.length === 1) {
|
|
@@ -50,4 +54,5 @@ function whenIsNullableFilled(...args) {
|
|
|
50
54
|
exports.eitherNullableFilledKind = eitherNullableFilledKind;
|
|
51
55
|
exports.isNullableFilled = isNullableFilled;
|
|
52
56
|
exports.nullableFilled = nullableFilled;
|
|
57
|
+
exports.nullableFilledKind = nullableFilledKind;
|
|
53
58
|
exports.whenIsNullableFilled = whenIsNullableFilled;
|
|
@@ -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;
|