mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-31 18:17:20 +01:00
19 lines
326 B
JavaScript
Vendored
19 lines
326 B
JavaScript
Vendored
'use strict';
|
|
|
|
/**
|
|
* Get value of a nested property
|
|
*
|
|
* @param mainObject
|
|
* @param key
|
|
* @returns {*}
|
|
*/
|
|
|
|
module.exports = function nestedValue(mainObject, key) {
|
|
try {
|
|
return key.split('.').reduce(function (obj, property) {
|
|
return obj[property];
|
|
}, mainObject);
|
|
} catch (err) {
|
|
return null;
|
|
}
|
|
}; |