@ls-stack/utils 3.15.0 → 3.16.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/lib/{chunk-MWND73GM.js → chunk-GHAQOUA6.js} +2 -5
- package/lib/objUtils.cjs +2 -5
- package/lib/objUtils.d.cts +1 -1
- package/lib/objUtils.d.ts +1 -1
- package/lib/objUtils.js +1 -1
- package/lib/testUtils.cjs +2 -5
- package/lib/testUtils.js +1 -1
- package/lib/typingFnUtils.d.cts +5 -5
- package/lib/typingFnUtils.d.ts +5 -5
- package/package.json +1 -1
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
function objectTypedEntries(obj) {
|
|
3
3
|
return Object.entries(obj);
|
|
4
4
|
}
|
|
5
|
-
function pick(obj, keys
|
|
5
|
+
function pick(obj, keys) {
|
|
6
6
|
const result = {};
|
|
7
|
-
if (!obj) {
|
|
8
|
-
return result;
|
|
9
|
-
}
|
|
10
7
|
for (const key of keys) {
|
|
11
|
-
result[
|
|
8
|
+
result[key] = obj[key];
|
|
12
9
|
}
|
|
13
10
|
return result;
|
|
14
11
|
}
|
package/lib/objUtils.cjs
CHANGED
|
@@ -32,13 +32,10 @@ module.exports = __toCommonJS(objUtils_exports);
|
|
|
32
32
|
function objectTypedEntries(obj) {
|
|
33
33
|
return Object.entries(obj);
|
|
34
34
|
}
|
|
35
|
-
function pick(obj, keys
|
|
35
|
+
function pick(obj, keys) {
|
|
36
36
|
const result = {};
|
|
37
|
-
if (!obj) {
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
37
|
for (const key of keys) {
|
|
41
|
-
result[
|
|
38
|
+
result[key] = obj[key];
|
|
42
39
|
}
|
|
43
40
|
return result;
|
|
44
41
|
}
|
package/lib/objUtils.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @deprecated use typedObjectEntries from @ls-stack/utils/typingFnUtils instead */
|
|
2
2
|
declare function objectTypedEntries<T extends Record<string, unknown>>(obj: T): [Extract<keyof T, string>, T[keyof T]][];
|
|
3
|
-
declare function pick<T, K extends keyof T>(obj: T
|
|
3
|
+
declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
4
4
|
declare function mapArrayToObject<T, K extends string, O>(array: T[], mapper: (item: T, index: number) => [K, O]): Record<K, O>;
|
|
5
5
|
declare function mapObjectToObject<I extends Record<string | number | symbol, unknown>, K extends string | number | symbol, O>(obj: I, mapper: (key: keyof I, value: I[keyof I]) => [K, O]): Record<K, O>;
|
|
6
6
|
declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
package/lib/objUtils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @deprecated use typedObjectEntries from @ls-stack/utils/typingFnUtils instead */
|
|
2
2
|
declare function objectTypedEntries<T extends Record<string, unknown>>(obj: T): [Extract<keyof T, string>, T[keyof T]][];
|
|
3
|
-
declare function pick<T, K extends keyof T>(obj: T
|
|
3
|
+
declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
4
4
|
declare function mapArrayToObject<T, K extends string, O>(array: T[], mapper: (item: T, index: number) => [K, O]): Record<K, O>;
|
|
5
5
|
declare function mapObjectToObject<I extends Record<string | number | symbol, unknown>, K extends string | number | symbol, O>(obj: I, mapper: (key: keyof I, value: I[keyof I]) => [K, O]): Record<K, O>;
|
|
6
6
|
declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
package/lib/objUtils.js
CHANGED
package/lib/testUtils.cjs
CHANGED
|
@@ -125,13 +125,10 @@ function clampMin(value, min) {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
// src/objUtils.ts
|
|
128
|
-
function pick(obj, keys
|
|
128
|
+
function pick(obj, keys) {
|
|
129
129
|
const result = {};
|
|
130
|
-
if (!obj) {
|
|
131
|
-
return result;
|
|
132
|
-
}
|
|
133
130
|
for (const key of keys) {
|
|
134
|
-
result[
|
|
131
|
+
result[key] = obj[key];
|
|
135
132
|
}
|
|
136
133
|
return result;
|
|
137
134
|
}
|
package/lib/testUtils.js
CHANGED
package/lib/typingFnUtils.d.cts
CHANGED
|
@@ -30,19 +30,19 @@ type UnionDiff<T, U> = [
|
|
|
30
30
|
] extends [U] ? [
|
|
31
31
|
U
|
|
32
32
|
] extends [T] ? null : {
|
|
33
|
-
|
|
33
|
+
onRightHasExtraErr: Exclude<U, T>;
|
|
34
34
|
} : [U] extends [T] ? {
|
|
35
|
-
|
|
35
|
+
onRightHasMissingErr: Exclude<T, U>;
|
|
36
36
|
} : {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
onRightHasExtraErr: Exclude<U, T>;
|
|
38
|
+
onRightHasMissingErr: Exclude<T, U>;
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
41
41
|
* Type helper to compare two union types and determine their relationship.
|
|
42
42
|
*
|
|
43
43
|
* @template T - The first union type (left side)
|
|
44
44
|
* @template U - The second union type (right side)
|
|
45
|
-
* @param _diff - null if unions are identical, or an object describing the
|
|
45
|
+
* @param _diff - null if unions are identical, or an object describing the errors
|
|
46
46
|
* @returns void - This function is only used for type checking
|
|
47
47
|
*/
|
|
48
48
|
declare function unionsAreTheSame<T, U>(_diff: UnionDiff<T, U>): void;
|
package/lib/typingFnUtils.d.ts
CHANGED
|
@@ -30,19 +30,19 @@ type UnionDiff<T, U> = [
|
|
|
30
30
|
] extends [U] ? [
|
|
31
31
|
U
|
|
32
32
|
] extends [T] ? null : {
|
|
33
|
-
|
|
33
|
+
onRightHasExtraErr: Exclude<U, T>;
|
|
34
34
|
} : [U] extends [T] ? {
|
|
35
|
-
|
|
35
|
+
onRightHasMissingErr: Exclude<T, U>;
|
|
36
36
|
} : {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
onRightHasExtraErr: Exclude<U, T>;
|
|
38
|
+
onRightHasMissingErr: Exclude<T, U>;
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
41
41
|
* Type helper to compare two union types and determine their relationship.
|
|
42
42
|
*
|
|
43
43
|
* @template T - The first union type (left side)
|
|
44
44
|
* @template U - The second union type (right side)
|
|
45
|
-
* @param _diff - null if unions are identical, or an object describing the
|
|
45
|
+
* @param _diff - null if unions are identical, or an object describing the errors
|
|
46
46
|
* @returns void - This function is only used for type checking
|
|
47
47
|
*/
|
|
48
48
|
declare function unionsAreTheSame<T, U>(_diff: UnionDiff<T, U>): void;
|