1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.getPropertyByPath = getPropertyByPath;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | function getPropertyByPath(source, path) {
|
14 | if (typeof path === 'string' && Object.prototype.hasOwnProperty.call(source, path)) {
|
15 | return source[path];
|
16 | }
|
17 |
|
18 | const parsedPath = typeof path === 'string' ? path.split('.') : path;
|
19 |
|
20 | return parsedPath.reduce((previous, key) => {
|
21 | if (previous === undefined) {
|
22 | return previous;
|
23 | }
|
24 |
|
25 | return previous[key];
|
26 | }, source);
|
27 | }
|
28 |
|
\ | No newline at end of file |