@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,9 @@
|
|
|
1
1
|
import { createEitherKind } from '../kind.mjs';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const boolKind = createEitherKind("bool");
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated use boolKind
|
|
6
|
+
*/
|
|
7
|
+
const eitherBoolKind = boolKind;
|
|
4
8
|
|
|
5
|
-
export { eitherBoolKind };
|
|
9
|
+
export { boolKind, eitherBoolKind };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type FalsyValue, type IsEqual } from "../../common";
|
|
2
|
-
import { type
|
|
3
|
-
import { type
|
|
2
|
+
import { type BoolFalsy } from "./falsy";
|
|
3
|
+
import { type BoolTruthy } from "./truthy";
|
|
4
4
|
/**
|
|
5
|
-
* Converts any value into a boolean monad (
|
|
5
|
+
* Converts any value into a boolean monad (BoolTruthy or BoolFalsy). Handy to keep track of the test while benefiting from the whenIsBoolTruthy/whenIsBoolFalsy helpers.
|
|
6
6
|
*
|
|
7
7
|
* Signature: `bool(value)` → returns a value
|
|
8
8
|
*
|
|
@@ -15,7 +15,7 @@ import { type EitherBoolTruthy } from "./truthy";
|
|
|
15
15
|
* E.bool,
|
|
16
16
|
* );
|
|
17
17
|
*
|
|
18
|
-
* // type: E.
|
|
18
|
+
* // type: E.BoolFalsy<undefined> | E.BoolTruthy<"nest">
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
21
|
* @see https://utils.duplojs.dev/en/v1/api/either/bool
|
|
@@ -23,5 +23,5 @@ import { type EitherBoolTruthy } from "./truthy";
|
|
|
23
23
|
* @namespace E
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
|
-
export declare function bool<const GenericValue extends unknown = undefined>(value: GenericValue): GenericValue extends FalsyValue ?
|
|
27
|
-
export type Bool<GenericValue extends unknown> =
|
|
26
|
+
export declare function bool<const GenericValue extends unknown = undefined>(value: GenericValue): GenericValue extends FalsyValue ? BoolFalsy<GenericValue> : IsEqual<GenericValue, number> extends true ? BoolTruthy<GenericValue> | BoolFalsy<0> : IsEqual<GenericValue, bigint> extends true ? BoolTruthy<GenericValue> | BoolFalsy<0n> : IsEqual<GenericValue, string> extends true ? BoolTruthy<GenericValue> | BoolFalsy<""> : BoolTruthy<GenericValue>;
|
|
27
|
+
export type Bool<GenericValue extends unknown> = BoolTruthy<GenericValue> | BoolFalsy;
|
|
@@ -8,7 +8,11 @@ var is = require('../left/is.cjs');
|
|
|
8
8
|
var is$1 = require('../right/is.cjs');
|
|
9
9
|
var unwrap = require('../../common/unwrap.cjs');
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const boolFalsyKind = kind.createEitherKind("bool-falsy");
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated use boolFalsyKind
|
|
14
|
+
*/
|
|
15
|
+
const eitherBoolFalsyKind = boolFalsyKind;
|
|
12
16
|
/**
|
|
13
17
|
* {@include either/boolFalsy/index.md}
|
|
14
18
|
*/
|
|
@@ -19,12 +23,12 @@ const eitherBoolFalsyKind = kind.createEitherKind("bool-falsy");
|
|
|
19
23
|
* {@include either/whenIsBoolFalsy/index.md}
|
|
20
24
|
*/
|
|
21
25
|
function boolFalsy(value = undefined) {
|
|
22
|
-
return base.
|
|
26
|
+
return base.boolKind.setTo(boolFalsyKind.setTo(create.left("bool", value)));
|
|
23
27
|
}
|
|
24
28
|
function isBoolFalsy(input) {
|
|
25
29
|
return is.isLeft(input)
|
|
26
|
-
&& base.
|
|
27
|
-
&&
|
|
30
|
+
&& base.boolKind.has(input)
|
|
31
|
+
&& boolFalsyKind.has(input);
|
|
28
32
|
}
|
|
29
33
|
function whenIsBoolFalsy(...args) {
|
|
30
34
|
if (args.length === 1) {
|
|
@@ -48,6 +52,7 @@ function whenIsBoolFalsy(...args) {
|
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
exports.boolFalsy = boolFalsy;
|
|
55
|
+
exports.boolFalsyKind = boolFalsyKind;
|
|
51
56
|
exports.eitherBoolFalsyKind = eitherBoolFalsyKind;
|
|
52
57
|
exports.isBoolFalsy = isBoolFalsy;
|
|
53
58
|
exports.whenIsBoolFalsy = whenIsBoolFalsy;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink, type FalsyValue } from "../../common";
|
|
2
2
|
import { type Kind } from "../../common/kind";
|
|
3
|
-
import {
|
|
3
|
+
import { boolKind } from "./base";
|
|
4
4
|
import { bool } from "./create";
|
|
5
|
-
import { type
|
|
6
|
-
import { type
|
|
5
|
+
import { type Left } from "../left";
|
|
6
|
+
import { type Right } from "../right";
|
|
7
|
+
export declare const boolFalsyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/bool-falsy", unknown>>;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use boolFalsyKind
|
|
10
|
+
*/
|
|
7
11
|
export declare const eitherBoolFalsyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/bool-falsy", unknown>>;
|
|
8
|
-
type
|
|
9
|
-
export interface
|
|
12
|
+
type _BoolFalsy<GenericValue extends FalsyValue = FalsyValue> = (Left<"bool", GenericValue> & Kind<typeof boolKind.definition> & Kind<typeof boolFalsyKind.definition>);
|
|
13
|
+
export interface BoolFalsy<GenericValue extends FalsyValue = FalsyValue> extends _BoolFalsy<GenericValue> {
|
|
10
14
|
}
|
|
11
15
|
/**
|
|
12
|
-
*
|
|
16
|
+
* @deprecated use BoolFalsy
|
|
17
|
+
*/
|
|
18
|
+
export type EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> = BoolFalsy<GenericValue>;
|
|
19
|
+
/**
|
|
20
|
+
* Builds an Left<"bool"> for an explicitly falsy value (0, "", null, undefined, false).
|
|
13
21
|
*
|
|
14
22
|
* Signature: `boolFalsy(value)` → returns a value
|
|
15
23
|
*
|
|
@@ -26,7 +34,7 @@ export interface EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> e
|
|
|
26
34
|
* ),
|
|
27
35
|
* );
|
|
28
36
|
*
|
|
29
|
-
* // type: string | E.
|
|
37
|
+
* // type: string | E.BoolFalsy<"">
|
|
30
38
|
* ```
|
|
31
39
|
*
|
|
32
40
|
* @see https://utils.duplojs.dev/en/v1/api/either/boolFalsy
|
|
@@ -35,7 +43,7 @@ export interface EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> e
|
|
|
35
43
|
*
|
|
36
44
|
*/
|
|
37
45
|
/**
|
|
38
|
-
* Type guard that detects an
|
|
46
|
+
* Type guard that detects an BoolFalsy.
|
|
39
47
|
*
|
|
40
48
|
* Signature: `isBoolFalsy(input)` → returns a value
|
|
41
49
|
*
|
|
@@ -45,7 +53,7 @@ export interface EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> e
|
|
|
45
53
|
* const maybeInput = E.bool(true ? true : null);
|
|
46
54
|
*
|
|
47
55
|
* if (E.isBoolFalsy(maybeInput)) {
|
|
48
|
-
* // type: E.
|
|
56
|
+
* // type: E.BoolFalsy<null>
|
|
49
57
|
* }
|
|
50
58
|
* ```
|
|
51
59
|
*
|
|
@@ -69,7 +77,7 @@ export interface EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> e
|
|
|
69
77
|
* E.whenIsBoolFalsy(() => "falsy"),
|
|
70
78
|
* );
|
|
71
79
|
*
|
|
72
|
-
* // type: E.
|
|
80
|
+
* // type: E.BoolTruthy<"value"> | "falsy"
|
|
73
81
|
* ```
|
|
74
82
|
*
|
|
75
83
|
* @see https://utils.duplojs.dev/en/v1/api/either/whenIsBoolFalsy
|
|
@@ -77,10 +85,10 @@ export interface EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> e
|
|
|
77
85
|
* @namespace E
|
|
78
86
|
*
|
|
79
87
|
*/
|
|
80
|
-
export declare function boolFalsy<const GenericValue extends FalsyValue = undefined>(value?: GenericValue):
|
|
81
|
-
type Either =
|
|
82
|
-
export declare function isBoolFalsy<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput,
|
|
88
|
+
export declare function boolFalsy<const GenericValue extends FalsyValue = undefined>(value?: GenericValue): BoolFalsy<GenericValue>;
|
|
89
|
+
type Either = Right | Left;
|
|
90
|
+
export declare function isBoolFalsy<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, BoolFalsy>;
|
|
83
91
|
type ToEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof bool<GenericValue>>;
|
|
84
|
-
export declare function whenIsBoolFalsy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>,
|
|
85
|
-
export declare function whenIsBoolFalsy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>,
|
|
92
|
+
export declare function whenIsBoolFalsy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, BoolFalsy>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<BreakGenericLink<GenericInput>>, BoolFalsy>;
|
|
93
|
+
export declare function whenIsBoolFalsy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, BoolFalsy>>) => GenericOutput): GenericOutput | Exclude<ToEither<GenericInput>, BoolFalsy>;
|
|
86
94
|
export {};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { createEitherKind } from '../kind.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { boolKind } from './base.mjs';
|
|
3
3
|
import { bool } from './create.mjs';
|
|
4
4
|
import { left } from '../left/create.mjs';
|
|
5
5
|
import { isLeft } from '../left/is.mjs';
|
|
6
6
|
import { isRight } from '../right/is.mjs';
|
|
7
7
|
import { unwrap } from '../../common/unwrap.mjs';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const boolFalsyKind = createEitherKind("bool-falsy");
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use boolFalsyKind
|
|
12
|
+
*/
|
|
13
|
+
const eitherBoolFalsyKind = boolFalsyKind;
|
|
10
14
|
/**
|
|
11
15
|
* {@include either/boolFalsy/index.md}
|
|
12
16
|
*/
|
|
@@ -17,12 +21,12 @@ const eitherBoolFalsyKind = createEitherKind("bool-falsy");
|
|
|
17
21
|
* {@include either/whenIsBoolFalsy/index.md}
|
|
18
22
|
*/
|
|
19
23
|
function boolFalsy(value = undefined) {
|
|
20
|
-
return
|
|
24
|
+
return boolKind.setTo(boolFalsyKind.setTo(left("bool", value)));
|
|
21
25
|
}
|
|
22
26
|
function isBoolFalsy(input) {
|
|
23
27
|
return isLeft(input)
|
|
24
|
-
&&
|
|
25
|
-
&&
|
|
28
|
+
&& boolKind.has(input)
|
|
29
|
+
&& boolFalsyKind.has(input);
|
|
26
30
|
}
|
|
27
31
|
function whenIsBoolFalsy(...args) {
|
|
28
32
|
if (args.length === 1) {
|
|
@@ -45,4 +49,4 @@ function whenIsBoolFalsy(...args) {
|
|
|
45
49
|
return either;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
export { boolFalsy, eitherBoolFalsyKind, isBoolFalsy, whenIsBoolFalsy };
|
|
52
|
+
export { boolFalsy, boolFalsyKind, eitherBoolFalsyKind, isBoolFalsy, whenIsBoolFalsy };
|
|
@@ -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 boolTruthyKind = kind.createEitherKind("bool-truthy");
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated use boolTruthyKind
|
|
14
|
+
*/
|
|
15
|
+
const eitherBoolTruthyKind = boolTruthyKind;
|
|
12
16
|
/**
|
|
13
17
|
* {@include either/boolTruthy/index.md}
|
|
14
18
|
*/
|
|
@@ -19,12 +23,12 @@ const eitherBoolTruthyKind = kind.createEitherKind("bool-truthy");
|
|
|
19
23
|
* {@include either/whenIsBoolTruthy/index.md}
|
|
20
24
|
*/
|
|
21
25
|
function boolTruthy(value) {
|
|
22
|
-
return base.
|
|
26
|
+
return base.boolKind.setTo(boolTruthyKind.setTo(create.right("bool", value)));
|
|
23
27
|
}
|
|
24
28
|
function isBoolTruthy(input) {
|
|
25
29
|
return is.isRight(input)
|
|
26
|
-
&& base.
|
|
27
|
-
&&
|
|
30
|
+
&& base.boolKind.has(input)
|
|
31
|
+
&& boolTruthyKind.has(input);
|
|
28
32
|
}
|
|
29
33
|
function whenIsBoolTruthy(...args) {
|
|
30
34
|
if (args.length === 1) {
|
|
@@ -48,6 +52,7 @@ function whenIsBoolTruthy(...args) {
|
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
exports.boolTruthy = boolTruthy;
|
|
55
|
+
exports.boolTruthyKind = boolTruthyKind;
|
|
51
56
|
exports.eitherBoolTruthyKind = eitherBoolTruthyKind;
|
|
52
57
|
exports.isBoolTruthy = isBoolTruthy;
|
|
53
58
|
exports.whenIsBoolTruthy = whenIsBoolTruthy;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
2
2
|
import { type Kind } from "../../common/kind";
|
|
3
|
-
import {
|
|
4
|
-
import { type
|
|
5
|
-
import { type
|
|
3
|
+
import { boolKind } from "./base";
|
|
4
|
+
import { type Left } from "../left";
|
|
5
|
+
import { type Right } from "../right";
|
|
6
6
|
import { bool } from "./create";
|
|
7
|
+
export declare const boolTruthyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/bool-truthy", unknown>>;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use boolTruthyKind
|
|
10
|
+
*/
|
|
7
11
|
export declare const eitherBoolTruthyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/bool-truthy", unknown>>;
|
|
8
|
-
type
|
|
9
|
-
export interface
|
|
12
|
+
type _BoolTruthy<GenericValue extends unknown = unknown> = (Right<"bool", GenericValue> & Kind<typeof boolKind.definition> & Kind<typeof boolTruthyKind.definition>);
|
|
13
|
+
export interface BoolTruthy<GenericValue extends unknown = unknown> extends _BoolTruthy<GenericValue> {
|
|
10
14
|
}
|
|
11
15
|
/**
|
|
12
|
-
*
|
|
16
|
+
* @deprecated use BoolTruthy
|
|
17
|
+
*/
|
|
18
|
+
export type EitherBoolTruthy<GenericValue extends unknown = unknown> = BoolTruthy<GenericValue>;
|
|
19
|
+
/**
|
|
20
|
+
* Forces the creation of an Right<"bool"> by explicitly marking a truthy value.
|
|
13
21
|
*
|
|
14
22
|
* Signature: `boolTruthy(value)` → returns a value
|
|
15
23
|
*
|
|
@@ -26,7 +34,7 @@ export interface EitherBoolTruthy<GenericValue extends unknown = unknown> extend
|
|
|
26
34
|
* ),
|
|
27
35
|
* );
|
|
28
36
|
*
|
|
29
|
-
* // type: string | E.
|
|
37
|
+
* // type: string | E.BoolTruthy<`${string}@${string}`>
|
|
30
38
|
* ```
|
|
31
39
|
*
|
|
32
40
|
* @see https://utils.duplojs.dev/en/v1/api/either/boolTruthy
|
|
@@ -45,7 +53,7 @@ export interface EitherBoolTruthy<GenericValue extends unknown = unknown> extend
|
|
|
45
53
|
* const maybeInput = E.bool(true ? true : null);
|
|
46
54
|
*
|
|
47
55
|
* if (E.isBoolTruthy(maybeInput)) {
|
|
48
|
-
* // type: E.
|
|
56
|
+
* // type: E.BoolTruthy<true>
|
|
49
57
|
* }
|
|
50
58
|
* ```
|
|
51
59
|
*
|
|
@@ -55,7 +63,7 @@ export interface EitherBoolTruthy<GenericValue extends unknown = unknown> extend
|
|
|
55
63
|
*
|
|
56
64
|
*/
|
|
57
65
|
/**
|
|
58
|
-
* Callback executed only for
|
|
66
|
+
* Callback executed only for BoolTruthy values. Otherwise, the initial value is returned.
|
|
59
67
|
*
|
|
60
68
|
* **Supported call styles:**
|
|
61
69
|
* - Classic: `whenIsBoolTruthy(input, theFunction)` → returns a value
|
|
@@ -69,7 +77,7 @@ export interface EitherBoolTruthy<GenericValue extends unknown = unknown> extend
|
|
|
69
77
|
* E.whenIsBoolTruthy(S.toUpperCase),
|
|
70
78
|
* );
|
|
71
79
|
*
|
|
72
|
-
* // type: E.
|
|
80
|
+
* // type: E.BoolFalsy<null> | "VALUE"
|
|
73
81
|
* ```
|
|
74
82
|
*
|
|
75
83
|
* @see https://utils.duplojs.dev/en/v1/api/either/whenIsBoolTruthy
|
|
@@ -77,10 +85,10 @@ export interface EitherBoolTruthy<GenericValue extends unknown = unknown> extend
|
|
|
77
85
|
* @namespace E
|
|
78
86
|
*
|
|
79
87
|
*/
|
|
80
|
-
export declare function boolTruthy<const GenericValue extends unknown>(value: GenericValue):
|
|
81
|
-
type Either =
|
|
82
|
-
export declare function isBoolTruthy<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput,
|
|
88
|
+
export declare function boolTruthy<const GenericValue extends unknown>(value: GenericValue): BoolTruthy<GenericValue>;
|
|
89
|
+
type Either = Right | Left;
|
|
90
|
+
export declare function isBoolTruthy<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, BoolTruthy>;
|
|
83
91
|
type ToEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof bool<GenericValue>>;
|
|
84
|
-
export declare function whenIsBoolTruthy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>,
|
|
85
|
-
export declare function whenIsBoolTruthy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>,
|
|
92
|
+
export declare function whenIsBoolTruthy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, BoolTruthy>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<BreakGenericLink<GenericInput>>, BoolTruthy>;
|
|
93
|
+
export declare function whenIsBoolTruthy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<BreakGenericLink<GenericInput>>, BoolTruthy>>) => GenericOutput): GenericOutput | Exclude<ToEither<GenericInput>, BoolTruthy>;
|
|
86
94
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { boolKind } from './base.mjs';
|
|
2
2
|
import { createEitherKind } from '../kind.mjs';
|
|
3
3
|
import { bool } from './create.mjs';
|
|
4
4
|
import { right } from '../right/create.mjs';
|
|
@@ -6,7 +6,11 @@ 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 boolTruthyKind = createEitherKind("bool-truthy");
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use boolTruthyKind
|
|
12
|
+
*/
|
|
13
|
+
const eitherBoolTruthyKind = boolTruthyKind;
|
|
10
14
|
/**
|
|
11
15
|
* {@include either/boolTruthy/index.md}
|
|
12
16
|
*/
|
|
@@ -17,12 +21,12 @@ const eitherBoolTruthyKind = createEitherKind("bool-truthy");
|
|
|
17
21
|
* {@include either/whenIsBoolTruthy/index.md}
|
|
18
22
|
*/
|
|
19
23
|
function boolTruthy(value) {
|
|
20
|
-
return
|
|
24
|
+
return boolKind.setTo(boolTruthyKind.setTo(right("bool", value)));
|
|
21
25
|
}
|
|
22
26
|
function isBoolTruthy(input) {
|
|
23
27
|
return isRight(input)
|
|
24
|
-
&&
|
|
25
|
-
&&
|
|
28
|
+
&& boolKind.has(input)
|
|
29
|
+
&& boolTruthyKind.has(input);
|
|
26
30
|
}
|
|
27
31
|
function whenIsBoolTruthy(...args) {
|
|
28
32
|
if (args.length === 1) {
|
|
@@ -45,4 +49,4 @@ function whenIsBoolTruthy(...args) {
|
|
|
45
49
|
return either;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
export { boolTruthy, eitherBoolTruthyKind, isBoolTruthy, whenIsBoolTruthy };
|
|
52
|
+
export { boolTruthy, boolTruthyKind, eitherBoolTruthyKind, isBoolTruthy, whenIsBoolTruthy };
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var kind = require('../kind.cjs');
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const futureKind = kind.createEitherKind("future");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use futureKind
|
|
8
|
+
*/
|
|
9
|
+
const eitherFutureKind = futureKind;
|
|
6
10
|
|
|
7
11
|
exports.eitherFutureKind = eitherFutureKind;
|
|
12
|
+
exports.futureKind = futureKind;
|
|
@@ -1 +1,5 @@
|
|
|
1
|
+
export declare const futureKind: import("../..").KindHandler<import("../..").KindDefinition<"@DuplojsUtilsEither/future", unknown>>;
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated use futureKind
|
|
4
|
+
*/
|
|
1
5
|
export declare const eitherFutureKind: import("../..").KindHandler<import("../..").KindDefinition<"@DuplojsUtilsEither/future", unknown>>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { createEitherKind } from '../kind.mjs';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const futureKind = createEitherKind("future");
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated use futureKind
|
|
6
|
+
*/
|
|
7
|
+
const eitherFutureKind = futureKind;
|
|
4
8
|
|
|
5
|
-
export { eitherFutureKind };
|
|
9
|
+
export { eitherFutureKind, futureKind };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
3
|
-
import { type
|
|
4
|
-
import { type
|
|
1
|
+
import { type Left } from "../left";
|
|
2
|
+
import { type Right } from "../right";
|
|
3
|
+
import { type FutureSuccess } from "./success";
|
|
4
|
+
import { type FutureError } from "./error";
|
|
5
5
|
import { type IsEqual } from "../../common/types/isEqual";
|
|
6
6
|
import { type AnyValue } from "../../common";
|
|
7
|
-
type Either =
|
|
8
|
-
type ComputeEitherFutureSuccessResult<GenericValue extends unknown> = IsEqual<never, Exclude<GenericValue, Either>> extends false ?
|
|
9
|
-
type ComputeEitherFutureErrorResult<GenericValue extends unknown> = GenericValue extends Future<any> ? GenericValue : GenericValue extends Promise<unknown> ?
|
|
7
|
+
type Either = Right | Left;
|
|
8
|
+
type ComputeEitherFutureSuccessResult<GenericValue extends unknown> = IsEqual<never, Exclude<GenericValue, Either>> extends false ? FutureSuccess<Exclude<GenericValue, Either>> : never;
|
|
9
|
+
type ComputeEitherFutureErrorResult<GenericValue extends unknown> = GenericValue extends Future<any> ? GenericValue : GenericValue extends Promise<unknown> ? FutureError : never;
|
|
10
10
|
type ComputeFutureEitherResult<GenericValue extends unknown = unknown> = Extract<(Extract<Awaited<GenericValue>, Either> | ComputeEitherFutureSuccessResult<Awaited<GenericValue>> | ComputeEitherFutureErrorResult<GenericValue>), any>;
|
|
11
11
|
export type FutureEitherAllResult<GenericArray extends readonly unknown[] | []> = Future<{
|
|
12
12
|
-readonly [Prop in keyof GenericArray]: Awaited<Future<GenericArray[Prop]>>;
|
|
@@ -33,7 +33,7 @@ export declare class Future<const GenericValue extends unknown = unknown> extend
|
|
|
33
33
|
* );
|
|
34
34
|
*
|
|
35
35
|
* await maybePromise.then((value) => {
|
|
36
|
-
* // type: E.
|
|
36
|
+
* // type: E.FutureSuccess<number> | E.FutureError
|
|
37
37
|
* return value;
|
|
38
38
|
* });
|
|
39
39
|
* ```
|
|
@@ -4,13 +4,18 @@ var base = require('./base.cjs');
|
|
|
4
4
|
var kind = require('../kind.cjs');
|
|
5
5
|
var create = require('../left/create.cjs');
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const futureErrorKind = kind.createEitherKind("future-error");
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use futureErrorKind
|
|
10
|
+
*/
|
|
11
|
+
const eitherFutureErrorKind = futureErrorKind;
|
|
8
12
|
/**
|
|
9
13
|
* {@include either/futureError/index.md}
|
|
10
14
|
*/
|
|
11
15
|
function futureError(value) {
|
|
12
|
-
return base.
|
|
16
|
+
return base.futureKind.setTo(futureErrorKind.setTo(create.left("future", value)));
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
exports.eitherFutureErrorKind = eitherFutureErrorKind;
|
|
16
20
|
exports.futureError = futureError;
|
|
21
|
+
exports.futureErrorKind = futureErrorKind;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { type Kind } from "../../common/kind";
|
|
2
|
-
import { type
|
|
3
|
-
import {
|
|
2
|
+
import { type Left } from "../left";
|
|
3
|
+
import { futureKind } from "./base";
|
|
4
|
+
export declare const futureErrorKind: import("../../common/kind").KindHandler<import("../../common/kind").KindDefinition<"@DuplojsUtilsEither/future-error", unknown>>;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use futureErrorKind
|
|
7
|
+
*/
|
|
4
8
|
export declare const eitherFutureErrorKind: import("../../common/kind").KindHandler<import("../../common/kind").KindDefinition<"@DuplojsUtilsEither/future-error", unknown>>;
|
|
5
|
-
type
|
|
6
|
-
export interface
|
|
9
|
+
type _FutureError = (Left<"future", unknown> & Kind<typeof futureKind.definition> & Kind<typeof futureErrorKind.definition>);
|
|
10
|
+
export interface FutureError extends _FutureError {
|
|
7
11
|
}
|
|
8
12
|
/**
|
|
9
|
-
*
|
|
13
|
+
* @deprecated use FutureError
|
|
14
|
+
*/
|
|
15
|
+
export type EitherFutureError = FutureError;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a Future resolved with an Left<"future">, ideal for propagating a standardized rejection.
|
|
10
18
|
*
|
|
11
19
|
* Signature: `futureError(value)` → returns a value
|
|
12
20
|
*
|
|
@@ -15,7 +23,7 @@ export interface EitherFutureError extends _EitherFutureError {
|
|
|
15
23
|
* ```ts
|
|
16
24
|
* const future = E.futureError("error");
|
|
17
25
|
*
|
|
18
|
-
* // type: E.
|
|
26
|
+
* // type: E.FutureError
|
|
19
27
|
* ```
|
|
20
28
|
*
|
|
21
29
|
* @see https://utils.duplojs.dev/en/v1/api/either/futureError
|
|
@@ -23,5 +31,5 @@ export interface EitherFutureError extends _EitherFutureError {
|
|
|
23
31
|
* @namespace E
|
|
24
32
|
*
|
|
25
33
|
*/
|
|
26
|
-
export declare function futureError(value: unknown):
|
|
34
|
+
export declare function futureError(value: unknown): FutureError;
|
|
27
35
|
export {};
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { futureKind } from './base.mjs';
|
|
2
2
|
import { createEitherKind } from '../kind.mjs';
|
|
3
3
|
import { left } from '../left/create.mjs';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const futureErrorKind = createEitherKind("future-error");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use futureErrorKind
|
|
8
|
+
*/
|
|
9
|
+
const eitherFutureErrorKind = futureErrorKind;
|
|
6
10
|
/**
|
|
7
11
|
* {@include either/futureError/index.md}
|
|
8
12
|
*/
|
|
9
13
|
function futureError(value) {
|
|
10
|
-
return
|
|
14
|
+
return futureKind.setTo(futureErrorKind.setTo(left("future", value)));
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
export { eitherFutureErrorKind, futureError };
|
|
17
|
+
export { eitherFutureErrorKind, futureError, futureErrorKind };
|
|
@@ -4,13 +4,18 @@ var kind = require('../kind.cjs');
|
|
|
4
4
|
var base = require('./base.cjs');
|
|
5
5
|
var create = require('../right/create.cjs');
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const futureSuccessKind = kind.createEitherKind("future-success");
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use futureSuccessKind
|
|
10
|
+
*/
|
|
11
|
+
const eitherFutureSuccessKind = futureSuccessKind;
|
|
8
12
|
/**
|
|
9
13
|
* {@include either/futureSuccess/index.md}
|
|
10
14
|
*/
|
|
11
15
|
function futureSuccess(value) {
|
|
12
|
-
return base.
|
|
16
|
+
return base.futureKind.setTo(futureSuccessKind.setTo(create.right("future", value)));
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
exports.eitherFutureSuccessKind = eitherFutureSuccessKind;
|
|
16
20
|
exports.futureSuccess = futureSuccess;
|
|
21
|
+
exports.futureSuccessKind = futureSuccessKind;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { type Kind } from "../../common/kind";
|
|
2
|
-
import {
|
|
3
|
-
import { type
|
|
2
|
+
import { futureKind } from "./base";
|
|
3
|
+
import { type Right } from "../right";
|
|
4
|
+
export declare const futureSuccessKind: import("../../common/kind").KindHandler<import("../../common/kind").KindDefinition<"@DuplojsUtilsEither/future-success", unknown>>;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use futureSuccessKind
|
|
7
|
+
*/
|
|
4
8
|
export declare const eitherFutureSuccessKind: import("../../common/kind").KindHandler<import("../../common/kind").KindDefinition<"@DuplojsUtilsEither/future-success", unknown>>;
|
|
5
|
-
type
|
|
6
|
-
export interface
|
|
9
|
+
type _FutureSuccess<GenericValue extends unknown = unknown> = (Right<"future", GenericValue> & Kind<typeof futureKind.definition> & Kind<typeof futureSuccessKind.definition>);
|
|
10
|
+
export interface FutureSuccess<GenericValue extends unknown = unknown> extends _FutureSuccess<GenericValue> {
|
|
7
11
|
}
|
|
8
12
|
/**
|
|
9
|
-
*
|
|
13
|
+
* @deprecated use FutureSuccess
|
|
14
|
+
*/
|
|
15
|
+
export type EitherFutureSuccess<GenericValue extends unknown = unknown> = FutureSuccess<GenericValue>;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a Future resolved with an Right<"future">.
|
|
10
18
|
*
|
|
11
19
|
* Signature: `futureSuccess(value)` → returns a value
|
|
12
20
|
*
|
|
@@ -15,7 +23,7 @@ export interface EitherFutureSuccess<GenericValue extends unknown = unknown> ext
|
|
|
15
23
|
* ```ts
|
|
16
24
|
* const future = E.futureSuccess("value");
|
|
17
25
|
*
|
|
18
|
-
* // type: E.
|
|
26
|
+
* // type: E.FutureSuccess<"value">
|
|
19
27
|
* ```
|
|
20
28
|
*
|
|
21
29
|
* @see https://utils.duplojs.dev/en/v1/api/either/futureSuccess
|
|
@@ -23,5 +31,5 @@ export interface EitherFutureSuccess<GenericValue extends unknown = unknown> ext
|
|
|
23
31
|
* @namespace E
|
|
24
32
|
*
|
|
25
33
|
*/
|
|
26
|
-
export declare function futureSuccess<const GenericValue extends unknown>(value: GenericValue):
|
|
34
|
+
export declare function futureSuccess<const GenericValue extends unknown>(value: GenericValue): FutureSuccess<GenericValue>;
|
|
27
35
|
export {};
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { createEitherKind } from '../kind.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { futureKind } from './base.mjs';
|
|
3
3
|
import { right } from '../right/create.mjs';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const futureSuccessKind = createEitherKind("future-success");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use futureSuccessKind
|
|
8
|
+
*/
|
|
9
|
+
const eitherFutureSuccessKind = futureSuccessKind;
|
|
6
10
|
/**
|
|
7
11
|
* {@include either/futureSuccess/index.md}
|
|
8
12
|
*/
|
|
9
13
|
function futureSuccess(value) {
|
|
10
|
-
return
|
|
14
|
+
return futureKind.setTo(futureSuccessKind.setTo(right("future", value)));
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
export { eitherFutureSuccessKind, futureSuccess };
|
|
17
|
+
export { eitherFutureSuccessKind, futureSuccess, futureSuccessKind };
|
|
@@ -8,8 +8,8 @@ function hasInformation(...args) {
|
|
|
8
8
|
return (input) => hasInformation(input, information);
|
|
9
9
|
}
|
|
10
10
|
const [input, information] = args;
|
|
11
|
-
return kind.
|
|
12
|
-
&& kind.
|
|
11
|
+
return kind.informationKind.has(input)
|
|
12
|
+
&& kind.informationKind.getValue(input) === information;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
exports.hasInformation = hasInformation;
|