@go-mailer/jarvis 7.0.3 → 7.1.9
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/utilitiy/text.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
const flattenObject = (object = {}, result = {}) => {
|
|
1
|
+
const flattenObject = (object = {}, result = {}, concatenate_keys = false, root_key = "") => {
|
|
2
2
|
let flattened_object = {};
|
|
3
3
|
|
|
4
4
|
const entries = Object.entries(object);
|
|
5
5
|
|
|
6
6
|
for (let [key, value] of entries) {
|
|
7
|
+
const item_key = root_key && concatenate_keys ? `${root_key}.${key}` : key;
|
|
7
8
|
if (value && typeof value === "object") {
|
|
8
|
-
flattened_object = { ...flattenObject(value, { ...flattened_object }) };
|
|
9
|
+
flattened_object = { ...flattenObject(value, { ...flattened_object }, concatenate_keys, item_key) };
|
|
9
10
|
} else {
|
|
10
|
-
flattened_object[
|
|
11
|
+
flattened_object[item_key] = value;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
|