ag-common 0.0.271 → 0.0.272
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.
|
@@ -43,7 +43,8 @@ export declare function objectToString(obj: Record<string, string>, joinKeyValue
|
|
|
43
43
|
* @returns
|
|
44
44
|
*/
|
|
45
45
|
export declare const castObject: <TIn, TOut>(orig: Record<string, TIn>, castF: (t: TIn) => TOut) => Record<string, TOut>;
|
|
46
|
-
|
|
46
|
+
/** remove key values from an object where the value is null or undefined or other specific passed in values */
|
|
47
|
+
export declare const removeUndefValuesFromObject: <T>(orig: Record<string, T>, ...additionalRemoves: T[]) => Record<string, T>;
|
|
47
48
|
/**
|
|
48
49
|
* cast Record<string,string[]|string> to Record<string,string>. can be used for querystring params
|
|
49
50
|
* @param orig
|
|
@@ -128,10 +128,13 @@ const castObject = (orig, castF) => {
|
|
|
128
128
|
return ret;
|
|
129
129
|
};
|
|
130
130
|
exports.castObject = castObject;
|
|
131
|
-
|
|
131
|
+
/** remove key values from an object where the value is null or undefined or other specific passed in values */
|
|
132
|
+
const removeUndefValuesFromObject = (orig,
|
|
133
|
+
/** other than null or undefined */
|
|
134
|
+
...additionalRemoves) => {
|
|
132
135
|
const ret = {};
|
|
133
136
|
Object.entries(orig).forEach(([k, v]) => {
|
|
134
|
-
if (v !== null && v !== undefined) {
|
|
137
|
+
if (v !== null && v !== undefined && !(additionalRemoves === null || additionalRemoves === void 0 ? void 0 : additionalRemoves.includes(v))) {
|
|
135
138
|
ret[k] = v;
|
|
136
139
|
}
|
|
137
140
|
});
|