source: imaps-frontend/node_modules/lodash-es/update.js@ d565449

main
Last change on this file since d565449 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
RevLine 
[d565449]1import baseUpdate from './_baseUpdate.js';
2import castFunction from './_castFunction.js';
3
4/**
5 * This method is like `_.set` except that accepts `updater` to produce the
6 * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
7 * is invoked with one argument: (value).
8 *
9 * **Note:** This method mutates `object`.
10 *
11 * @static
12 * @memberOf _
13 * @since 4.6.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 {Function} updater The function to produce the updated value.
18 * @returns {Object} Returns `object`.
19 * @example
20 *
21 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
22 *
23 * _.update(object, 'a[0].b.c', function(n) { return n * n; });
24 * console.log(object.a[0].b.c);
25 * // => 9
26 *
27 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
28 * console.log(object.x[0].y.z);
29 * // => 0
30 */
31function update(object, path, updater) {
32 return object == null ? object : baseUpdate(object, path, castFunction(updater));
33}
34
35export default update;
Note: See TracBrowser for help on using the repository browser.