CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
update.js36 linesDownload Raw Back to lodash-es
1import baseUpdate from './_baseUpdate.js';2import castFunction from './_castFunction.js';3 4/**5 * This method is like `_.set` except that accepts `updater` to produce the6 * 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 * @static12 * @memberOf _13 * @since 4.6.014 * @category Object15 * @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 * @example20 *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 * // => 926 *27 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });28 * console.log(object.x[0].y.z);29 * // => 030 */31function update(object, path, updater) {32  return object == null ? object : baseUpdate(object, path, castFunction(updater));33}34 35export default update;36 
basant307/AI_Governance_Project · CoolFace