@duplojs/utils 1.0.5 → 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/array/group.cjs +1 -1
- package/dist/array/group.mjs +2 -2
- package/dist/array/index.cjs +3 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/index.mjs +2 -1
- package/dist/array/length.cjs +7 -0
- package/dist/array/length.d.ts +1 -0
- package/dist/array/length.mjs +5 -0
- package/dist/array/reduce.cjs +8 -9
- package/dist/array/reduce.d.ts +6 -8
- package/dist/array/reduce.mjs +8 -10
- package/dist/array/reduceRight.cjs +4 -12
- package/dist/array/reduceRight.d.ts +3 -30
- package/dist/array/reduceRight.mjs +4 -12
- package/dist/array/types/index.d.ts +1 -0
- package/dist/common/and.cjs +17 -0
- package/dist/common/and.mjs +15 -0
- package/dist/common/index.d.ts +4 -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/or.cjs +17 -0
- package/dist/common/or.mjs +15 -0
- 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/create.d.ts +1 -0
- package/dist/either/bool/falsy.d.ts +2 -2
- package/dist/either/bool/truthy.d.ts +2 -2
- package/dist/either/future/create.d.ts +1 -1
- package/dist/either/left/when.d.ts +2 -2
- package/dist/either/nullable/create.d.ts +1 -0
- package/dist/either/nullable/empty.d.ts +2 -2
- package/dist/either/nullable/filled.d.ts +2 -2
- package/dist/either/nullish/create.d.ts +1 -0
- package/dist/either/nullish/empty.d.ts +2 -2
- package/dist/either/nullish/filled.d.ts +2 -2
- package/dist/either/optional/create.d.ts +1 -0
- package/dist/either/optional/empty.d.ts +2 -2
- package/dist/either/optional/filled.d.ts +2 -2
- package/dist/either/right/asyncPipe.cjs +8 -4
- package/dist/either/right/asyncPipe.d.ts +13 -15
- package/dist/either/right/asyncPipe.mjs +8 -4
- package/dist/either/right/pipe.cjs +15 -8
- package/dist/either/right/pipe.d.ts +13 -14
- package/dist/either/right/pipe.mjs +12 -5
- package/dist/either/right/when.d.ts +2 -2
- package/dist/either/whenHasInformation.d.ts +2 -2
- package/dist/generator/asyncReduce.cjs +4 -12
- package/dist/generator/asyncReduce.d.ts +3 -30
- package/dist/generator/asyncReduce.mjs +4 -12
- package/dist/generator/index.cjs +1 -0
- package/dist/generator/index.mjs +1 -1
- package/dist/generator/reduce.cjs +8 -9
- package/dist/generator/reduce.d.ts +8 -10
- package/dist/generator/reduce.mjs +8 -10
- package/dist/index.cjs +8 -0
- package/dist/index.mjs +4 -0
- package/dist/object/discriminate.d.ts +2 -3
- 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/dist/string/index.cjs +2 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.mjs +1 -0
- package/dist/string/length.cjs +7 -0
- package/dist/string/length.d.ts +2 -0
- package/dist/string/length.mjs +5 -0
- package/dist/string/types/index.d.ts +1 -0
- package/dist/string/types/stringLength.d.ts +2 -0
- package/package.json +8 -3
package/dist/array/group.cjs
CHANGED
|
@@ -19,7 +19,7 @@ function group(...args) {
|
|
|
19
19
|
return (array) => group(array, theFunction);
|
|
20
20
|
}
|
|
21
21
|
const [array, theFunction] = args;
|
|
22
|
-
return reduce.reduce(array, ({
|
|
22
|
+
return reduce.reduce(array, reduce.reduceFrom({}), ({ index, element, lastValue, nextWithObject }) => {
|
|
23
23
|
const { group, value } = theFunction(element, {
|
|
24
24
|
index,
|
|
25
25
|
output: groupOutput,
|
package/dist/array/group.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { reduce } from './reduce.mjs';
|
|
1
|
+
import { reduce, reduceFrom } from './reduce.mjs';
|
|
2
2
|
|
|
3
3
|
function groupOutput(...args) {
|
|
4
4
|
if (args.length === 1) {
|
|
@@ -17,7 +17,7 @@ function group(...args) {
|
|
|
17
17
|
return (array) => group(array, theFunction);
|
|
18
18
|
}
|
|
19
19
|
const [array, theFunction] = args;
|
|
20
|
-
return reduce(array, ({
|
|
20
|
+
return reduce(array, reduceFrom({}), ({ index, element, lastValue, nextWithObject }) => {
|
|
21
21
|
const { group, value } = theFunction(element, {
|
|
22
22
|
index,
|
|
23
23
|
output: groupOutput,
|
package/dist/array/index.cjs
CHANGED
|
@@ -48,6 +48,7 @@ var _delete$1 = require('./findAndSplice/delete.cjs');
|
|
|
48
48
|
var insert$1 = require('./findAndSplice/insert.cjs');
|
|
49
49
|
var replace$1 = require('./findAndSplice/replace.cjs');
|
|
50
50
|
var sum = require('./sum.cjs');
|
|
51
|
+
var length = require('./length.cjs');
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
|
|
@@ -64,6 +65,7 @@ exports.minElements = minElements.minElements;
|
|
|
64
65
|
exports.minOf = minOf.minOf;
|
|
65
66
|
exports.push = push.push;
|
|
66
67
|
exports.reduce = reduce.reduce;
|
|
68
|
+
exports.reduceFrom = reduce.reduceFrom;
|
|
67
69
|
exports.some = some.some;
|
|
68
70
|
exports.sort = _default.sort;
|
|
69
71
|
exports.sortNumber = number.sortNumber;
|
|
@@ -100,3 +102,4 @@ exports.findAndSpliceDelete = _delete$1.findAndSpliceDelete;
|
|
|
100
102
|
exports.findAndSpliceInsert = insert$1.findAndSpliceInsert;
|
|
101
103
|
exports.findAndSpliceReplace = replace$1.findAndSpliceReplace;
|
|
102
104
|
exports.sum = sum.sum;
|
|
105
|
+
exports.length = length.length;
|
package/dist/array/index.d.ts
CHANGED
package/dist/array/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ export { maxOf } from './maxOf.mjs';
|
|
|
9
9
|
export { minElements } from './minElements.mjs';
|
|
10
10
|
export { minOf } from './minOf.mjs';
|
|
11
11
|
export { push } from './push.mjs';
|
|
12
|
-
export { reduce } from './reduce.mjs';
|
|
12
|
+
export { reduce, reduceFrom } from './reduce.mjs';
|
|
13
13
|
export { some } from './some.mjs';
|
|
14
14
|
export { sort } from './sort/default.mjs';
|
|
15
15
|
export { sortNumber } from './sort/number.mjs';
|
|
@@ -46,3 +46,4 @@ export { findAndSpliceDelete } from './findAndSplice/delete.mjs';
|
|
|
46
46
|
export { findAndSpliceInsert } from './findAndSplice/insert.mjs';
|
|
47
47
|
export { findAndSpliceReplace } from './findAndSplice/replace.mjs';
|
|
48
48
|
export { sum } from './sum.mjs';
|
|
49
|
+
export { length } from './length.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function length<GenericInput extends readonly unknown[]>(input: GenericInput): GenericInput["length"];
|
package/dist/array/reduce.cjs
CHANGED
|
@@ -6,18 +6,16 @@ var unwrap = require('../common/unwrap.cjs');
|
|
|
6
6
|
var override = require('../object/override.cjs');
|
|
7
7
|
|
|
8
8
|
const arrayReduceFromKind = kind.createKind("array-reduce-from");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
9
|
+
function reduceFrom(value) {
|
|
10
|
+
return arrayReduceFromKind.addTo(wrapValue.wrapValue(value));
|
|
11
|
+
}
|
|
12
12
|
function reduce(...args) {
|
|
13
13
|
if (args.length === 2) {
|
|
14
|
-
const [
|
|
15
|
-
return (array) => reduce(array,
|
|
14
|
+
const [fromValue, theFunction] = args;
|
|
15
|
+
return (array) => reduce(array, fromValue, theFunction);
|
|
16
16
|
}
|
|
17
|
-
const [array,
|
|
18
|
-
let lastValue = unwrap.unwrap(
|
|
19
|
-
? getStartValue(getStartValueParams)
|
|
20
|
-
: getStartValue);
|
|
17
|
+
const [array, fromValue, theFunction] = args;
|
|
18
|
+
let lastValue = unwrap.unwrap(fromValue);
|
|
21
19
|
for (let index = 0; index < array.length; index++) {
|
|
22
20
|
const element = array[index];
|
|
23
21
|
const result = theFunction({
|
|
@@ -39,3 +37,4 @@ function reduce(...args) {
|
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
exports.reduce = reduce;
|
|
40
|
+
exports.reduceFrom = reduceFrom;
|
package/dist/array/reduce.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ interface ArrayReduceNext<GenericOutput extends unknown> {
|
|
|
8
8
|
interface ArrayReduceExit<GenericOutput extends unknown> {
|
|
9
9
|
"-exit": GenericOutput;
|
|
10
10
|
}
|
|
11
|
-
type
|
|
11
|
+
export type ArrayReduceExitOrNext<GenericOutput extends unknown = unknown> = ArrayReduceExit<GenericOutput> | ArrayReduceNext<GenericOutput>;
|
|
12
12
|
export interface ArrayReduceFunctionParams<GenericElement extends unknown = unknown, GenericOutput extends unknown = unknown> {
|
|
13
13
|
element: GenericElement;
|
|
14
14
|
index: number;
|
|
@@ -20,11 +20,9 @@ export interface ArrayReduceFunctionParams<GenericElement extends unknown = unkn
|
|
|
20
20
|
declare const arrayReduceFromKind: import("../common").KindHandler<import("../common").KindDefinition<"array-reduce-from", unknown>>;
|
|
21
21
|
export interface ArrayReduceFromResult<GenericValue extends unknown = unknown> extends Kind<typeof arrayReduceFromKind.definition>, WrappedValue<GenericValue> {
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export declare function reduce<GenericElement extends unknown, GenericReduceFrom extends
|
|
27
|
-
export declare function reduce<GenericElement extends unknown, GenericReduceFrom extends ArrayReduceFromResult>(
|
|
28
|
-
export declare function reduce<GenericElement extends unknown, GenericReduceFrom extends number | string | bigint | boolean>(array: readonly GenericElement[], startValue: GenericReduceFrom, theFunction: (params: ArrayReduceFunctionParams<GenericElement, ToLargeEnsemble<GenericReduceFrom>>) => ExitOrNext<ToLargeEnsemble<GenericReduceFrom>>): ToLargeEnsemble<GenericReduceFrom>;
|
|
29
|
-
export declare function reduce<GenericElement extends unknown, GenericReduceFrom extends ArrayReduceFromResult>(array: readonly GenericElement[], getStartValue: (params: GetStartValueParams) => GenericReduceFrom, theFunction: (params: ArrayReduceFunctionParams<GenericElement, Unwrap<GenericReduceFrom>>) => ExitOrNext<Unwrap<GenericReduceFrom>>): Unwrap<GenericReduceFrom>;
|
|
23
|
+
export declare function reduceFrom<GenericValue extends unknown>(value: GenericValue): ArrayReduceFromResult<GenericValue>;
|
|
24
|
+
export type ArrayEligibleReduceFromValue = number | string | bigint | boolean | ArrayReduceFromResult;
|
|
25
|
+
export type ArrayReduceFromValue<GenericValue extends ArrayEligibleReduceFromValue> = GenericValue extends ArrayReduceFromResult ? Unwrap<GenericValue> : ToLargeEnsemble<GenericValue>;
|
|
26
|
+
export declare function reduce<GenericElement extends unknown, GenericReduceFrom extends ArrayEligibleReduceFromValue>(startValue: GenericReduceFrom, theFunction: (params: ArrayReduceFunctionParams<GenericElement, ArrayReduceFromValue<GenericReduceFrom>>) => ArrayReduceExitOrNext<ArrayReduceFromValue<GenericReduceFrom>>): (array: readonly GenericElement[]) => ArrayReduceFromValue<GenericReduceFrom>;
|
|
27
|
+
export declare function reduce<GenericElement extends unknown, GenericReduceFrom extends number | string | bigint | boolean | ArrayReduceFromResult>(array: readonly GenericElement[], startValue: GenericReduceFrom, theFunction: (params: ArrayReduceFunctionParams<GenericElement, ArrayReduceFromValue<GenericReduceFrom>>) => ArrayReduceExitOrNext<ArrayReduceFromValue<GenericReduceFrom>>): ArrayReduceFromValue<GenericReduceFrom>;
|
|
30
28
|
export {};
|
package/dist/array/reduce.mjs
CHANGED
|
@@ -4,18 +4,16 @@ import { unwrap } from '../common/unwrap.mjs';
|
|
|
4
4
|
import { override } from '../object/override.mjs';
|
|
5
5
|
|
|
6
6
|
const arrayReduceFromKind = createKind("array-reduce-from");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
7
|
+
function reduceFrom(value) {
|
|
8
|
+
return arrayReduceFromKind.addTo(wrapValue(value));
|
|
9
|
+
}
|
|
10
10
|
function reduce(...args) {
|
|
11
11
|
if (args.length === 2) {
|
|
12
|
-
const [
|
|
13
|
-
return (array) => reduce(array,
|
|
12
|
+
const [fromValue, theFunction] = args;
|
|
13
|
+
return (array) => reduce(array, fromValue, theFunction);
|
|
14
14
|
}
|
|
15
|
-
const [array,
|
|
16
|
-
let lastValue = unwrap(
|
|
17
|
-
? getStartValue(getStartValueParams)
|
|
18
|
-
: getStartValue);
|
|
15
|
+
const [array, fromValue, theFunction] = args;
|
|
16
|
+
let lastValue = unwrap(fromValue);
|
|
19
17
|
for (let index = 0; index < array.length; index++) {
|
|
20
18
|
const element = array[index];
|
|
21
19
|
const result = theFunction({
|
|
@@ -36,4 +34,4 @@ function reduce(...args) {
|
|
|
36
34
|
return lastValue;
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
export { reduce };
|
|
37
|
+
export { reduce, reduceFrom };
|
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var kind = require('../common/kind.cjs');
|
|
4
|
-
var wrapValue = require('../common/wrapValue.cjs');
|
|
5
3
|
var unwrap = require('../common/unwrap.cjs');
|
|
6
4
|
var override = require('../object/override.cjs');
|
|
7
5
|
|
|
8
|
-
const arrayReduceRightFromKind = kind.createKind("array-reduce-right-from");
|
|
9
|
-
const getStartValueParams = {
|
|
10
|
-
from: (value) => arrayReduceRightFromKind.addTo(wrapValue.wrapValue(value), null),
|
|
11
|
-
};
|
|
12
6
|
function reduceRight(...args) {
|
|
13
7
|
if (args.length === 2) {
|
|
14
|
-
const [
|
|
15
|
-
return (array) => reduceRight(array,
|
|
8
|
+
const [fromValue, theFunction] = args;
|
|
9
|
+
return (array) => reduceRight(array, fromValue, theFunction);
|
|
16
10
|
}
|
|
17
|
-
const [array,
|
|
18
|
-
let lastValue = unwrap.unwrap(
|
|
19
|
-
? getStartValue(getStartValueParams)
|
|
20
|
-
: getStartValue);
|
|
11
|
+
const [array, fromValue, theFunction] = args;
|
|
12
|
+
let lastValue = unwrap.unwrap(fromValue);
|
|
21
13
|
for (let index = array.length - 1; index >= 0; index--) {
|
|
22
14
|
const element = array[index];
|
|
23
15
|
const result = theFunction({
|
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { type ToLargeEnsemble } from "../common";
|
|
5
|
-
interface ArrayReduceRightNext<GenericOutput extends unknown> {
|
|
6
|
-
"-next": GenericOutput;
|
|
7
|
-
}
|
|
8
|
-
interface ArrayReduceRightExit<GenericOutput extends unknown> {
|
|
9
|
-
"-exit": GenericOutput;
|
|
10
|
-
}
|
|
11
|
-
type ExitOrNextRight<GenericOutput extends unknown = unknown> = ArrayReduceRightExit<GenericOutput> | ArrayReduceRightNext<GenericOutput>;
|
|
12
|
-
export interface ArrayReduceRightFunctionParams<GenericElement extends unknown = unknown, GenericOutput extends unknown = unknown> {
|
|
13
|
-
element: GenericElement;
|
|
14
|
-
index: number;
|
|
15
|
-
lastValue: GenericOutput;
|
|
16
|
-
nextWithObject: GenericOutput extends object ? (object1: GenericOutput, object2: Partial<GenericOutput>) => ArrayReduceRightNext<GenericOutput> : undefined;
|
|
17
|
-
next(output: GenericOutput): ArrayReduceRightNext<GenericOutput>;
|
|
18
|
-
exit(output: GenericOutput): ArrayReduceRightExit<GenericOutput>;
|
|
19
|
-
}
|
|
20
|
-
declare const arrayReduceRightFromKind: import("../common").KindHandler<import("../common").KindDefinition<"array-reduce-right-from", unknown>>;
|
|
21
|
-
export interface ArrayReduceRightFromResult<GenericValue extends unknown = unknown> extends Kind<typeof arrayReduceRightFromKind.definition>, WrappedValue<GenericValue> {
|
|
22
|
-
}
|
|
23
|
-
interface GetStartValueParams {
|
|
24
|
-
from<GenericValue extends unknown>(value: GenericValue): ArrayReduceRightFromResult<GenericValue>;
|
|
25
|
-
}
|
|
26
|
-
export declare function reduceRight<GenericElement extends unknown, GenericReduceFrom extends number | string | bigint | boolean>(startValue: GenericReduceFrom, theFunction: (params: ArrayReduceRightFunctionParams<GenericElement, ToLargeEnsemble<GenericReduceFrom>>) => ExitOrNextRight<ToLargeEnsemble<GenericReduceFrom>>): (array: readonly GenericElement[]) => ToLargeEnsemble<GenericReduceFrom>;
|
|
27
|
-
export declare function reduceRight<GenericElement extends unknown, GenericReduceFrom extends ArrayReduceRightFromResult>(getStartValue: (params: GetStartValueParams) => GenericReduceFrom, theFunction: (params: ArrayReduceRightFunctionParams<GenericElement, Unwrap<GenericReduceFrom>>) => ExitOrNextRight<Unwrap<GenericReduceFrom>>): (array: readonly GenericElement[]) => Unwrap<GenericReduceFrom>;
|
|
28
|
-
export declare function reduceRight<GenericElement extends unknown, GenericReduceFrom extends number | string | bigint | boolean>(array: readonly GenericElement[], startValue: GenericReduceFrom, theFunction: (params: ArrayReduceRightFunctionParams<GenericElement, ToLargeEnsemble<GenericReduceFrom>>) => ExitOrNextRight<ToLargeEnsemble<GenericReduceFrom>>): ToLargeEnsemble<GenericReduceFrom>;
|
|
29
|
-
export declare function reduceRight<GenericElement extends unknown, GenericReduceFrom extends ArrayReduceRightFromResult>(array: readonly GenericElement[], getStartValue: (params: GetStartValueParams) => GenericReduceFrom, theFunction: (params: ArrayReduceRightFunctionParams<GenericElement, Unwrap<GenericReduceFrom>>) => ExitOrNextRight<Unwrap<GenericReduceFrom>>): Unwrap<GenericReduceFrom>;
|
|
30
|
-
export {};
|
|
1
|
+
import { type ArrayReduceFunctionParams, type ArrayReduceFromResult, type ArrayReduceExitOrNext, type ArrayReduceFromValue } from "./reduce";
|
|
2
|
+
export declare function reduceRight<GenericElement extends unknown, GenericReduceFrom extends number | string | bigint | boolean | ArrayReduceFromResult>(startValue: GenericReduceFrom, theFunction: (params: ArrayReduceFunctionParams<GenericElement, ArrayReduceFromValue<GenericReduceFrom>>) => ArrayReduceExitOrNext<ArrayReduceFromValue<GenericReduceFrom>>): (array: readonly GenericElement[]) => ArrayReduceFromValue<GenericReduceFrom>;
|
|
3
|
+
export declare function reduceRight<GenericElement extends unknown, GenericReduceFrom extends number | string | bigint | boolean | ArrayReduceFromResult>(array: readonly GenericElement[], startValue: GenericReduceFrom, theFunction: (params: ArrayReduceFunctionParams<GenericElement, ArrayReduceFromValue<GenericReduceFrom>>) => ArrayReduceExitOrNext<ArrayReduceFromValue<GenericReduceFrom>>): ArrayReduceFromValue<GenericReduceFrom>;
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
import { createKind } from '../common/kind.mjs';
|
|
2
|
-
import { wrapValue } from '../common/wrapValue.mjs';
|
|
3
1
|
import { unwrap } from '../common/unwrap.mjs';
|
|
4
2
|
import { override } from '../object/override.mjs';
|
|
5
3
|
|
|
6
|
-
const arrayReduceRightFromKind = createKind("array-reduce-right-from");
|
|
7
|
-
const getStartValueParams = {
|
|
8
|
-
from: (value) => arrayReduceRightFromKind.addTo(wrapValue(value), null),
|
|
9
|
-
};
|
|
10
4
|
function reduceRight(...args) {
|
|
11
5
|
if (args.length === 2) {
|
|
12
|
-
const [
|
|
13
|
-
return (array) => reduceRight(array,
|
|
6
|
+
const [fromValue, theFunction] = args;
|
|
7
|
+
return (array) => reduceRight(array, fromValue, theFunction);
|
|
14
8
|
}
|
|
15
|
-
const [array,
|
|
16
|
-
let lastValue = unwrap(
|
|
17
|
-
? getStartValue(getStartValueParams)
|
|
18
|
-
: getStartValue);
|
|
9
|
+
const [array, fromValue, theFunction] = args;
|
|
10
|
+
let lastValue = unwrap(fromValue);
|
|
19
11
|
for (let index = array.length - 1; index >= 0; index--) {
|
|
20
12
|
const element = array[index];
|
|
21
13
|
const result = theFunction({
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function and(...args) {
|
|
4
|
+
if (args.length === 1) {
|
|
5
|
+
const [predicatedList] = args;
|
|
6
|
+
return (input) => and(input, predicatedList);
|
|
7
|
+
}
|
|
8
|
+
const [input, predicatedList] = args;
|
|
9
|
+
for (const predicate of predicatedList) {
|
|
10
|
+
if (!predicate(input)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.and = and;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function and(...args) {
|
|
2
|
+
if (args.length === 1) {
|
|
3
|
+
const [predicatedList] = args;
|
|
4
|
+
return (input) => and(input, predicatedList);
|
|
5
|
+
}
|
|
6
|
+
const [input, predicatedList] = args;
|
|
7
|
+
for (const predicate of predicatedList) {
|
|
8
|
+
if (!predicate(input)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { and };
|
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> {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function or(...args) {
|
|
4
|
+
if (args.length === 1) {
|
|
5
|
+
const [predicatedList] = args;
|
|
6
|
+
return (input) => or(input, predicatedList);
|
|
7
|
+
}
|
|
8
|
+
const [input, predicatedList] = args;
|
|
9
|
+
for (const predicate of predicatedList) {
|
|
10
|
+
if (predicate(input)) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.or = or;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function or(...args) {
|
|
2
|
+
if (args.length === 1) {
|
|
3
|
+
const [predicatedList] = args;
|
|
4
|
+
return (input) => or(input, predicatedList);
|
|
5
|
+
}
|
|
6
|
+
const [input, predicatedList] = args;
|
|
7
|
+
for (const predicate of predicatedList) {
|
|
8
|
+
if (predicate(input)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { or };
|
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;
|
|
@@ -2,3 +2,4 @@ import { type IsEqual } from "../../common";
|
|
|
2
2
|
import { type BoolFalsyValue, type EitherBoolFalsy } from "./falsy";
|
|
3
3
|
import { type EitherBoolTruthy } from "./truthy";
|
|
4
4
|
export declare function bool<const GenericValue extends unknown = undefined>(value: GenericValue): GenericValue extends BoolFalsyValue ? EitherBoolFalsy<GenericValue> : IsEqual<GenericValue, number> extends true ? EitherBoolTruthy<GenericValue> | EitherBoolFalsy<0> : IsEqual<GenericValue, string> extends true ? EitherBoolTruthy<GenericValue> | EitherBoolFalsy<""> : EitherBoolTruthy<GenericValue>;
|
|
5
|
+
export type Bool<GenericValue extends unknown> = EitherBoolTruthy<GenericValue> | EitherBoolFalsy;
|
|
@@ -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 {};
|
|
@@ -21,5 +21,5 @@ export declare class Future<const GenericValue extends unknown = unknown> extend
|
|
|
21
21
|
static instanceof<GenericValue extends unknown>(value: GenericValue): value is Extract<GenericValue, Future<any>>;
|
|
22
22
|
static all<const GenericValue extends unknown, GenericArray extends readonly GenericValue[] | []>(values: GenericArray): FutureEitherAllResult<GenericArray>;
|
|
23
23
|
}
|
|
24
|
-
export declare function future<
|
|
24
|
+
export declare function future<GenericEither extends AnyValue>(value: GenericEither): Future<GenericEither>;
|
|
25
25
|
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,3 +1,4 @@
|
|
|
1
1
|
import { type EitherNullableEmpty } from "./empty";
|
|
2
2
|
import { type EitherNullableFilled } from "./filled";
|
|
3
3
|
export declare function nullable<const GenericValue extends unknown = null>(value: GenericValue): GenericValue extends null ? EitherNullableEmpty : EitherNullableFilled<GenericValue>;
|
|
4
|
+
export type Nullable<GenericValue extends unknown> = EitherNullableFilled<GenericValue> | EitherNullableEmpty;
|
|
@@ -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,3 +1,4 @@
|
|
|
1
1
|
import { type EitherNullishEmpty, type NullishValue } from "./empty";
|
|
2
2
|
import { type EitherNullishFilled } from "./filled";
|
|
3
3
|
export declare function nullish<const GenericValue extends unknown = undefined>(value: GenericValue): GenericValue extends NullishValue ? EitherNullishEmpty<GenericValue> : EitherNullishFilled<GenericValue>;
|
|
4
|
+
export type Nullish<GenericValue extends unknown> = EitherNullishFilled<GenericValue> | EitherNullishEmpty;
|
|
@@ -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 {};
|