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.2 KB
|
Rev | Line | |
---|
[d565449] | 1 | import baseUpdate from './_baseUpdate.js';
|
---|
| 2 | import castFunction from './_castFunction.js';
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * This method is like `_.update` except that it accepts `customizer` which is
|
---|
| 6 | * invoked to produce the objects of `path`. If `customizer` returns `undefined`
|
---|
| 7 | * path creation is handled by the method instead. The `customizer` is invoked
|
---|
| 8 | * with three arguments: (nsValue, key, nsObject).
|
---|
| 9 | *
|
---|
| 10 | * **Note:** This method mutates `object`.
|
---|
| 11 | *
|
---|
| 12 | * @static
|
---|
| 13 | * @memberOf _
|
---|
| 14 | * @since 4.6.0
|
---|
| 15 | * @category Object
|
---|
| 16 | * @param {Object} object The object to modify.
|
---|
| 17 | * @param {Array|string} path The path of the property to set.
|
---|
| 18 | * @param {Function} updater The function to produce the updated value.
|
---|
| 19 | * @param {Function} [customizer] The function to customize assigned values.
|
---|
| 20 | * @returns {Object} Returns `object`.
|
---|
| 21 | * @example
|
---|
| 22 | *
|
---|
| 23 | * var object = {};
|
---|
| 24 | *
|
---|
| 25 | * _.updateWith(object, '[0][1]', _.constant('a'), Object);
|
---|
| 26 | * // => { '0': { '1': 'a' } }
|
---|
| 27 | */
|
---|
| 28 | function updateWith(object, path, updater, customizer) {
|
---|
| 29 | customizer = typeof customizer == 'function' ? customizer : undefined;
|
---|
| 30 | return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | export default updateWith;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.