@duplojs/utils 1.3.27 → 1.3.29
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/concat.d.ts +2 -2
- package/dist/common/falsy.cjs +7 -0
- package/dist/common/falsy.d.ts +2 -0
- package/dist/common/falsy.mjs +5 -0
- package/dist/common/hasKinds.cjs +17 -0
- package/dist/common/hasKinds.d.ts +4 -0
- package/dist/common/hasKinds.mjs +15 -0
- package/dist/common/hasSomeKinds.cjs +17 -0
- package/dist/common/hasSomeKinds.d.ts +4 -0
- package/dist/common/hasSomeKinds.mjs +15 -0
- package/dist/common/index.d.ts +4 -0
- package/dist/common/truthy.cjs +7 -0
- package/dist/common/truthy.d.ts +3 -0
- package/dist/common/truthy.mjs +5 -0
- package/dist/common/types/falsyValue.d.ts +1 -0
- package/dist/common/types/index.d.ts +1 -0
- package/dist/common/types/predicate.d.ts +1 -1
- package/dist/either/bool/create.cjs +1 -0
- package/dist/either/bool/create.d.ts +3 -3
- package/dist/either/bool/create.mjs +1 -0
- package/dist/either/bool/falsy.d.ts +4 -5
- package/dist/index.cjs +8 -0
- package/dist/index.mjs +4 -0
- package/dist/metadata.json +39 -0
- package/package.json +1 -1
package/dist/array/concat.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function concat<
|
|
2
|
-
export declare function concat<
|
|
1
|
+
export declare function concat<GenericFirstArray extends readonly unknown[], GenericSecondArray extends readonly unknown[]>(elements: GenericSecondArray): (array: GenericFirstArray) => (GenericFirstArray[number] | GenericSecondArray[number])[];
|
|
2
|
+
export declare function concat<GenericFirstArray extends readonly unknown[], GenericSecondArray extends readonly unknown[], GenericRest extends readonly unknown[][]>(array: GenericFirstArray, elements: GenericSecondArray, ...elementsRest: GenericRest): (GenericFirstArray[number] | GenericSecondArray[number] | GenericRest[number][number])[];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { type FalsyValue, type UnionContain } from "./types";
|
|
2
|
+
export declare function falsy<GenericInput extends unknown>(input: GenericInput): input is (Extract<GenericInput, FalsyValue> | (UnionContain<GenericInput, string> extends true ? "" : never) | (UnionContain<GenericInput, number> extends true ? 0 : never) | (UnionContain<GenericInput, bigint> extends true ? 0n : never));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function hasKinds(...args) {
|
|
4
|
+
if (args.length === 1) {
|
|
5
|
+
const [kinds] = args;
|
|
6
|
+
return (input) => hasKinds(input, kinds);
|
|
7
|
+
}
|
|
8
|
+
const [input, kinds] = args;
|
|
9
|
+
for (const kind of kinds) {
|
|
10
|
+
if (!kind.has(input)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.hasKinds = hasKinds;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Kind, type KindHandler } from "./kind";
|
|
2
|
+
import { type AnyTuple, type UnionToIntersection } from "./types";
|
|
3
|
+
export declare function hasKinds<GenericInput extends unknown, const GenericKindHandlers extends AnyTuple<KindHandler>, GenericKindHandler extends GenericKindHandlers[number]>(kinds: GenericKindHandlers): (input: GenericInput) => input is Extract<GenericInput, UnionToIntersection<GenericKindHandler extends any ? Kind<GenericKindHandler["definition"]> : never>>;
|
|
4
|
+
export declare function hasKinds<GenericInput extends unknown, const GenericKindHandlers extends AnyTuple<KindHandler>, GenericKindHandler extends GenericKindHandlers[number]>(input: GenericInput, kinds: GenericKindHandlers): input is Extract<GenericInput, UnionToIntersection<GenericKindHandler extends any ? Kind<GenericKindHandler["definition"]> : never>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function hasKinds(...args) {
|
|
2
|
+
if (args.length === 1) {
|
|
3
|
+
const [kinds] = args;
|
|
4
|
+
return (input) => hasKinds(input, kinds);
|
|
5
|
+
}
|
|
6
|
+
const [input, kinds] = args;
|
|
7
|
+
for (const kind of kinds) {
|
|
8
|
+
if (!kind.has(input)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { hasKinds };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function hasSomeKinds(...args) {
|
|
4
|
+
if (args.length === 1) {
|
|
5
|
+
const [kinds] = args;
|
|
6
|
+
return (input) => hasSomeKinds(input, kinds);
|
|
7
|
+
}
|
|
8
|
+
const [input, kinds] = args;
|
|
9
|
+
for (const kind of kinds) {
|
|
10
|
+
if (kind.has(input)) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.hasSomeKinds = hasSomeKinds;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Kind, type KindHandler } from "./kind";
|
|
2
|
+
import { type AnyTuple } from "./types";
|
|
3
|
+
export declare function hasSomeKinds<GenericInput extends unknown, const GenericKindHandlers extends AnyTuple<KindHandler>, GenericKindHandler extends GenericKindHandlers[number]>(kinds: GenericKindHandlers): (input: GenericInput) => input is Extract<GenericInput, GenericKindHandler extends any ? Kind<GenericKindHandler["definition"]> : never>;
|
|
4
|
+
export declare function hasSomeKinds<GenericInput extends unknown, const GenericKindHandlers extends AnyTuple<KindHandler>, GenericKindHandler extends GenericKindHandlers[number]>(input: GenericInput, kinds: GenericKindHandlers): input is Extract<GenericInput, GenericKindHandler extends any ? Kind<GenericKindHandler["definition"]> : never>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function hasSomeKinds(...args) {
|
|
2
|
+
if (args.length === 1) {
|
|
3
|
+
const [kinds] = args;
|
|
4
|
+
return (input) => hasSomeKinds(input, kinds);
|
|
5
|
+
}
|
|
6
|
+
const [input, kinds] = args;
|
|
7
|
+
for (const kind of kinds) {
|
|
8
|
+
if (kind.has(input)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { hasSomeKinds };
|
package/dist/common/index.d.ts
CHANGED
|
@@ -41,3 +41,7 @@ export * from "./createKindIdentifier";
|
|
|
41
41
|
export * from "./forwardLog";
|
|
42
42
|
export * from "./override";
|
|
43
43
|
export * from "./errorKindNamespace";
|
|
44
|
+
export * from "./truthy";
|
|
45
|
+
export * from "./falsy";
|
|
46
|
+
export * from "./hasSomeKinds";
|
|
47
|
+
export * from "./hasKinds";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type FalsyValue = false | 0 | 0n | "" | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type Predicate<GenericFunction extends (input: any, ...args: any[]) =>
|
|
1
|
+
export type Predicate<GenericFunction extends (input: any, ...args: any[]) => boolean> = GenericFunction extends (input: any, ...args: any[]) => input is infer InferredPredicate ? InferredPredicate : Parameters<GenericFunction>[0];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type IsEqual } from "../../common";
|
|
2
|
-
import { type
|
|
1
|
+
import { type FalsyValue, type IsEqual } from "../../common";
|
|
2
|
+
import { type EitherBoolFalsy } from "./falsy";
|
|
3
3
|
import { type EitherBoolTruthy } from "./truthy";
|
|
4
|
-
export declare function bool<const GenericValue extends unknown = undefined>(value: GenericValue): GenericValue extends
|
|
4
|
+
export declare function bool<const GenericValue extends unknown = undefined>(value: GenericValue): GenericValue extends FalsyValue ? EitherBoolFalsy<GenericValue> : IsEqual<GenericValue, number> extends true ? EitherBoolTruthy<GenericValue> | EitherBoolFalsy<0> : IsEqual<GenericValue, bigint> extends true ? EitherBoolTruthy<GenericValue> | EitherBoolFalsy<0n> : IsEqual<GenericValue, string> extends true ? EitherBoolTruthy<GenericValue> | EitherBoolFalsy<""> : EitherBoolTruthy<GenericValue>;
|
|
5
5
|
export type Bool<GenericValue extends unknown> = EitherBoolTruthy<GenericValue> | EitherBoolFalsy;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
|
|
1
|
+
import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink, type FalsyValue } from "../../common";
|
|
2
2
|
import { type Kind } from "../../common/kind";
|
|
3
3
|
import { eitherBoolKind } from "./base";
|
|
4
4
|
import { bool } from "./create";
|
|
5
5
|
import { type EitherLeft } from "../left";
|
|
6
6
|
import { type EitherRight } from "../right";
|
|
7
|
-
export type BoolFalsyValue = 0 | "" | undefined | null | false;
|
|
8
7
|
export declare const eitherBoolFalsyKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsEither/bool-falsy", unknown>>;
|
|
9
|
-
type _EitherBoolFalsy<GenericValue extends
|
|
10
|
-
export interface EitherBoolFalsy<GenericValue extends
|
|
8
|
+
type _EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> = (EitherLeft<"bool", GenericValue> & Kind<typeof eitherBoolKind.definition> & Kind<typeof eitherBoolFalsyKind.definition>);
|
|
9
|
+
export interface EitherBoolFalsy<GenericValue extends FalsyValue = FalsyValue> extends _EitherBoolFalsy<GenericValue> {
|
|
11
10
|
}
|
|
12
|
-
export declare function boolFalsy<const GenericValue extends
|
|
11
|
+
export declare function boolFalsy<const GenericValue extends FalsyValue = undefined>(value?: GenericValue): EitherBoolFalsy<GenericValue>;
|
|
13
12
|
type Either = EitherRight | EitherLeft;
|
|
14
13
|
export declare function isBoolFalsy<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, EitherBoolFalsy>;
|
|
15
14
|
type ToEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof bool<GenericValue>>;
|
package/dist/index.cjs
CHANGED
|
@@ -54,6 +54,10 @@ var createKindIdentifier = require('./common/createKindIdentifier.cjs');
|
|
|
54
54
|
var forwardLog = require('./common/forwardLog.cjs');
|
|
55
55
|
var override = require('./common/override.cjs');
|
|
56
56
|
var errorKindNamespace = require('./common/errorKindNamespace.cjs');
|
|
57
|
+
var truthy = require('./common/truthy.cjs');
|
|
58
|
+
var falsy = require('./common/falsy.cjs');
|
|
59
|
+
var hasSomeKinds = require('./common/hasSomeKinds.cjs');
|
|
60
|
+
var hasKinds = require('./common/hasKinds.cjs');
|
|
57
61
|
|
|
58
62
|
|
|
59
63
|
|
|
@@ -135,3 +139,7 @@ exports.createKindIdentifier = createKindIdentifier.createKindIdentifier;
|
|
|
135
139
|
exports.forwardLog = forwardLog.forwardLog;
|
|
136
140
|
exports.createOverride = override.createOverride;
|
|
137
141
|
exports.createErrorKind = errorKindNamespace.createErrorKind;
|
|
142
|
+
exports.truthy = truthy.truthy;
|
|
143
|
+
exports.falsy = falsy.falsy;
|
|
144
|
+
exports.hasSomeKinds = hasSomeKinds.hasSomeKinds;
|
|
145
|
+
exports.hasKinds = hasKinds.hasKinds;
|
package/dist/index.mjs
CHANGED
|
@@ -76,3 +76,7 @@ export { createKindIdentifier } from './common/createKindIdentifier.mjs';
|
|
|
76
76
|
export { forwardLog } from './common/forwardLog.mjs';
|
|
77
77
|
export { createOverride } from './common/override.mjs';
|
|
78
78
|
export { createErrorKind } from './common/errorKindNamespace.mjs';
|
|
79
|
+
export { truthy } from './common/truthy.mjs';
|
|
80
|
+
export { falsy } from './common/falsy.mjs';
|
|
81
|
+
export { hasSomeKinds } from './common/hasSomeKinds.mjs';
|
|
82
|
+
export { hasKinds } from './common/hasKinds.mjs';
|
package/dist/metadata.json
CHANGED
|
@@ -976,6 +976,9 @@
|
|
|
976
976
|
{
|
|
977
977
|
"name": "expectType.d.ts"
|
|
978
978
|
},
|
|
979
|
+
{
|
|
980
|
+
"name": "falsyValue.d.ts"
|
|
981
|
+
},
|
|
979
982
|
{
|
|
980
983
|
"name": "fixDeepFunctionInfer.d.ts"
|
|
981
984
|
},
|
|
@@ -1197,6 +1200,15 @@
|
|
|
1197
1200
|
{
|
|
1198
1201
|
"name": "externalPromise.mjs"
|
|
1199
1202
|
},
|
|
1203
|
+
{
|
|
1204
|
+
"name": "falsy.cjs"
|
|
1205
|
+
},
|
|
1206
|
+
{
|
|
1207
|
+
"name": "falsy.d.ts"
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
"name": "falsy.mjs"
|
|
1211
|
+
},
|
|
1200
1212
|
{
|
|
1201
1213
|
"name": "forward.cjs"
|
|
1202
1214
|
},
|
|
@@ -1224,6 +1236,24 @@
|
|
|
1224
1236
|
{
|
|
1225
1237
|
"name": "globalStore.mjs"
|
|
1226
1238
|
},
|
|
1239
|
+
{
|
|
1240
|
+
"name": "hasKinds.cjs"
|
|
1241
|
+
},
|
|
1242
|
+
{
|
|
1243
|
+
"name": "hasKinds.d.ts"
|
|
1244
|
+
},
|
|
1245
|
+
{
|
|
1246
|
+
"name": "hasKinds.mjs"
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
"name": "hasSomeKinds.cjs"
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
"name": "hasSomeKinds.d.ts"
|
|
1253
|
+
},
|
|
1254
|
+
{
|
|
1255
|
+
"name": "hasSomeKinds.mjs"
|
|
1256
|
+
},
|
|
1227
1257
|
{
|
|
1228
1258
|
"name": "index.d.ts"
|
|
1229
1259
|
},
|
|
@@ -1407,6 +1437,15 @@
|
|
|
1407
1437
|
{
|
|
1408
1438
|
"name": "toWrappedValue.mjs"
|
|
1409
1439
|
},
|
|
1440
|
+
{
|
|
1441
|
+
"name": "truthy.cjs"
|
|
1442
|
+
},
|
|
1443
|
+
{
|
|
1444
|
+
"name": "truthy.d.ts"
|
|
1445
|
+
},
|
|
1446
|
+
{
|
|
1447
|
+
"name": "truthy.mjs"
|
|
1448
|
+
},
|
|
1410
1449
|
{
|
|
1411
1450
|
"name": "unwrap.cjs"
|
|
1412
1451
|
},
|