@cofondateurauchomage/libs 1.1.133 → 1.1.134
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.
|
@@ -23,5 +23,10 @@ export declare function cleanObject<T extends object>(obj: T, options?: {
|
|
|
23
23
|
keepNull?: boolean;
|
|
24
24
|
keepEmptyArrays?: boolean;
|
|
25
25
|
}): Cleaned<T>;
|
|
26
|
+
type IsNull<T> = T extends null ? true : false;
|
|
27
|
+
type WithoutNull<T> = {
|
|
28
|
+
[K in keyof T as IsNull<T[K]> extends true ? never : K]: Exclude<T[K], null>;
|
|
29
|
+
};
|
|
30
|
+
export declare function removeNull<T extends Record<string, any>>(obj: T): WithoutNull<T>;
|
|
26
31
|
export declare function deepEqual<T>(obj1: T, obj2: T): boolean;
|
|
27
32
|
export {};
|
|
@@ -6,6 +6,7 @@ exports.typedKeys = typedKeys;
|
|
|
6
6
|
exports.typedObjectEntries = typedObjectEntries;
|
|
7
7
|
exports.isObject = isObject;
|
|
8
8
|
exports.cleanObject = cleanObject;
|
|
9
|
+
exports.removeNull = removeNull;
|
|
9
10
|
exports.deepEqual = deepEqual;
|
|
10
11
|
const arrayUtils_1 = require("./arrayUtils");
|
|
11
12
|
/**
|
|
@@ -55,6 +56,16 @@ function cleanObject(obj, options) {
|
|
|
55
56
|
}
|
|
56
57
|
return result;
|
|
57
58
|
}
|
|
59
|
+
function removeNull(obj) {
|
|
60
|
+
const acc = {};
|
|
61
|
+
for (const [key, value] of typedObjectEntries(obj)) {
|
|
62
|
+
const cleanedValue = isObject(value) ? removeNull(value) : value;
|
|
63
|
+
if (cleanedValue !== null) {
|
|
64
|
+
acc[key] = cleanedValue;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return acc;
|
|
68
|
+
}
|
|
58
69
|
function deepEqual(obj1, obj2) {
|
|
59
70
|
if (obj1 === obj2) {
|
|
60
71
|
return true;
|