shareneus 1.6.99 → 1.7.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.
@@ -110,15 +110,29 @@ function readValue(item, field) {
110
110
  if (item[field] !== undefined) {
111
111
  return item[field];
112
112
  }
113
- const dottedPathValue = field.split('.').reduce((current, key) => {
113
+ const pathSegments = field.split('.');
114
+ const dottedPathValue = pathSegments.reduce((current, key) => {
115
+ console.log('Current value for key', key, 'is', current);
114
116
  if (current && current[key] !== undefined) {
115
117
  return current[key];
116
118
  }
117
119
  return undefined;
118
120
  }, item);
121
+ console.log('Value for field', field, 'is', dottedPathValue);
119
122
  if (dottedPathValue !== undefined) {
120
123
  return dottedPathValue;
121
124
  }
125
+ if (pathSegments.length > 1) {
126
+ const rootValue = item[pathSegments[0]];
127
+ if (rootValue !== undefined && rootValue !== null && typeof rootValue !== 'object') {
128
+ return rootValue;
129
+ }
130
+ const leafField = pathSegments[pathSegments.length - 1];
131
+ const leafValue = deepFindByKey(item, leafField);
132
+ if (leafValue !== undefined) {
133
+ return leafValue;
134
+ }
135
+ }
122
136
  return deepFindByKey(item, field);
123
137
  }
124
138
  function deepFindByKey(source, field) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shareneus",
3
- "version": "1.6.99",
3
+ "version": "1.7.00",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",