Add getDeep method to utils
This commit is contained in:
parent
e3bae562fc
commit
41c7dff0e8
@ -10,7 +10,7 @@ const i18n = {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
let string = key.split('.').reduce((o,i) => o[i] || {}, config.i18n);
|
let string = utils.getDeep(config.i18n, key);
|
||||||
|
|
||||||
if (utils.is.empty(string)) {
|
if (utils.is.empty(string)) {
|
||||||
return '';
|
return '';
|
||||||
|
@ -728,6 +728,11 @@ const utils = {
|
|||||||
return JSON.parse(JSON.stringify(object));
|
return JSON.parse(JSON.stringify(object));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Get a nested value in an object
|
||||||
|
getDeep(object, value) {
|
||||||
|
return value.split('.').reduce((obj, key) => obj[key] || {}, object);
|
||||||
|
},
|
||||||
|
|
||||||
// Get the closest value in an array
|
// Get the closest value in an array
|
||||||
closest(array, value) {
|
closest(array, value) {
|
||||||
if (!utils.is.array(array) || !array.length) {
|
if (!utils.is.array(array) || !array.length) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user