@ls-stack/utils 3.41.0 → 3.42.0
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/{chunk-DTE2QMWE.js → chunk-GMJTLFM6.js} +13 -1
- package/dist/{chunk-23KPGKDT.js → chunk-Y45CE75W.js} +1 -1
- package/dist/objUtils.js +2 -2
- package/dist/testUtils.js +2 -2
- package/dist/typingFnUtils.cjs +15 -0
- package/dist/typingFnUtils.d.cts +22 -1
- package/dist/typingFnUtils.d.ts +22 -1
- package/dist/typingFnUtils.js +7 -1
- package/package.json +1 -1
|
@@ -5,6 +5,9 @@ function asNonPartial(obj) {
|
|
|
5
5
|
function typedObjectEntries(obj) {
|
|
6
6
|
return Object.entries(obj);
|
|
7
7
|
}
|
|
8
|
+
function strictTypedObjectEntries(obj) {
|
|
9
|
+
return Object.entries(obj);
|
|
10
|
+
}
|
|
8
11
|
function typedObjectKeys(obj) {
|
|
9
12
|
return Object.keys(obj);
|
|
10
13
|
}
|
|
@@ -33,10 +36,17 @@ function unionsAreTheSame(_diff) {
|
|
|
33
36
|
function asPartialUndefinedValues(value) {
|
|
34
37
|
return value;
|
|
35
38
|
}
|
|
39
|
+
function isNonEmptyArray(array) {
|
|
40
|
+
return array.length > 0;
|
|
41
|
+
}
|
|
42
|
+
function objectHasKey(obj, key) {
|
|
43
|
+
return key in obj;
|
|
44
|
+
}
|
|
36
45
|
|
|
37
46
|
export {
|
|
38
47
|
asNonPartial,
|
|
39
48
|
typedObjectEntries,
|
|
49
|
+
strictTypedObjectEntries,
|
|
40
50
|
typedObjectKeys,
|
|
41
51
|
asType,
|
|
42
52
|
narrowStringToUnion,
|
|
@@ -44,5 +54,7 @@ export {
|
|
|
44
54
|
isSubTypeOf,
|
|
45
55
|
isObjKey,
|
|
46
56
|
unionsAreTheSame,
|
|
47
|
-
asPartialUndefinedValues
|
|
57
|
+
asPartialUndefinedValues,
|
|
58
|
+
isNonEmptyArray,
|
|
59
|
+
objectHasKey
|
|
48
60
|
};
|
package/dist/objUtils.js
CHANGED
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
pick,
|
|
9
9
|
rejectObjUndefinedValues,
|
|
10
10
|
sortObjectKeys
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-Y45CE75W.js";
|
|
12
|
+
import "./chunk-GMJTLFM6.js";
|
|
13
13
|
import "./chunk-27AL66CH.js";
|
|
14
14
|
import "./chunk-C2SVCIWE.js";
|
|
15
15
|
import "./chunk-JF2MDHOJ.js";
|
package/dist/testUtils.js
CHANGED
package/dist/typingFnUtils.cjs
CHANGED
|
@@ -23,9 +23,12 @@ __export(typingFnUtils_exports, {
|
|
|
23
23
|
asNonPartial: () => asNonPartial,
|
|
24
24
|
asPartialUndefinedValues: () => asPartialUndefinedValues,
|
|
25
25
|
asType: () => asType,
|
|
26
|
+
isNonEmptyArray: () => isNonEmptyArray,
|
|
26
27
|
isObjKey: () => isObjKey,
|
|
27
28
|
isSubTypeOf: () => isSubTypeOf,
|
|
28
29
|
narrowStringToUnion: () => narrowStringToUnion,
|
|
30
|
+
objectHasKey: () => objectHasKey,
|
|
31
|
+
strictTypedObjectEntries: () => strictTypedObjectEntries,
|
|
29
32
|
typeOnRightExtendsLeftType: () => typeOnRightExtendsLeftType,
|
|
30
33
|
typedObjectEntries: () => typedObjectEntries,
|
|
31
34
|
typedObjectKeys: () => typedObjectKeys,
|
|
@@ -38,6 +41,9 @@ function asNonPartial(obj) {
|
|
|
38
41
|
function typedObjectEntries(obj) {
|
|
39
42
|
return Object.entries(obj);
|
|
40
43
|
}
|
|
44
|
+
function strictTypedObjectEntries(obj) {
|
|
45
|
+
return Object.entries(obj);
|
|
46
|
+
}
|
|
41
47
|
function typedObjectKeys(obj) {
|
|
42
48
|
return Object.keys(obj);
|
|
43
49
|
}
|
|
@@ -66,14 +72,23 @@ function unionsAreTheSame(_diff) {
|
|
|
66
72
|
function asPartialUndefinedValues(value) {
|
|
67
73
|
return value;
|
|
68
74
|
}
|
|
75
|
+
function isNonEmptyArray(array) {
|
|
76
|
+
return array.length > 0;
|
|
77
|
+
}
|
|
78
|
+
function objectHasKey(obj, key) {
|
|
79
|
+
return key in obj;
|
|
80
|
+
}
|
|
69
81
|
// Annotate the CommonJS export names for ESM import in node:
|
|
70
82
|
0 && (module.exports = {
|
|
71
83
|
asNonPartial,
|
|
72
84
|
asPartialUndefinedValues,
|
|
73
85
|
asType,
|
|
86
|
+
isNonEmptyArray,
|
|
74
87
|
isObjKey,
|
|
75
88
|
isSubTypeOf,
|
|
76
89
|
narrowStringToUnion,
|
|
90
|
+
objectHasKey,
|
|
91
|
+
strictTypedObjectEntries,
|
|
77
92
|
typeOnRightExtendsLeftType,
|
|
78
93
|
typedObjectEntries,
|
|
79
94
|
typedObjectKeys,
|
package/dist/typingFnUtils.d.cts
CHANGED
|
@@ -10,6 +10,15 @@ declare function asNonPartial<T extends Record<string, unknown>>(obj: T): NonPar
|
|
|
10
10
|
declare function typedObjectEntries<T extends Record<string, unknown>>(obj: T): NonNullable<{
|
|
11
11
|
[K in keyof T]: [K, T[K]];
|
|
12
12
|
}[keyof T]>[];
|
|
13
|
+
/**
|
|
14
|
+
* A wrapper to Object.entries with a better typing inference, but with strict
|
|
15
|
+
* typing narrowing keys to strings.
|
|
16
|
+
*
|
|
17
|
+
* @param obj
|
|
18
|
+
*/
|
|
19
|
+
declare function strictTypedObjectEntries<T extends Record<string, unknown>>(obj: T): NonNullable<{
|
|
20
|
+
[K in keyof T]: [K & string, T[K]];
|
|
21
|
+
}[keyof T]>[];
|
|
13
22
|
/**
|
|
14
23
|
* A wrapper to Object.keys with a better typing inference
|
|
15
24
|
*
|
|
@@ -68,5 +77,17 @@ type UnionDiff<T, U> = [
|
|
|
68
77
|
*/
|
|
69
78
|
declare function unionsAreTheSame<T, U>(_diff: UnionDiff<T, U>): void;
|
|
70
79
|
declare function asPartialUndefinedValues<T extends Record<string, unknown>>(value: PartialPossiblyUndefinedValues<T>): T;
|
|
80
|
+
/** A type representing an array that is guaranteed to have at least one element. */
|
|
81
|
+
type NonEmptyArray<T> = [T, ...T[]];
|
|
82
|
+
/**
|
|
83
|
+
* Type guard to check if an array has at least one element.
|
|
84
|
+
*
|
|
85
|
+
* @param array - The array to check
|
|
86
|
+
* @returns True if the array is non-empty, false otherwise
|
|
87
|
+
*/
|
|
88
|
+
declare function isNonEmptyArray<T>(array: T[]): array is NonEmptyArray<T>;
|
|
89
|
+
declare function objectHasKey<T extends string>(obj: object, key: T): obj is object & {
|
|
90
|
+
[K in T]: unknown;
|
|
91
|
+
};
|
|
71
92
|
|
|
72
|
-
export { asNonPartial, asPartialUndefinedValues, asType, isObjKey, isSubTypeOf, narrowStringToUnion, typeOnRightExtendsLeftType, typedObjectEntries, typedObjectKeys, unionsAreTheSame };
|
|
93
|
+
export { type NonEmptyArray, asNonPartial, asPartialUndefinedValues, asType, isNonEmptyArray, isObjKey, isSubTypeOf, narrowStringToUnion, objectHasKey, strictTypedObjectEntries, typeOnRightExtendsLeftType, typedObjectEntries, typedObjectKeys, unionsAreTheSame };
|
package/dist/typingFnUtils.d.ts
CHANGED
|
@@ -10,6 +10,15 @@ declare function asNonPartial<T extends Record<string, unknown>>(obj: T): NonPar
|
|
|
10
10
|
declare function typedObjectEntries<T extends Record<string, unknown>>(obj: T): NonNullable<{
|
|
11
11
|
[K in keyof T]: [K, T[K]];
|
|
12
12
|
}[keyof T]>[];
|
|
13
|
+
/**
|
|
14
|
+
* A wrapper to Object.entries with a better typing inference, but with strict
|
|
15
|
+
* typing narrowing keys to strings.
|
|
16
|
+
*
|
|
17
|
+
* @param obj
|
|
18
|
+
*/
|
|
19
|
+
declare function strictTypedObjectEntries<T extends Record<string, unknown>>(obj: T): NonNullable<{
|
|
20
|
+
[K in keyof T]: [K & string, T[K]];
|
|
21
|
+
}[keyof T]>[];
|
|
13
22
|
/**
|
|
14
23
|
* A wrapper to Object.keys with a better typing inference
|
|
15
24
|
*
|
|
@@ -68,5 +77,17 @@ type UnionDiff<T, U> = [
|
|
|
68
77
|
*/
|
|
69
78
|
declare function unionsAreTheSame<T, U>(_diff: UnionDiff<T, U>): void;
|
|
70
79
|
declare function asPartialUndefinedValues<T extends Record<string, unknown>>(value: PartialPossiblyUndefinedValues<T>): T;
|
|
80
|
+
/** A type representing an array that is guaranteed to have at least one element. */
|
|
81
|
+
type NonEmptyArray<T> = [T, ...T[]];
|
|
82
|
+
/**
|
|
83
|
+
* Type guard to check if an array has at least one element.
|
|
84
|
+
*
|
|
85
|
+
* @param array - The array to check
|
|
86
|
+
* @returns True if the array is non-empty, false otherwise
|
|
87
|
+
*/
|
|
88
|
+
declare function isNonEmptyArray<T>(array: T[]): array is NonEmptyArray<T>;
|
|
89
|
+
declare function objectHasKey<T extends string>(obj: object, key: T): obj is object & {
|
|
90
|
+
[K in T]: unknown;
|
|
91
|
+
};
|
|
71
92
|
|
|
72
|
-
export { asNonPartial, asPartialUndefinedValues, asType, isObjKey, isSubTypeOf, narrowStringToUnion, typeOnRightExtendsLeftType, typedObjectEntries, typedObjectKeys, unionsAreTheSame };
|
|
93
|
+
export { type NonEmptyArray, asNonPartial, asPartialUndefinedValues, asType, isNonEmptyArray, isObjKey, isSubTypeOf, narrowStringToUnion, objectHasKey, strictTypedObjectEntries, typeOnRightExtendsLeftType, typedObjectEntries, typedObjectKeys, unionsAreTheSame };
|
package/dist/typingFnUtils.js
CHANGED
|
@@ -2,21 +2,27 @@ import {
|
|
|
2
2
|
asNonPartial,
|
|
3
3
|
asPartialUndefinedValues,
|
|
4
4
|
asType,
|
|
5
|
+
isNonEmptyArray,
|
|
5
6
|
isObjKey,
|
|
6
7
|
isSubTypeOf,
|
|
7
8
|
narrowStringToUnion,
|
|
9
|
+
objectHasKey,
|
|
10
|
+
strictTypedObjectEntries,
|
|
8
11
|
typeOnRightExtendsLeftType,
|
|
9
12
|
typedObjectEntries,
|
|
10
13
|
typedObjectKeys,
|
|
11
14
|
unionsAreTheSame
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-GMJTLFM6.js";
|
|
13
16
|
export {
|
|
14
17
|
asNonPartial,
|
|
15
18
|
asPartialUndefinedValues,
|
|
16
19
|
asType,
|
|
20
|
+
isNonEmptyArray,
|
|
17
21
|
isObjKey,
|
|
18
22
|
isSubTypeOf,
|
|
19
23
|
narrowStringToUnion,
|
|
24
|
+
objectHasKey,
|
|
25
|
+
strictTypedObjectEntries,
|
|
20
26
|
typeOnRightExtendsLeftType,
|
|
21
27
|
typedObjectEntries,
|
|
22
28
|
typedObjectKeys,
|