UNPKG
require-indexify
Version:
latest (1.0.0)
1.0.0
0.2.2
0.2.1
0.2.0
0.1.1
0.1.0
automatically require modules in a directory
github.com/MegrezZhu/indexify
MegrezZhu/indexify
require-indexify
/
util.js
21 lines
(18 loc)
•
345 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const _ =
require
(
'lodash'
);
function
unsetProp
(obj, path)
{
while
(
true
) {
if
(!_.hasIn(obj,
path
))
break
; _.unset(obj,
path
);
path
.pop();
if
(
path
.length) {
if
(Object.keys(_.get(obj,
path
)).length) {
break
; } }
else
{
break
; } } }
module
.exports = { unsetProp };