initial commit

This commit is contained in:
2021-12-10 12:03:04 +00:00
commit c46c7ddbf0
3643 changed files with 582794 additions and 0 deletions

View File

@ -0,0 +1,16 @@
/**
* External dependencies
*/
import { has } from 'lodash';
/**
* Utility for returning whether the given path exists in the state.
*
* @param {Object} state The state being checked
* @param {Array} path The path to check
*
* @return {boolean} True means this exists in the state.
*/
export default function hasInState( state, path ) {
return has( state, path );
}

View File

@ -0,0 +1,2 @@
export { default as hasInState } from './has-in-state';
export { default as updateState } from './update-state';

View File

@ -0,0 +1,17 @@
/**
* 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 );
}