File "update-state.js"

Full Path: /home/vantageo/public_html/wp-admin-20240915120854/wp-includes-20240915121038/IXR/plugins/woocommerce/packages/woocommerce-blocks/assets/js/data/utils/update-state.js
File size: 476 bytes
MIME-type: text/x-java
Charset: utf-8

/**
 * External dependencies
 */
import { setWith, clone } from 'lodash';

/**
 * Utility for updating state and only cloning objects in the path that changed.
 *
 * @param {Object} state The state being updated
 * @param {Array}  path  The path being updated
 * @param {*}      value The value to update for the path
 *
 * @return {Object} The new state
 */
export default function updateState( state, path, value ) {
	return setWith( clone( state ), path, value, clone );
}