@stackbit/utils
Advanced tools
Comparing version 0.2.20 to 0.2.21-alpha.0
@@ -155,11 +155,13 @@ "use strict"; | ||
} | ||
const childrenIterator = (val, key) => { | ||
if (includeKeyPath) { | ||
return _mapDeep(val, lodash_1.default.concat(keyPath, key), lodash_1.default.concat(mappedValueStack, value)); | ||
} | ||
return _mapDeep(val, null, null); | ||
}; | ||
if (lodash_1.default.isPlainObject(value)) { | ||
value = lodash_1.default.mapValues(value, (val, key) => { | ||
return _mapDeep(val, includeKeyPath ? lodash_1.default.concat(keyPath, key) : null, includeKeyPath ? lodash_1.default.concat(mappedValueStack, value) : null); | ||
}); | ||
value = lodash_1.default.mapValues(value, childrenIterator); | ||
} | ||
else if (Array.isArray(value)) { | ||
value = lodash_1.default.map(value, (val, key) => { | ||
return _mapDeep(val, includeKeyPath ? lodash_1.default.concat(keyPath, key) : null, includeKeyPath ? lodash_1.default.concat(mappedValueStack, value) : null); | ||
}); | ||
value = lodash_1.default.map(value, childrenIterator); | ||
} | ||
@@ -166,0 +168,0 @@ return value; |
{ | ||
"name": "@stackbit/utils", | ||
"version": "0.2.20", | ||
"version": "0.2.21-alpha.0", | ||
"description": "Stackbit utilities", | ||
@@ -46,3 +46,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "f4471bdd3fb6fc3c6950a9899ce627fa921310cd" | ||
"gitHead": "65c13454379b9cba8a9ce7667f0b15e1f863f1fa" | ||
} |
@@ -168,10 +168,12 @@ import _, { PropertyPath } from 'lodash'; | ||
} | ||
const childrenIterator = (val: any, key: string | number) => { | ||
if (includeKeyPath) { | ||
return _mapDeep(val, _.concat(keyPath!, key), _.concat(mappedValueStack!, value)); | ||
} | ||
return _mapDeep(val, null, null); | ||
}; | ||
if (_.isPlainObject(value)) { | ||
value = _.mapValues(value, (val: any, key: string) => { | ||
return _mapDeep(val, includeKeyPath ? _.concat(keyPath!, key) : null, includeKeyPath ? _.concat(mappedValueStack!, value) : null); | ||
}); | ||
value = _.mapValues(value, childrenIterator); | ||
} else if (Array.isArray(value)) { | ||
value = _.map(value, (val: any, key: number) => { | ||
return _mapDeep(val, includeKeyPath ? _.concat(keyPath!, key) : null, includeKeyPath ? _.concat(mappedValueStack!, value) : null); | ||
}); | ||
value = _.map(value, childrenIterator); | ||
} | ||
@@ -178,0 +180,0 @@ return value; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2845
158468