Remove `fromEntriesPolyfill` (https://github.com/woocommerce/woocommerce-blocks/pull/5981)
* Remove fromEntriesPolyfill * Remove further instances of fromEntriesPolyfill
This commit is contained in:
parent
9157930349
commit
db1989aefb
|
@ -28,10 +28,7 @@ import type {
|
|||
CartResponseCouponItem,
|
||||
CartResponseCoupons,
|
||||
} from '@woocommerce/types';
|
||||
import {
|
||||
emptyHiddenAddressFields,
|
||||
fromEntriesPolyfill,
|
||||
} from '@woocommerce/base-utils';
|
||||
import { emptyHiddenAddressFields } from '@woocommerce/base-utils';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -85,7 +82,7 @@ const defaultCartTotals: CartResponseTotals = {
|
|||
const decodeValues = (
|
||||
object: Record< string, unknown >
|
||||
): Record< string, unknown > =>
|
||||
fromEntriesPolyfill(
|
||||
Object.fromEntries(
|
||||
Object.entries( object ).map( ( [ key, value ] ) => [
|
||||
key,
|
||||
decodeEntities( value ),
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { fromEntriesPolyfill } from './from-entries-polyfill';
|
||||
|
||||
/**
|
||||
* Get an array of selected shipping rates keyed by Package ID.
|
||||
*
|
||||
|
@ -10,7 +5,7 @@ import { fromEntriesPolyfill } from './from-entries-polyfill';
|
|||
* @return {Object} Object containing the package IDs and selected rates in the format: { [packageId:string]: rateId:string }
|
||||
*/
|
||||
export const deriveSelectedShippingRates = ( shippingRates ) =>
|
||||
fromEntriesPolyfill(
|
||||
Object.fromEntries(
|
||||
shippingRates.map(
|
||||
( { package_id: packageId, shipping_rates: packageRates } ) => [
|
||||
packageId,
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
/**
|
||||
* A polyfill for Object.fromEntries function.
|
||||
*
|
||||
* @param {Array<[string, unknown]>} array Array to be turned back to object
|
||||
* @return {Record< string, unknown >} the newly created object
|
||||
*/
|
||||
export const fromEntriesPolyfill = (
|
||||
array: Array< [ string, unknown ] >
|
||||
): Record< string, unknown > =>
|
||||
array.reduce< Record< string, unknown > >( ( obj, [ key, val ] ) => {
|
||||
obj[ key ] = val;
|
||||
return obj;
|
||||
}, {} );
|
|
@ -6,5 +6,4 @@ export * from './render-frontend';
|
|||
export * from './get-valid-block-attributes';
|
||||
export * from './product-data';
|
||||
export * from './derive-selected-shipping-rates';
|
||||
export * from './from-entries-polyfill';
|
||||
export * from './get-icons-from-payment-methods';
|
||||
|
|
Loading…
Reference in New Issue