Skip to content

Commit

Permalink
getValueFromObjectPath: remove memize (#56711)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr authored Dec 1, 2023
1 parent f14c509 commit 08eb841
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/block-editor/src/utils/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import { paramCase } from 'change-case';
import memoize from 'memize';

/**
* Converts any string to kebab case.
Expand Down Expand Up @@ -65,8 +64,6 @@ export function setImmutably( object, path, value ) {
return object;
}

const stringToPath = memoize( ( path ) => path.split( '.' ) );

/**
* Helper util to return a value from a certain path of the object.
* Path is specified as either:
Expand All @@ -80,9 +77,9 @@ const stringToPath = memoize( ( path ) => path.split( '.' ) );
* @return {*} Value of the object property at the specified path.
*/
export const getValueFromObjectPath = ( object, path, defaultValue ) => {
const normalizedPath = Array.isArray( path ) ? path : stringToPath( path );
const arrayPath = Array.isArray( path ) ? path : path.split( '.' );
let value = object;
normalizedPath.forEach( ( fieldName ) => {
arrayPath.forEach( ( fieldName ) => {
value = value?.[ fieldName ];
} );
return value ?? defaultValue;
Expand Down

0 comments on commit 08eb841

Please sign in to comment.