Philipp Horstenkamp 2b58149655
All checks were successful
Auto Maintenance Cycle / pre-commit Autoupdate (push) Successful in 39s
Added the underscore node_module.
2023-11-19 13:27:05 +01:00

22 lines
441 B
JavaScript

define(['./isNumber', './isArray', './isObject'], function (isNumber, isArray, isObject) {
function set (obj, path, value) {
var key = String(path[0]);
if (path.length === 1) {
obj[key] = value;
return;
}
if (!isArray(obj[key]) || !isObject(obj[key])) {
var nextKey = path[1];
obj[key] = isNumber(nextKey) ? [] : {};
}
return set(obj[key], path.slice(1), value);
}
return set;
});