UNPKG
@lunaticmuch/front-matter-manipulator
Version:
latest (2.0.2)
2.0.2
2.0.1
2.0.0-alpha.2
2.0.0-alpha.1
1.10.2
1.10.1
1.10.0
1.9.0
1.8.0
1.7.0
1.6.0
1.4.0
1.3.0
1.2.0
1.0.2
1.0.1
1.0.0
A utility for parsing and manipulating documents with Front Matter
@lunaticmuch/front-matter-manipulator
/
lib
/
util
/
getDescendantProp.js
15 lines
(12 loc)
•
305 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export
default
function
getDescendantProp
(
obj, key
) { key = key.
split
(
'.'
);
var
i =
0
;
if
(key.
length
>
1
) {
for
(i =
0
; i < key.
length
-
1
; i++) obj = obj[key[i]];
if
(obj)
return
obj[key[i]]; }
if
(obj)
return
obj[key[i]]; }