@ptolemy2002/list-object-utils 1.1.0 → 1.2.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/index.js +5 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -149,7 +149,11 @@ function objectDifference(a, b) {
|
|
|
149
149
|
function flattenKeys(obj, prefix = "") {
|
|
150
150
|
const result = {};
|
|
151
151
|
for (const key in obj) {
|
|
152
|
-
if (
|
|
152
|
+
if (Array.isArray(obj[key])) {
|
|
153
|
+
const flat = flattenKeys(obj[key], prefix + key + ".");
|
|
154
|
+
Object.assign(result, flat);
|
|
155
|
+
if (Object.keys(flat).length === 0) result[prefix + key] = obj[key];
|
|
156
|
+
} else if (typeof obj[key] === "object") {
|
|
153
157
|
const flat = flattenKeys(obj[key], prefix + key + ".");
|
|
154
158
|
Object.assign(result, flat);
|
|
155
159
|
if (Object.keys(flat).length === 0) result[prefix + key] = obj[key];
|