main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[d565449] | 1 | import baseSet from './_baseSet.js';
|
---|
| 2 |
|
---|
| 3 | /**
|
---|
| 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).
|
---|
| 8 | *
|
---|
| 9 | * **Note:** This method mutates `object`.
|
---|
| 10 | *
|
---|
| 11 | * @static
|
---|
| 12 | * @memberOf _
|
---|
| 13 | * @since 4.0.0
|
---|
| 14 | * @category Object
|
---|
| 15 | * @param {Object} object The object to modify.
|
---|
| 16 | * @param {Array|string} path The path of the property to set.
|
---|
| 17 | * @param {*} value The value to set.
|
---|
| 18 | * @param {Function} [customizer] The function to customize assigned values.
|
---|
| 19 | * @returns {Object} Returns `object`.
|
---|
| 20 | * @example
|
---|
| 21 | *
|
---|
| 22 | * var object = {};
|
---|
| 23 | *
|
---|
| 24 | * _.setWith(object, '[0][1]', 'a', Object);
|
---|
| 25 | * // => { '0': { '1': 'a' } }
|
---|
| 26 | */
|
---|
| 27 | function setWith(object, path, value, customizer) {
|
---|
| 28 | customizer = typeof customizer == 'function' ? customizer : undefined;
|
---|
| 29 | return object == null ? object : baseSet(object, path, value, customizer);
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | export default setWith;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.