woocommerce/plugins/woocommerce-blocks/assets/js/base/utils/parse-style.ts

17 lines
299 B
TypeScript

/**
* External dependencies
*/
import { isString, isObject } from '@woocommerce/types';
export const parseStyle = ( style: unknown ): Record< string, unknown > => {
if ( isString( style ) ) {
return JSON.parse( style ) || {};
}
if ( isObject( style ) ) {
return style;
}
return {};
};