* Underlying get mechanism * * @method getPath * @param {object} object - Object to get the property for * @param {string|string[]} property - The property name to get (as an array or '.' delimited string) * @return {*} value - Property value, including undefined if not defined.
(object, property)
| 598 | * @return {*} value - Property value, including undefined if not defined. |
| 599 | */ |
| 600 | static getPath(object, property) { |
| 601 | const path = Array.isArray(property) ? property : property.split('.'); |
| 602 | |
| 603 | let next = object; |
| 604 | for (let i = 0; i < path.length; i++) { |
| 605 | const name = path[i]; |
| 606 | const value = next[name]; |
| 607 | |
| 608 | if (i === path.length - 1) { |
| 609 | return value; |
| 610 | } |
| 611 | |
| 612 | // Note that typeof null === 'object' |
| 613 | if (value === null || typeof value !== 'object') { |
| 614 | return undefined; |
| 615 | } |
| 616 | |
| 617 | next = value; |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | /** |
| 622 | * Set objects given a path as a string list |
no outgoing calls
no test coverage detected