Skip to content

Commit

Permalink
Lodash: Refactor away from _.mapValues() in data registry
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed Feb 3, 2023
1 parent 0935351 commit 57ad6bc
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/data/src/registry.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { mapValues } from 'lodash';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -198,14 +193,19 @@ export function createRegistry( storeConfigs = {}, parent = null ) {
// Deprecated
// TODO: Remove this after `use()` is removed.
function withPlugins( attributes ) {
return mapValues( attributes, ( attribute, key ) => {
if ( typeof attribute !== 'function' ) {
return attribute;
}
return function () {
return registry[ key ].apply( null, arguments );
};
} );
return Object.fromEntries(
Object.entries( attributes ).map( ( [ key, attribute ] ) => {
if ( typeof attribute !== 'function' ) {
return [ key, attribute ];
}
return [
key,
function () {
return registry[ key ].apply( null, arguments );
},
];
} )
);
}

/**
Expand Down

0 comments on commit 57ad6bc

Please sign in to comment.