From 08eb841d240fdef01ab9aa89bf3bc4c7d11fab80 Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Fri, 1 Dec 2023 12:18:14 +0100 Subject: [PATCH] getValueFromObjectPath: remove memize (#56711) --- packages/block-editor/src/utils/object.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/block-editor/src/utils/object.js b/packages/block-editor/src/utils/object.js index 526f037899fd0..5238056426417 100644 --- a/packages/block-editor/src/utils/object.js +++ b/packages/block-editor/src/utils/object.js @@ -2,7 +2,6 @@ * External dependencies */ import { paramCase } from 'change-case'; -import memoize from 'memize'; /** * Converts any string to kebab case. @@ -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: @@ -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;