Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Replace lodash pick with native function
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Apr 21, 2023
1 parent 12e5ab6 commit 8e3bb60
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion assets/js/data/cart/push-changes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
import { pick } from 'lodash';
import { select, dispatch } from '@wordpress/data';
import {
pluckEmail,
Expand Down Expand Up @@ -30,6 +29,15 @@ type CustomerData = {

type BillingOrShippingAddress = CartBillingAddress | CartShippingAddress;

const pick = < Type >( object: Type, keys: string[] ): Type => {
return keys.reduce( ( obj, key ) => {
if ( object && object.hasOwnProperty( key ) ) {
obj[ key as keyof Type ] = object[ key as keyof Type ];
}
return obj;
}, {} as Type );
};

/**
* Checks if a cart response contains an email property.
*/
Expand Down

0 comments on commit 8e3bb60

Please sign in to comment.