@duplojs/utils 1.0.6 → 1.0.7
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/common/index.d.ts +2 -0
- package/dist/common/justReturn.cjs +12 -0
- package/dist/common/justReturn.d.ts +3 -0
- package/dist/common/justReturn.mjs +10 -0
- package/dist/common/kind.d.ts +2 -2
- package/dist/common/when.d.ts +2 -2
- package/dist/common/whenElse.cjs +17 -0
- package/dist/common/whenElse.d.ts +5 -0
- package/dist/common/whenElse.mjs +15 -0
- package/dist/common/whenNot.d.ts +2 -2
- package/dist/either/bool/falsy.d.ts +2 -2
- package/dist/either/bool/truthy.d.ts +2 -2
- package/dist/either/left/when.d.ts +2 -2
- package/dist/either/nullable/empty.d.ts +2 -2
- package/dist/either/nullable/filled.d.ts +2 -2
- package/dist/either/nullish/empty.d.ts +2 -2
- package/dist/either/nullish/filled.d.ts +2 -2
- package/dist/either/optional/empty.d.ts +2 -2
- package/dist/either/optional/filled.d.ts +2 -2
- package/dist/either/right/when.d.ts +2 -2
- package/dist/either/whenHasInformation.d.ts +2 -2
- package/dist/index.cjs +4 -0
- package/dist/index.mjs +2 -0
- package/dist/object/entry.cjs +7 -0
- package/dist/object/entry.d.ts +2 -0
- package/dist/object/entry.mjs +5 -0
- package/dist/object/index.cjs +2 -0
- package/dist/object/index.d.ts +1 -0
- package/dist/object/index.mjs +1 -0
- package/dist/object/keys.cjs +4 -1
- package/dist/object/keys.d.ts +1 -1
- package/dist/object/keys.mjs +4 -1
- package/dist/pattern/result.d.ts +1 -1
- package/dist/pattern/when.d.ts +2 -2
- package/package.json +8 -3
package/dist/common/index.d.ts
CHANGED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type AnyValue } from "./types";
|
|
2
|
+
export declare function justReturn<GenericValue extends AnyValue>(value: GenericValue): (input: unknown) => GenericValue;
|
|
3
|
+
export declare function justReturn<GenericValue extends AnyValue>(input: unknown, value: GenericValue): GenericValue;
|
package/dist/common/kind.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Or, type IsEqual } from "./types";
|
|
1
|
+
import { type Or, type IsEqual, type BreakGenericLink } from "./types";
|
|
2
2
|
export interface KindHandler<GenericKindDefinition extends KindDefinition> {
|
|
3
3
|
definition: GenericKindDefinition;
|
|
4
4
|
runTimeKey: string;
|
|
@@ -7,7 +7,7 @@ export interface KindHandler<GenericKindDefinition extends KindDefinition> {
|
|
|
7
7
|
IsEqual<GenericValue, never>,
|
|
8
8
|
IsEqual<GenericValue, unknown>,
|
|
9
9
|
IsEqual<GenericValue, any>
|
|
10
|
-
]> extends true ? [input: GenericInput, value?: GenericValue] : [input: GenericInput, value: GenericValue]): Kind<GenericKindDefinition, GenericValue> & GenericInput
|
|
10
|
+
]> extends true ? [input: GenericInput, value?: GenericValue] : [input: GenericInput, value: GenericValue]): Kind<GenericKindDefinition, GenericValue> & BreakGenericLink<GenericInput>;
|
|
11
11
|
getValue<GenericKind extends Kind<GenericKindDefinition, GenericKindDefinition["value"]>>(input: GenericKind): GenericKind[SymbolKind][GenericKindDefinition["name"]];
|
|
12
12
|
}
|
|
13
13
|
export interface KindDefinition<GenericName extends string = string, GenericValue extends unknown = unknown> {
|
package/dist/common/when.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type EscapeVoid, type AnyValue } from "./types";
|
|
2
|
-
export declare function when<GenericInput extends AnyValue, GenericPredicatedInput extends GenericInput, GenericOutput extends AnyValue | EscapeVoid>(ifFunction: (input: GenericInput) => input is GenericPredicatedInput, theFunction: (predicatedInput: GenericPredicatedInput) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<GenericInput
|
|
1
|
+
import { type EscapeVoid, type AnyValue, type BreakGenericLink } from "./types";
|
|
2
|
+
export declare function when<GenericInput extends AnyValue, GenericPredicatedInput extends GenericInput, GenericOutput extends AnyValue | EscapeVoid>(ifFunction: (input: GenericInput) => input is GenericPredicatedInput, theFunction: (predicatedInput: GenericPredicatedInput) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<BreakGenericLink<GenericInput>, GenericPredicatedInput>;
|
|
3
3
|
export declare function when<GenericInput extends AnyValue, GenericPredicatedInput extends GenericInput, GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, ifFunction: (input: GenericInput) => input is GenericPredicatedInput, theFunction: (predicatedInput: GenericPredicatedInput) => GenericOutput): GenericOutput | Exclude<GenericInput, GenericPredicatedInput>;
|
|
4
4
|
export declare function when<GenericInput extends AnyValue, GenericOutput extends AnyValue | EscapeVoid>(ifFunction: (input: GenericInput) => boolean, theFunction: (predicatedInput: GenericInput) => GenericOutput): (input: GenericInput) => GenericOutput | GenericInput;
|
|
5
5
|
export declare function when<GenericInput extends AnyValue, GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, ifFunction: (input: GenericInput) => boolean, theFunction: (predicatedInput: GenericInput) => GenericOutput): GenericOutput | GenericInput;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function whenElse(...args) {
|
|
4
|
+
if (args.length === 3) {
|
|
5
|
+
const [ifFunction, theFunction, elseFunction] = args;
|
|
6
|
+
return (input) => whenElse(input, ifFunction, theFunction, elseFunction);
|
|
7
|
+
}
|
|
8
|
+
const [input, ifFunction, theFunction, elseFunction] = args;
|
|
9
|
+
if (ifFunction(input)) {
|
|
10
|
+
return theFunction(input);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return elseFunction(input);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.whenElse = whenElse;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type EscapeVoid, type AnyValue, type BreakGenericLink } from "./types";
|
|
2
|
+
export declare function whenElse<GenericInput extends AnyValue, GenericPredicatedInput extends GenericInput, GenericOutput1 extends AnyValue | EscapeVoid, GenericOutput2 extends AnyValue | EscapeVoid>(predicate: (input: GenericInput) => input is GenericPredicatedInput, theFunction: (predicatedInput: GenericPredicatedInput) => GenericOutput1, elseFunction: (predicatedInput: Exclude<GenericInput, GenericPredicatedInput>) => GenericOutput2): (input: GenericInput) => BreakGenericLink<GenericOutput1> | BreakGenericLink<GenericOutput2>;
|
|
3
|
+
export declare function whenElse<GenericInput extends AnyValue, GenericPredicatedInput extends GenericInput, GenericOutput1 extends AnyValue | EscapeVoid, GenericOutput2 extends AnyValue | EscapeVoid>(input: GenericInput, predicate: (input: GenericInput) => input is GenericPredicatedInput, theFunction: (predicatedInput: GenericPredicatedInput) => GenericOutput1, elseFunction: (predicatedInput: Exclude<GenericInput, GenericPredicatedInput>) => GenericOutput2): GenericOutput1 | GenericOutput2;
|
|
4
|
+
export declare function whenElse<GenericInput extends AnyValue, GenericOutput1 extends AnyValue | EscapeVoid, GenericOutput2 extends AnyValue | EscapeVoid>(predicate: (input: GenericInput) => boolean, theFunction: (predicatedInput: GenericInput) => GenericOutput1, elseFunction: (predicatedInput: GenericInput) => GenericOutput2): (input: GenericInput) => GenericOutput1 | GenericOutput2;
|
|
5
|
+
export declare function whenElse<GenericInput extends AnyValue, GenericOutput1 extends AnyValue | EscapeVoid, GenericOutput2 extends AnyValue | EscapeVoid>(input: GenericInput, predicate: (input: GenericInput) => boolean, theFunction: (predicatedInput: GenericInput) => GenericOutput1, elseFunction: (predicatedInput: GenericInput) => GenericOutput2): BreakGenericLink<GenericOutput1> | BreakGenericLink<GenericOutput2>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function whenElse(...args) {
|
|
2
|
+
if (args.length === 3) {
|
|
3
|
+
const [ifFunction, theFunction, elseFunction] = args;
|
|
4
|
+
return (input) => whenElse(input, ifFunction, theFunction, elseFunction);
|
|
5
|
+
}
|
|
6
|
+
const [input, ifFunction, theFunction, elseFunction] = args;
|
|
7
|
+
if (ifFunction(input)) {
|
|
8
|
+
return theFunction(input);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return elseFunction(input);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { whenElse };
|
package/dist/common/whenNot.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type EscapeVoid, type AnyValue } from "./types";
|
|
2
|
-
export declare function whenNot<GenericInput extends AnyValue, GenericPredicatedInput extends GenericInput, GenericOutput extends AnyValue | EscapeVoid>(ifFunction: (input: GenericInput) => input is GenericPredicatedInput, theFunction: (predicatedInput: Exclude<GenericInput, GenericPredicatedInput>) => GenericOutput): (input: GenericInput) => GenericOutput | GenericPredicatedInput
|
|
1
|
+
import { type EscapeVoid, type AnyValue, type BreakGenericLink } from "./types";
|
|
2
|
+
export declare function whenNot<GenericInput extends AnyValue, GenericPredicatedInput extends GenericInput, GenericOutput extends AnyValue | EscapeVoid>(ifFunction: (input: GenericInput) => input is GenericPredicatedInput, theFunction: (predicatedInput: Exclude<GenericInput, GenericPredicatedInput>) => GenericOutput): (input: GenericInput) => GenericOutput | BreakGenericLink<GenericPredicatedInput>;
|
|
3
3
|
export declare function whenNot<GenericInput extends AnyValue, GenericPredicatedInput extends GenericInput, GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, ifFunction: (input: GenericInput) => input is GenericPredicatedInput, theFunction: (predicatedInput: Exclude<GenericInput, GenericPredicatedInput>) => GenericOutput): GenericOutput | GenericPredicatedInput;
|
|
4
4
|
export declare function whenNot<GenericInput extends AnyValue, GenericOutput extends AnyValue | EscapeVoid>(ifFunction: (input: GenericInput) => boolean, theFunction: (predicatedInput: GenericInput) => GenericOutput): (input: GenericInput) => GenericOutput | GenericInput;
|
|
5
5
|
export declare function whenNot<GenericInput extends AnyValue, GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, ifFunction: (input: GenericInput) => boolean, theFunction: (predicatedInput: GenericInput) => GenericOutput): GenericOutput | GenericInput;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EscapeVoid, type AnyValue, type Unwrap } from "../../common";
|
|
1
|
+
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
2
2
|
import { type EitherLeft } from "../left";
|
|
3
3
|
import { type EitherRight } from "../right";
|
|
4
4
|
import { bool } from "./create";
|
|
@@ -13,6 +13,6 @@ export declare function boolFalsy<const GenericValue extends BoolFalsyValue = un
|
|
|
13
13
|
type Either = EitherRight | EitherLeft;
|
|
14
14
|
export declare function isBoolFalsy<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, EitherBoolFalsy>;
|
|
15
15
|
type ToEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof bool<GenericValue>>;
|
|
16
|
-
export declare function whenIsBoolFalsy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherBoolFalsy>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<GenericInput
|
|
16
|
+
export declare function whenIsBoolFalsy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherBoolFalsy>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<BreakGenericLink<GenericInput>>, EitherBoolFalsy>;
|
|
17
17
|
export declare function whenIsBoolFalsy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherBoolFalsy>>) => GenericOutput): GenericOutput | Exclude<ToEither<GenericInput>, EitherBoolFalsy>;
|
|
18
18
|
export {};
|
|
@@ -2,7 +2,7 @@ import { type EitherRight } from "../right";
|
|
|
2
2
|
import { bool } from "./create";
|
|
3
3
|
import { type EitherLeft } from "../left";
|
|
4
4
|
import { type Kind } from "../../common/kind";
|
|
5
|
-
import { type EscapeVoid, type AnyValue, type Unwrap } from "../../common";
|
|
5
|
+
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
6
6
|
import { eitherBoolKind } from "./base";
|
|
7
7
|
export declare const eitherBoolTruthyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"either-bool-truthy", unknown>>;
|
|
8
8
|
type _EitherBoolTruthy<GenericValue extends unknown = unknown> = (EitherRight<"bool", GenericValue> & Kind<typeof eitherBoolKind.definition> & Kind<typeof eitherBoolTruthyKind.definition>);
|
|
@@ -12,6 +12,6 @@ export declare function boolTruthy<const GenericValue extends unknown>(value: Ge
|
|
|
12
12
|
type Either = EitherRight | EitherLeft;
|
|
13
13
|
export declare function isBoolTruthy<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, EitherBoolTruthy>;
|
|
14
14
|
type ToEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof bool<GenericValue>>;
|
|
15
|
-
export declare function whenIsBoolTruthy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherBoolTruthy>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<GenericInput
|
|
15
|
+
export declare function whenIsBoolTruthy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherBoolTruthy>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<BreakGenericLink<GenericInput>>, EitherBoolTruthy>;
|
|
16
16
|
export declare function whenIsBoolTruthy<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherBoolTruthy>>) => GenericOutput): GenericOutput | Exclude<ToEither<GenericInput>, EitherBoolTruthy>;
|
|
17
17
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EscapeVoid, type AnyValue, type Unwrap } from "../../common";
|
|
1
|
+
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
2
2
|
import { type EitherLeft } from "./create";
|
|
3
|
-
export declare function whenIsLeft<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<GenericInput, EitherLeft>>) => GenericOutput): (input: GenericInput) => Exclude<GenericInput
|
|
3
|
+
export declare function whenIsLeft<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<GenericInput, EitherLeft>>) => GenericOutput): (input: GenericInput) => Exclude<BreakGenericLink<GenericInput>, EitherLeft> | GenericOutput;
|
|
4
4
|
export declare function whenIsLeft<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<GenericInput, EitherLeft>>) => GenericOutput): Exclude<GenericInput, EitherLeft> | GenericOutput;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EscapeVoid, type AnyValue, type Unwrap } from "../../common";
|
|
1
|
+
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
2
2
|
import { type Kind } from "../../common/kind";
|
|
3
3
|
import { type EitherLeft } from "../left";
|
|
4
4
|
import { type EitherRight } from "../right";
|
|
@@ -13,5 +13,5 @@ export declare function nullableEmpty(): EitherNullableEmpty;
|
|
|
13
13
|
export declare function isNullableEmpty<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, EitherNullableEmpty>;
|
|
14
14
|
type ToEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof nullable<GenericValue>>;
|
|
15
15
|
export declare function whenIsNullableEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherNullableEmpty>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<GenericInput>, EitherNullableEmpty>;
|
|
16
|
-
export declare function whenIsNullableEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherNullableEmpty>>) => GenericOutput): GenericOutput | Exclude<ToEither<GenericInput
|
|
16
|
+
export declare function whenIsNullableEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherNullableEmpty>>) => GenericOutput): GenericOutput | Exclude<ToEither<BreakGenericLink<GenericInput>>, EitherNullableEmpty>;
|
|
17
17
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EscapeVoid, type AnyValue, type Unwrap } from "../../common";
|
|
1
|
+
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
2
2
|
import { type Kind } from "../../common/kind";
|
|
3
3
|
import { type EitherLeft } from "../left";
|
|
4
4
|
import { type EitherRight } from "../right";
|
|
@@ -12,6 +12,6 @@ type Either = EitherRight | EitherLeft;
|
|
|
12
12
|
export declare function nullableFilled<const GenericValue extends unknown>(value: GenericValue): EitherNullableFilled<GenericValue>;
|
|
13
13
|
export declare function isNullableFilled<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, EitherNullableFilled>;
|
|
14
14
|
type ToEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof nullable<GenericValue>>;
|
|
15
|
-
export declare function whenIsNullableFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherNullableFilled>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<GenericInput
|
|
15
|
+
export declare function whenIsNullableFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherNullableFilled>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<BreakGenericLink<GenericInput>>, EitherNullableFilled>;
|
|
16
16
|
export declare function whenIsNullableFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherNullableFilled>>) => GenericOutput): GenericOutput | Exclude<ToEither<GenericInput>, EitherNullableFilled>;
|
|
17
17
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EscapeVoid, type AnyValue, type Unwrap } from "../../common";
|
|
1
|
+
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
2
2
|
import { type EitherLeft } from "../left";
|
|
3
3
|
import { type EitherRight } from "../right";
|
|
4
4
|
import { nullish } from "./create";
|
|
@@ -13,6 +13,6 @@ export declare function nullishEmpty<const GenericValue extends NullishValue = u
|
|
|
13
13
|
type Either = EitherRight | EitherLeft;
|
|
14
14
|
export declare function isNullishEmpty<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, EitherNullishEmpty>;
|
|
15
15
|
type ToEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof nullish<GenericValue>>;
|
|
16
|
-
export declare function whenIsNullishEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherNullishEmpty>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<GenericInput
|
|
16
|
+
export declare function whenIsNullishEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherNullishEmpty>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<BreakGenericLink<GenericInput>>, EitherNullishEmpty>;
|
|
17
17
|
export declare function whenIsNullishEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherNullishEmpty>>) => GenericOutput): GenericOutput | Exclude<ToEither<GenericInput>, EitherNullishEmpty>;
|
|
18
18
|
export {};
|
|
@@ -2,7 +2,7 @@ import { type EitherRight } from "../right";
|
|
|
2
2
|
import { type EitherLeft } from "../left";
|
|
3
3
|
import { nullish } from "./create";
|
|
4
4
|
import { type Kind } from "../../common/kind";
|
|
5
|
-
import { type EscapeVoid, type AnyValue, type Unwrap } from "../../common";
|
|
5
|
+
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
6
6
|
import { eitherNullishKind } from "./base";
|
|
7
7
|
export declare const eitherNullishFilledKind: import("../../common").KindHandler<import("../../common").KindDefinition<"either-nullish-filled", unknown>>;
|
|
8
8
|
type _EitherNullishFilled<GenericValue extends unknown = unknown> = (EitherRight<"nullish", GenericValue> & Kind<typeof eitherNullishKind.definition> & Kind<typeof eitherNullishFilledKind.definition>);
|
|
@@ -12,6 +12,6 @@ export declare function nullishFilled<const GenericValue extends unknown>(value:
|
|
|
12
12
|
type Either = EitherRight | EitherLeft;
|
|
13
13
|
export declare function isNullishFilled<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, EitherNullishFilled>;
|
|
14
14
|
type ToEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof nullish<GenericValue>>;
|
|
15
|
-
export declare function whenIsNullishFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherNullishFilled>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<GenericInput
|
|
15
|
+
export declare function whenIsNullishFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherNullishFilled>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToEither<BreakGenericLink<GenericInput>>, EitherNullishFilled>;
|
|
16
16
|
export declare function whenIsNullishFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToEither<GenericInput>, EitherNullishFilled>>) => GenericOutput): GenericOutput | Exclude<ToEither<GenericInput>, EitherNullishFilled>;
|
|
17
17
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EscapeVoid, type AnyValue, type Unwrap } from "../../common";
|
|
1
|
+
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
2
2
|
import { type Kind } from "../../common/kind";
|
|
3
3
|
import { type EitherLeft } from "../left";
|
|
4
4
|
import { type EitherRight } from "../right";
|
|
@@ -12,6 +12,6 @@ type Either = EitherRight | EitherLeft;
|
|
|
12
12
|
export declare function optionalEmpty(): EitherOptionalEmpty;
|
|
13
13
|
export declare function isOptionalEmpty<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, EitherOptionalEmpty>;
|
|
14
14
|
type ToOptionalEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof optional<GenericValue>>;
|
|
15
|
-
export declare function whenIsOptionalEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<GenericInput>, EitherOptionalEmpty>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToOptionalEither<GenericInput
|
|
15
|
+
export declare function whenIsOptionalEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<GenericInput>, EitherOptionalEmpty>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToOptionalEither<BreakGenericLink<GenericInput>>, EitherOptionalEmpty>;
|
|
16
16
|
export declare function whenIsOptionalEmpty<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<GenericInput>, EitherOptionalEmpty>>) => GenericOutput): GenericOutput | Exclude<ToOptionalEither<GenericInput>, EitherOptionalEmpty>;
|
|
17
17
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EscapeVoid, type AnyValue, type Unwrap } from "../../common";
|
|
1
|
+
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
2
2
|
import { type Kind } from "../../common/kind";
|
|
3
3
|
import { type EitherLeft } from "../left";
|
|
4
4
|
import { type EitherRight } from "../right";
|
|
@@ -12,6 +12,6 @@ type Either = EitherRight | EitherLeft;
|
|
|
12
12
|
export declare function optionalFilled<const GenericValue extends unknown>(value: GenericValue): EitherOptionalFilled<GenericValue>;
|
|
13
13
|
export declare function isOptionalFilled<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, EitherOptionalFilled>;
|
|
14
14
|
type ToOptionalEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof optional<GenericValue>>;
|
|
15
|
-
export declare function whenIsOptionalFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<GenericInput>, EitherOptionalFilled>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToOptionalEither<GenericInput
|
|
15
|
+
export declare function whenIsOptionalFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<GenericInput>, EitherOptionalFilled>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToOptionalEither<BreakGenericLink<GenericInput>>, EitherOptionalFilled>;
|
|
16
16
|
export declare function whenIsOptionalFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<GenericInput>, EitherOptionalFilled>>) => GenericOutput): GenericOutput | Exclude<ToOptionalEither<GenericInput>, EitherOptionalFilled>;
|
|
17
17
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EscapeVoid, type AnyValue, type Unwrap } from "../../common";
|
|
1
|
+
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
2
2
|
import { type EitherRight } from "./create";
|
|
3
|
-
export declare function whenIsRight<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<GenericInput, EitherRight>>) => GenericOutput): (input: GenericInput) => Exclude<GenericInput
|
|
3
|
+
export declare function whenIsRight<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<GenericInput, EitherRight>>) => GenericOutput): (input: GenericInput) => Exclude<BreakGenericLink<GenericInput>, EitherRight> | GenericOutput;
|
|
4
4
|
export declare function whenIsRight<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<GenericInput, EitherRight>>) => GenericOutput): Exclude<GenericInput, EitherRight> | GenericOutput;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type Kind, type WrappedValue, type AnyValue, type Unwrap } from "../common";
|
|
1
|
+
import { type Kind, type WrappedValue, type AnyValue, type Unwrap, type BreakGenericLink } from "../common";
|
|
2
2
|
import { type EitherRight } from "./right";
|
|
3
3
|
import { type EitherLeft } from "./left";
|
|
4
4
|
import { eitherInformationKind } from "./base";
|
|
5
5
|
type Either = EitherRight | EitherLeft;
|
|
6
|
-
export declare function whenHasInformation<const GenericInput extends unknown, GenericInformation extends (GenericInput extends Either ? ReturnType<typeof eitherInformationKind.getValue<GenericInput>> : never), const GenericOutput extends AnyValue>(information: GenericInformation | GenericInformation[], theFunction: (value: Unwrap<Extract<GenericInput, Kind<typeof eitherInformationKind.definition, GenericInformation> & WrappedValue>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<GenericInput
|
|
6
|
+
export declare function whenHasInformation<const GenericInput extends unknown, GenericInformation extends (GenericInput extends Either ? ReturnType<typeof eitherInformationKind.getValue<GenericInput>> : never), const GenericOutput extends AnyValue>(information: GenericInformation | GenericInformation[], theFunction: (value: Unwrap<Extract<GenericInput, Kind<typeof eitherInformationKind.definition, GenericInformation> & WrappedValue>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<BreakGenericLink<GenericInput>, Kind<typeof eitherInformationKind.definition, GenericInformation>>;
|
|
7
7
|
export declare function whenHasInformation<const GenericInput extends unknown, GenericInformation extends (GenericInput extends Either ? ReturnType<typeof eitherInformationKind.getValue<GenericInput>> : never), const GenericOutput extends AnyValue>(input: GenericInput, information: GenericInformation | GenericInformation[], theFunction: (value: Unwrap<Extract<GenericInput, Kind<typeof eitherInformationKind.definition, GenericInformation> & WrappedValue>>) => GenericOutput): GenericOutput | Exclude<GenericInput, Kind<typeof eitherInformationKind.definition, GenericInformation>>;
|
|
8
8
|
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -33,6 +33,8 @@ var not = require('./common/not.cjs');
|
|
|
33
33
|
var isType = require('./common/isType.cjs');
|
|
34
34
|
var and = require('./common/and.cjs');
|
|
35
35
|
var or = require('./common/or.cjs');
|
|
36
|
+
var whenElse = require('./common/whenElse.cjs');
|
|
37
|
+
var justReturn = require('./common/justReturn.cjs');
|
|
36
38
|
var index = require('./array/index.cjs');
|
|
37
39
|
var index$1 = require('./number/index.cjs');
|
|
38
40
|
var index$2 = require('./either/index.cjs');
|
|
@@ -82,6 +84,8 @@ exports.not = not.not;
|
|
|
82
84
|
exports.isType = isType.isType;
|
|
83
85
|
exports.and = and.and;
|
|
84
86
|
exports.or = or.or;
|
|
87
|
+
exports.whenElse = whenElse.whenElse;
|
|
88
|
+
exports.justReturn = justReturn.justReturn;
|
|
85
89
|
exports.A = index;
|
|
86
90
|
exports.DArray = index;
|
|
87
91
|
exports.DNumber = index$1;
|
package/dist/index.mjs
CHANGED
|
@@ -31,6 +31,8 @@ export { not } from './common/not.mjs';
|
|
|
31
31
|
export { isType } from './common/isType.mjs';
|
|
32
32
|
export { and } from './common/and.mjs';
|
|
33
33
|
export { or } from './common/or.mjs';
|
|
34
|
+
export { whenElse } from './common/whenElse.mjs';
|
|
35
|
+
export { justReturn } from './common/justReturn.mjs';
|
|
34
36
|
import * as index from './array/index.mjs';
|
|
35
37
|
export { index as A };
|
|
36
38
|
export { index as DArray };
|
package/dist/object/index.cjs
CHANGED
|
@@ -16,6 +16,7 @@ var pick = require('./pick.cjs');
|
|
|
16
16
|
var deepDiscriminate = require('./deepDiscriminate.cjs');
|
|
17
17
|
var getDeepProperty = require('./getDeepProperty.cjs');
|
|
18
18
|
var discriminate = require('./discriminate.cjs');
|
|
19
|
+
var entry = require('./entry.cjs');
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
|
|
@@ -35,3 +36,4 @@ exports.pick = pick.pick;
|
|
|
35
36
|
exports.deepDiscriminate = deepDiscriminate.deepDiscriminate;
|
|
36
37
|
exports.getDeepProperty = getDeepProperty.getDeepProperty;
|
|
37
38
|
exports.discriminate = discriminate.discriminate;
|
|
39
|
+
exports.entry = entry.entry;
|
package/dist/object/index.d.ts
CHANGED
package/dist/object/index.mjs
CHANGED
package/dist/object/keys.cjs
CHANGED
package/dist/object/keys.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function keys<GenericObject extends object>(object: GenericObject): (keyof GenericObject)[];
|
|
1
|
+
export declare function keys<GenericObject extends object>(object: GenericObject): (Exclude<keyof GenericObject, symbol>)[];
|
package/dist/object/keys.mjs
CHANGED
package/dist/pattern/result.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Kind, type WrappedValue } from "../common";
|
|
2
2
|
declare const patternResultKind: import("../common").KindHandler<import("../common").KindDefinition<"pattern-result", unknown>>;
|
|
3
|
-
export interface PatternResult<GenericValue extends unknown =
|
|
3
|
+
export interface PatternResult<GenericValue extends unknown = any> extends Kind<typeof patternResultKind.definition>, WrappedValue<GenericValue> {
|
|
4
4
|
}
|
|
5
5
|
export declare function result<const GenericValue extends unknown>(value: GenericValue): PatternResult<GenericValue>;
|
|
6
6
|
export declare const isResult: <GenericInput extends unknown>(input: GenericInput) => input is Extract<GenericInput, Kind<import("../common").KindDefinition<"pattern-result", unknown>, unknown>>;
|
package/dist/pattern/when.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type AnyValue } from "../common";
|
|
1
|
+
import { type AnyValue, type BreakGenericLink } from "../common";
|
|
2
2
|
import { type PatternResult } from "./result";
|
|
3
|
-
export declare function when<GenericInput extends AnyValue, GenericInputValue extends Exclude<GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, GenericPredicatedInput extends GenericInputValue, GenericOutput extends AnyValue>(predicate: (input: GenericInputValue) => input is GenericPredicatedInput, theFunction: (predicatedInput: GenericPredicatedInput) => GenericOutput): (input: (GenericInput | GenericInputPatternResult | GenericInputValue)) => (GenericInputPatternResult | Exclude<GenericInputValue
|
|
3
|
+
export declare function when<GenericInput extends AnyValue, GenericInputValue extends Exclude<GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, GenericPredicatedInput extends GenericInputValue, GenericOutput extends AnyValue>(predicate: (input: GenericInputValue) => input is GenericPredicatedInput, theFunction: (predicatedInput: GenericPredicatedInput) => GenericOutput): (input: (GenericInput | GenericInputPatternResult | GenericInputValue)) => (GenericInputPatternResult | Exclude<BreakGenericLink<GenericInputValue>, GenericPredicatedInput> | PatternResult<GenericOutput>);
|
|
4
4
|
export declare function when<GenericInput extends AnyValue, GenericInputValue extends Exclude<GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, GenericOutput extends AnyValue>(predicate: (input: GenericInputValue) => boolean, theFunction: (predicatedInput: GenericInputValue) => GenericOutput): (input: (GenericInput | GenericInputPatternResult | GenericInputValue)) => (GenericInputPatternResult | GenericInputValue | PatternResult<GenericOutput>);
|
|
5
5
|
export declare function when<GenericInput extends AnyValue, GenericInputValue extends Exclude<GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, GenericPredicatedInput extends GenericInputValue, GenericOutput extends AnyValue>(input: (GenericInput | GenericInputPatternResult | GenericInputValue), predicate: (input: GenericInputValue) => input is GenericPredicatedInput, theFunction: (predicatedInput: GenericPredicatedInput) => GenericOutput): (GenericInputPatternResult | Exclude<GenericInputValue, GenericPredicatedInput> | PatternResult<GenericOutput>);
|
|
6
6
|
export declare function when<GenericInput extends AnyValue, GenericInputValue extends Exclude<GenericInput, PatternResult>, GenericInputPatternResult extends Extract<GenericInput, PatternResult>, GenericOutput extends AnyValue>(input: (GenericInput | GenericInputPatternResult | GenericInputValue), predicate: (input: GenericInputValue) => boolean, theFunction: (predicatedInput: GenericInputValue) => GenericOutput): (GenericInputPatternResult | GenericInputValue | PatternResult<GenericOutput>);
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duplojs/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"author": "mathcovax",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"repository":
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/duplojs/utils.git"
|
|
10
|
+
},
|
|
8
11
|
"scripts": {
|
|
9
12
|
"build": "rollup --config && tsc-alias -p tsconfig.build.json",
|
|
10
13
|
"test:tu": "vitest --coverage",
|
|
@@ -46,7 +49,9 @@
|
|
|
46
49
|
"vite-tsconfig-paths": "5.1.4",
|
|
47
50
|
"vitest": "3.2.4"
|
|
48
51
|
},
|
|
49
|
-
"workspaces": [
|
|
52
|
+
"workspaces": [
|
|
53
|
+
"integration"
|
|
54
|
+
],
|
|
50
55
|
"keywords": [],
|
|
51
56
|
"engines": {
|
|
52
57
|
"node": ">=22.15.1"
|