Add getDeep method to utils
This commit is contained in:
		| @ -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) { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user