@stemy/ngx-utils 19.4.16 → 19.4.17

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.
@@ -129,15 +129,22 @@ class ObjectUtils {
129
129
  return !obj || Object.keys(obj).length == 0;
130
130
  }
131
131
  static iterate(obj, cb) {
132
- if (!obj)
133
- return;
134
- const keys = Array.isArray(obj) ? Array.from(obj.keys()) : Object.keys(obj);
132
+ const keys = Array.isArray(obj)
133
+ ? Array.from(obj.keys())
134
+ : (ObjectUtils.isObject(obj) ? Object.keys(obj) : []);
135
135
  keys.forEach(
136
136
  // @dynamic
137
137
  key => {
138
138
  cb(obj[key], key);
139
139
  });
140
140
  }
141
+ static iterateRecursive(obj, cb, path = "") {
142
+ return ObjectUtils.iterate(obj, (value, key) => {
143
+ const subPath = !path ? key : `${path}.${key}`;
144
+ cb(value, key, subPath, obj);
145
+ ObjectUtils.iterateRecursive(value, cb, subPath);
146
+ });
147
+ }
141
148
  static getValue(obj, key, defaultValue, treeFallback = false) {
142
149
  key = key || "";
143
150
  const keys = key.split(".");