File "from-entries-polyfill.ts"
Full path: /home/kosmetik/public_html/wp-content/plugins/woocommerce/packages/woocommerce-blocks/assets/js/base/utils/from-entries-polyfill.ts
File
size: 420 B
MIME-type: text/plain
Charset: utf-8
Download Open Edit Advanced Editor Back
/**
* 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;
}, {} );