woocommerce/plugins/woocommerce-admin/client/wp-admin-scripts/shipping-settings-region-pi.../utils.js

15 lines
387 B
JavaScript

export const recursivelyTransformLabels = ( node, transform ) => {
if ( Array.isArray( node ) ) {
return node.map( ( element ) => {
return recursivelyTransformLabels( element, transform );
} );
}
if ( node.label ) {
node.label = transform( node.label );
}
if ( node.children ) {
node.children = recursivelyTransformLabels( node.children, transform );
}
return node;
};