1 var baseSet = require('./_baseSet');
4 * This method is like `_.set` except that it accepts `customizer` which is
5 * invoked to produce the objects of `path`. If `customizer` returns `undefined`
6 * path creation is handled by the method instead. The `customizer` is invoked
7 * with three arguments: (nsValue, key, nsObject).
9 * **Note:** This method mutates `object`.
14 * @param {Object} object The object to modify.
15 * @param {Array|string} path The path of the property to set.
16 * @param {*} value The value to set.
17 * @param {Function} [customizer] The function to customize assigned values.
18 * @returns {Object} Returns `object`.
21 * _.setWith({ '0': { 'length': 2 } }, '[0][1][2]', 3, Object);
22 * // => { '0': { '1': { '2': 3 }, 'length': 2 } }
24 function setWith(object, path, value, customizer) {
25 customizer = typeof customizer == 'function' ? customizer : undefined;
26 return object == null ? object : baseSet(object, path, value, customizer);
29 module.exports = setWith;