woocommerce/plugins/woocommerce-blocks/assets/js/base/context/event-emit/utils.ts

16 lines
369 B
TypeScript

/**
* Internal dependencies
*/
import type { EventObserversType, ObserverType } from './types';
export const getObserversByPriority = (
observers: EventObserversType,
eventType: string
): ObserverType[] => {
return observers[ eventType ]
? Array.from( observers[ eventType ].values() ).sort( ( a, b ) => {
return a.priority - b.priority;
} )
: [];
};