You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
400 B
20 lines
400 B
|
3 years ago
|
var castPath = require('./castPath');
|
||
|
|
var isUndef = require('./isUndef');
|
||
|
|
|
||
|
|
exports = function(obj, path, val) {
|
||
|
|
path = castPath(path, obj);
|
||
|
|
var lastProp = path.pop();
|
||
|
|
var prop;
|
||
|
|
prop = path.shift();
|
||
|
|
|
||
|
|
while (!isUndef(prop)) {
|
||
|
|
if (!obj[prop]) obj[prop] = {};
|
||
|
|
obj = obj[prop];
|
||
|
|
prop = path.shift();
|
||
|
|
}
|
||
|
|
|
||
|
|
obj[lastProp] = val;
|
||
|
|
};
|
||
|
|
|
||
|
|
module.exports = exports;
|